Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Laravel-Swagger : Error generating the documentation #400

Open
Davidinho241 opened this issue Aug 3, 2021 · 5 comments
Open

Laravel-Swagger : Error generating the documentation #400

Davidinho241 opened this issue Aug 3, 2021 · 5 comments

Comments

@Davidinho241
Copy link

  • L5-Swagger Version: #.#.# (composer show | grep l5-swagger) : 8.0
  • PHP Version (php -v): 7.4.21
  • OS: Windows 10
  • Laravel Version : 8.0
  • Laravel/Passport : 10.1

Description: Hi support, I have integrate L5-Swagger successfully in my Laravel project, but when I try to generate the documentation with the command php artisan l5-swagger: generate I got the follow Error :

Image of the Error :

image

My config/l5-swagger.php file :

`<?php

return [
'default' => 'default',
'documentations' => [
'default' => [
'api' => [
'title' => 'L5 Swagger UI',
],

        'routes' => [
            /*
             * Route for accessing api documentation interface
            */
            'api' => 'api/documentation',
        ],
        'paths' => [
            /*
             * File name of the generated json documentation file
            */
            'docs_json' => 'api-docs.json',

            /*
             * File name of the generated YAML documentation file
            */
            'docs_yaml' => 'api-docs.yaml',

            /*
            * Set this to `json` or `yaml` to determine which documentation file to use in UI
            */
            'format_to_use_for_docs' => env('L5_FORMAT_TO_USE_FOR_DOCS', 'json'),

            /*
             * Absolute paths to directory containing the swagger annotations are stored.
            */
            'annotations' => [
                base_path('app'),
            ],

        ],
    ],
],
'defaults' => [
    'routes' => [
        /*
         * Route for accessing parsed swagger annotations.
        */
        'docs' => 'docs',

        /*
         * Route for Oauth2 authentication callback.
        */
        'oauth2_callback' => 'api/oauth2-callback',

        /*
         * Middleware allows to prevent unexpected access to API documentation
        */
        'middleware' => [
            'api' => [
                \App\Http\Middleware\EncryptCookies::class,
                \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
                \Illuminate\Session\Middleware\StartSession::class,
                \Illuminate\View\Middleware\ShareErrorsFromSession::class,
                \App\Http\Middleware\VerifyCsrfToken::class,
                \Illuminate\Routing\Middleware\SubstituteBindings::class,
                \Laravel\Passport\Http\Middleware\CreateFreshApiToken::class,
                'auth',
            ],
            'asset' => [],
            'docs' => [],
            'oauth2_callback' => [],
        ],

        /*
         * Route Group options
        */
        'group_options' => [],
    ],

    'paths' => [
        /*
         * Absolute path to location where parsed annotations will be stored
        */
        'docs' => storage_path('api-docs'),

        /*
         * Absolute path to directory where to export views
        */
        'views' => base_path('resources/views/vendor/l5-swagger'),

        /*
         * Edit to set the api's base path
        */
        'base' => env('L5_SWAGGER_BASE_PATH', null),

        /*
         * Edit to set path where swagger ui assets should be stored
        */
        'swagger_ui_assets_path' => env('L5_SWAGGER_UI_ASSETS_PATH', 'vendor/swagger-api/swagger-ui/dist/'),

        /*
         * Absolute path to directories that should be exclude from scanning
         * @deprecated Please use `scanOptions.exclude`
         * `scanOptions.exclude` overwrites this
        */
        'excludes' => [],
    ],

    'scanOptions' => [
        /**
         * analyser: defaults to \OpenApi\StaticAnalyser .
         * @see \OpenApi\scan
         */
        'analyser' => null,

        /**
         * analysis: defaults to a new \OpenApi\Analysis .
         * @see \OpenApi\scan
         */
        'analysis' => null,

        /**
         * Custom query path processors classes.
         *
         * @link https://github.com/zircote/swagger-php/tree/master/Examples/schema-query-parameter-processor
         * @see \OpenApi\scan
         */
        'processors' => [
            // new \App\SwaggerProcessors\SchemaQueryParameter(),
        ],

        /**
         * pattern: string       $pattern File pattern(s) to scan (default: *.php) .
         * @see \OpenApi\scan
         */
        'pattern' => null,

        /*
         * Absolute path to directories that should be exclude from scanning
         * @note This option overwrites `paths.excludes`
         * @see \OpenApi\scan
        */
        'exclude' => [],
    ],

    /*
     * API security definitions. Will be generated into documentation file.
    */
    'securityDefinitions' => [
        'securitySchemes' => [
            /*
             * Examples of Security schemes
            */
            /*
            'api_key_security_example' => [ // Unique name of security
                'type' => 'apiKey', // The type of the security scheme. Valid values are "basic", "apiKey" or "oauth2".
                'description' => 'A short description for security scheme',
                'name' => 'api_key', // The name of the header or query parameter to be used.
                'in' => 'header', // The location of the API key. Valid values are "query" or "header".
            ],
            'oauth2_security_example' => [ // Unique name of security
                'type' => 'oauth2', // The type of the security scheme. Valid values are "basic", "apiKey" or "oauth2".
                'description' => 'A short description for oauth2 security scheme.',
                'flow' => 'implicit', // The flow used by the OAuth2 security scheme. Valid values are "implicit", "password", "application" or "accessCode".
                'authorizationUrl' => 'http://example.com/auth', // The authorization URL to be used for (implicit/accessCode)
                //'tokenUrl' => 'http://example.com/auth' // The authorization URL to be used for (password/application/accessCode)
                'scopes' => [
                    'read:projects' => 'read your projects',
                    'write:projects' => 'modify projects in your account',
                ]
            ],
            */

            // Open API 3.0 support
            'passport' => [ // Unique name of security
                'type' => 'oauth2', // The type of the security scheme. Valid values are "basic", "apiKey" or "oauth2".
                'description' => 'Laravel passport oauth2 security.',
                'in' => 'header',
                'scheme' => 'https',
                'flows' => [
                    "password" => [
                        "authorizationUrl" => config('app.url') . '/oauth/authorize',
                        "tokenUrl" => config('app.url') . '/oauth/token',
                        "refreshUrl" => config('app.url') . '/token/refresh',
                        "scopes" => []
                    ],
                ],
            ],
        ],
        'security' => [
            /*
             * Examples of Securities
            */
            [
                /*
                'oauth2_security_example' => [
                    'read',
                    'write'
                ],

                'passport' => []
                */
            ],
        ],
    ],

    /*
     * Set this to `true` in development mode so that docs would be regenerated on each request
     * Set this to `false` to disable swagger generation on production
    */
    'generate_always' => env('L5_SWAGGER_GENERATE_ALWAYS', false),

    /*
     * Set this to `true` to generate a copy of documentation in yaml format
    */
    'generate_yaml_copy' => env('L5_SWAGGER_GENERATE_YAML_COPY', false),

    /*
     * Edit to trust the proxy's ip address - needed for AWS Load Balancer
     * string[]
    */
    'proxy' => false,

    /*
     * Configs plugin allows to fetch external configs instead of passing them to SwaggerUIBundle.
     * See more at: https://github.com/swagger-api/swagger-ui#configs-plugin
    */
    'additional_config_url' => null,

    /*
     * Apply a sort to the operation list of each API. It can be 'alpha' (sort by paths alphanumerically),
     * 'method' (sort by HTTP method).
     * Default is the order returned by the server unchanged.
    */
    'operations_sort' => env('L5_SWAGGER_OPERATIONS_SORT', null),

    /*
     * Pass the validatorUrl parameter to SwaggerUi init on the JS side.
     * A null value here disables validation.
    */
    'validator_url' => null,

    /*
     * Persist authorization login after refresh browser
     */
    'persist_authorization' => true,

    /*
     * Uncomment to add constants which can be used in annotations
     */
    // 'constants' => [
    // 'L5_SWAGGER_CONST_HOST' => env('L5_SWAGGER_CONST_HOST', 'http://my-default-host.com'),
    // ],
],

];
`

Please I need help

@engwebdev
Copy link

I have the same problem. Did you come up with a solution?

@rakshitbharat
Copy link

@premalatha1999
Copy link

Anyone got solution for this issue ? i have the same problem.

@premalatha1999
Copy link

premalatha1999 commented Jun 15, 2022

I got fixed this issue by deleted l5-swagger.php file from my config folder and republished the l5-swagger.php config file.

@malisoft
Copy link

Anyone got solution for this issue ? i have the same problem.

yeah changing the default value(maybe you have it as defaults) to a specific key in you documents array(maybe you have for "systemone" "systemtwo") but this will generate the documents for only choiced key, example you takes systemone value in default so will generate the documents only for it, if you wants for the systemtwo, change de default value to it and php artisan l5-swagger:generate and will generate the second document, pff

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants