knuckleswtf / scribe

Generate API documentation for humans from your Laravel codebase.✍
https://scribe.knuckles.wtf/laravel/
MIT License
1.72k stars 307 forks source link

Excluded routes still showing in documentation #175

Closed juliakerschbaummayr1 closed 3 years ago

juliakerschbaummayr1 commented 3 years ago

What happened? In the scribe.php file at 'routes' => 'match' => 'prefixes' I set the value to ['api/*'] to only show routes from my api in the documentation. But it seems that this value is ignored because all of my routes are showing. I also grouped my endpoints. This works and the different groups are showing, but still some of the routes are showing in the created group and also in the default group Endpoints.

So my two questions are:

My environment:

My Scribe config (minus the comments):

return [
    'title' => null,
    'description' => '',
    'routes' => [
        [
            'match' => [
                'domains' => ['*'],
                'prefixes' => ['api/*'],
                'versions' => ['v1'],
            ],
            'include' => [
            ],
            'exclude' => [
            ],
            'apply' => [
                'headers' => [
                    'Content-Type' => 'application/json',
                    'Accept' => 'application/json',
                ],
                'response_calls' => [
                    'methods' => ['GET'],
                    'config' => [
                        'app.env' => 'documentation',
                    ],
                    'queryParams' => [
                    ],
                    'bodyParams' => [
                    ],
                    'fileParams' => [
                    ],
                    'cookies' => [
                    ],
                ],
            ],
        ],
    ],
    'type' => 'laravel',
    'static' => [
        'output_path' => 'public/docs',
    ],
    'laravel' => [
        'add_routes' => true,
        'docs_url' => '/docs',
        'middleware' => [],
    ],
    'interactive' => true,
    'auth' => [
        'enabled' => true,
        'default' => false,
        'in' => 'query',
        'name' => 'token',
        'use_value' => env('SCRIBE_AUTH_KEY'),
        'placeholder' => '{YOUR_AUTH_KEY}',
        'extra_info' => 'You can retrieve your token by visiting your dashboard and clicking <b>Generate API token</b>.',
    ],
    'intro_text' => <<<INTRO
This documentation aims to provide all the information you need to work with our API.
<aside>As you scroll, you'll see code examples for working with the API in different programming languages in the dark area to the right (or as part of the content on mobile).
You can switch the language used with the tabs at the top right (or from the nav menu at the top left on mobile).</aside>
INTRO
    ,
    'example_languages' => [
        'bash',
        'javascript',
    ],
    'base_url' => null,
    'postman' => [
        'enabled' => true,
        'overrides' => [
        ],
    ],
    'openapi' => [
        'enabled' => true,
        'overrides' => [
        ],
    ],
    'default_group' => 'Endpoints',
    'logo' => false,
    'router' => 'laravel',
    'faker_seed' => null,
    'strategies' => [
        'metadata' => [
            \Knuckles\Scribe\Extracting\Strategies\Metadata\GetFromDocBlocks::class,
        ],
        'urlParameters' => [
            \Knuckles\Scribe\Extracting\Strategies\UrlParameters\GetFromLaravelAPI::class,
            \Knuckles\Scribe\Extracting\Strategies\UrlParameters\GetFromLumenAPI::class,
            \Knuckles\Scribe\Extracting\Strategies\UrlParameters\GetFromUrlParamTag::class,
        ],
        'queryParameters' => [
            \Knuckles\Scribe\Extracting\Strategies\QueryParameters\GetFromQueryParamTag::class,
        ],
        'headers' => [
            \Knuckles\Scribe\Extracting\Strategies\Headers\GetFromRouteRules::class,
            \Knuckles\Scribe\Extracting\Strategies\Headers\GetFromHeaderTag::class,
        ],
        'bodyParameters' => [
            \Knuckles\Scribe\Extracting\Strategies\BodyParameters\GetFromFormRequest::class,
            \Knuckles\Scribe\Extracting\Strategies\BodyParameters\GetFromBodyParamTag::class,
        ],
        'responses' => [
            \Knuckles\Scribe\Extracting\Strategies\Responses\UseTransformerTags::class,
            \Knuckles\Scribe\Extracting\Strategies\Responses\UseResponseTag::class,
            \Knuckles\Scribe\Extracting\Strategies\Responses\UseResponseFileTag::class,
            \Knuckles\Scribe\Extracting\Strategies\Responses\UseApiResourceTags::class,
            \Knuckles\Scribe\Extracting\Strategies\Responses\ResponseCalls::class,
        ],
        'responseFields' => [
            \Knuckles\Scribe\Extracting\Strategies\ResponseFields\GetFromResponseFieldTag::class,
        ],
    ],
    'fractal' => [
        'serializer' => null,
    ],
    'routeMatcher' => \Knuckles\Scribe\Matching\RouteMatcher::class,
    'continue_without_database_transactions' => [],
    'database_connections_to_transact' => [config('database.default')]
];
shalvah commented 3 years ago

That's weird. I couldn't reproduce this. Route rules work fine in both the package tests and my machine. Try debugging this further by running in verbose mode and adding some log statements.

juliakerschbaummayr1 commented 3 years ago

I am not sure what you mean, but I ran php artisan scribe:generate --verbose and copied the output here, hope this helps

As you can see I added @hideFromAPIDocumentation to a lot of routes to prevent them from showing in the documentation but some are still showing although they donΒ΄t start with api/, for example login, logout, register and so on

The route api/forums/all/{courseId} is an example of the routes I have two times, in the Forums group and in the general Endpoints group

php artisan scribe:generate --verbose πŸ”Š info Processing route: [GET] sanctum/csrf-cookie πŸ‘ success Processed route: [GET] sanctum/csrf-cookie πŸ”Š info Processing route: [GET] api/user πŸ‘ success Processed route: [GET] api/user πŸ”Š info Processing route: [POST] api/tokens/create πŸ‘ success Processed route: [POST] api/tokens/create πŸ”Š info Processing route: [GET] api/courses πŸ‘ success Processed route: [GET] api/courses πŸ”Š info Processing route: [PUT] api/courses/follow/{id} πŸ‘ success Processed route: [PUT] api/courses/follow/{id} πŸ”Š info Processing route: [GET] api/coaches/all/{courseId} πŸ‘ success Processed route: [GET] api/coaches/all/{courseId} πŸ”Š info Processing route: [GET] api/coaches/{id} πŸ‘ success Processed route: [GET] api/coaches/{id} πŸ”Š info Processing route: [GET] api/forums/all/{courseId} πŸ‘ success Processed route: [GET] api/forums/all/{courseId} πŸ”Š info Processing route: [GET] api/forums/{id} πŸ‘ success Processed route: [GET] api/forums/{id} πŸ”Š info Processing route: [PUT] api/forums/{courseId} πŸ‘ success Processed route: [PUT] api/forums/{courseId} πŸ”Š info Processing route: [GET] api/forums/comments/{id} πŸ‘ success Processed route: [GET] api/forums/comments/{id} πŸ”Š info Processing route: [PUT] api/forums/comments/{id} πŸ‘ success Processed route: [PUT] api/forums/comments/{id} πŸ”Š info Processing route: [GET] api/videos/all/{courseId} πŸ‘ success Processed route: [GET] api/videos/all/{courseId} πŸ”Š info Processing route: [GET] api/videos/{id} πŸ‘ success Processed route: [GET] api/videos/{id} 🚸 warning Skipping route: [GET] activate/{user}/{token}: @hideFromAPIDocumentation was specified. πŸ”Š info Processing route: [GET] login πŸ‘ success Processed route: [GET] login 🚸 warning Skipping route: [POST] login: @hideFromAPIDocumentation was specified. πŸ”Š info Processing route: [POST] logout πŸ‘ success Processed route: [POST] logout πŸ”Š info Processing route: [GET] register πŸ‘ success Processed route: [GET] register πŸ”Š info Processing route: [POST] register πŸ‘ success Processed route: [POST] register πŸ”Š info Processing route: [GET] password/reset πŸ‘ success Processed route: [GET] password/reset πŸ”Š info Processing route: [POST] password/email πŸ‘ success Processed route: [POST] password/email πŸ”Š info Processing route: [GET] password/reset/{token} πŸ‘ success Processed route: [GET] password/reset/{token} πŸ”Š info Processing route: [POST] password/reset πŸ‘ success Processed route: [POST] password/reset πŸ”Š info Processing route: [GET] / πŸ‘ success Processed route: [GET] / 🚸 warning Skipping route: [GET] home: @hideFromAPIDocumentation was specified. 🚸 warning Skipping route: [GET] admin/coachings: @hideFromAPIDocumentation was specified. 🚸 warning Skipping route: [GET] admin/coachings/create: @hideFromAPIDocumentation was specified. 🚸 warning Skipping route: [POST] admin/coachings: @hideFromAPIDocumentation was specified. 🚸 warning Skipping route: [GET] admin/coachings/{coaching} - Controller method does not exist. 🚸 warning Skipping route: [GET] admin/coachings/{coaching}/edit: @hideFromAPIDocumentation was specified. 🚸 warning Skipping route: [PUT,PATCH] admin/coachings/{coaching}: @hideFromAPIDocumentation was specified. 🚸 warning Skipping route: [DELETE] admin/coachings/{coaching}: @hideFromAPIDocumentation was specified. 🚸 warning Skipping route: [GET] admin/coaching/signout/{attendee}: @hideFromAPIDocumentation was specified. 🚸 warning Skipping route: [GET] admin/coaching/cancel/{coaching}: @hideFromAPIDocumentation was specified. πŸ”Š info Processing route: [POST] admin/notifications/{notification}/read πŸ‘ success Processed route: [POST] admin/notifications/{notification}/read πŸ”Š info Processing route: [POST] admin/notifications/read πŸ‘ success Processed route: [POST] admin/notifications/read 🚸 warning Skipping route: [GET] admin/forums: @hideFromAPIDocumentation was specified. 🚸 warning Skipping route: [GET] admin/forums/create: @hideFromAPIDocumentation was specified. 🚸 warning Skipping route: [POST] admin/forums: @hideFromAPIDocumentation was specified. 🚸 warning Skipping route: [GET] admin/forums/{forum}: @hideFromAPIDocumentation was specified. 🚸 warning Skipping route: [GET] admin/forums/{forum}/edit: @hideFromAPIDocumentation was specified. 🚸 warning Skipping route: [PUT,PATCH] admin/forums/{forum}: @hideFromAPIDocumentation was specified. 🚸 warning Skipping route: [DELETE] admin/forums/{forum}: @hideFromAPIDocumentation was specified. 🚸 warning Skipping route: [POST] admin/forums/{forum}/add/comment: @hideFromAPIDocumentation was specified. πŸ”Š info Processing route: [GET] admin/mailable/{id}/{type} πŸ‘ success Processed route: [GET] admin/mailable/{id}/{type} πŸ”Š info Processing route: [GET] admin/testnotification/{id} πŸ‘ success Processed route: [GET] admin/testnotification/{id} 🚸 warning Skipping route: [GET] coaching/coachings: @hideFromAPIDocumentation was specified. 🚸 warning Skipping route: [GET] coaching/attend/{coaching}: @hideFromAPIDocumentation was specified. 🚸 warning Skipping route: [GET] coaching/info/{coaching}: @hideFromAPIDocumentation was specified. 🚸 warning Skipping route: [GET] coaching/signout/{coaching}: @hideFromAPIDocumentation was specified. πŸ”Š info Processing route: [GET] coachings πŸ‘ success Processed route: [GET] coachings πŸ”Š info Processing route: [GET] forum πŸ‘ success Processed route: [GET] forum πŸ”Š info Processing route: [GET] forum/{forum} πŸ‘ success Processed route: [GET] forum/{forum} πŸ”Š info Processing route: [GET] testcrudgenerator CrudGeneratorServiceProvider: OKπŸ‘ success Processed route: [GET] testcrudgenerator πŸ”Š info Writing source Markdown files to: resources/docs 🚸 warning Skipping modified file resources/docs/groups/endpoints.md 🚸 warning Skipping modified file resources/docs/index.md 🚸 warning Skipping modified file resources/docs/authentication.md πŸ”Š info Wrote source Markdown files to: resources/docs πŸ”Š info Transforming Markdown docs to HTML... πŸ‘ success Wrote HTML documentation to: resources/views/scribe πŸ”Š info Generating Postman collection πŸ‘ success Wrote Postman collection to: storage/app/scribe/collection.json πŸ”Š info Generating OpenAPI specification πŸ‘ success Wrote OpenAPI specification to: storage/app/scribe/openapi.yaml

juliakerschbaummayr1 commented 3 years ago

not sure why but it works now I added Authentication and generated the docs again and now it works, so IΒ΄ll close this issue