PHP code example of bornfight / jsonapi-documentation

1. Go to this page and download the library: Download bornfight/jsonapi-documentation library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

bornfight / jsonapi-documentation example snippets


    Bornfight\JsonApiDocumentation\BornfightJsonApiDocumentation::class => [ 'all' => true],



namespace App\Documentation;

use Bornfight\JsonApiDocumentation\Documentation\CustomDocumentationInterface;
use Symfony\Component\Yaml\Yaml;

class CustomDocumentationHandler implements CustomDocumentationInterface
{
    /**
     * @var string
     */
    private $projectDir;

    public function __construct(string $projectDir)
    {
        $this->projectDir = $projectDir;
    }


    public function decorate(array &$documentation): void
    {
        $baseDir = '/documentation/parts/';

        // add custom routes
        //login
        $templateFile = $this->projectDir . $baseDir . 'login.yaml';
        $routeDefinition = Yaml::parseFile($templateFile);
        $documentation['paths']['/auth/login'] = $routeDefinition;
    }
}

php bin/console jsonapi:documentation:generate