When I use attributes to document example responses the status code is not included in the output.
Screenshots and stack traces:
Using an attribute:
results in:
Using a docblock:
results in:
As you can see, the first response example screenshot using attributes is missing the status code, whereas the second response example screenshot using a docblock includes the status code.
My environment:
PHP version (from php -v): 8.1.12
Framework (Laravel/Lumen): Laravel
Laravel/Lumen version (from composer show laravel/framework or composer show laravel/lumen-framework): 9.40.1
Scribe version (from composer show knuckleswtf/scribe): 4.5.0
My Scribe config (minus the comments):
<?php
use Knuckles\Scribe\Extracting\Strategies;
return [
'theme' => 'default',
'title' => null,
'description' => 'My API',
'base_url' => null,
'routes' => [
[
'match' => [
'prefixes' => ['api/*'],
'domains' => ['*'],
'versions' => ['v1'],
],
'include' => [],
'exclude' => [],
'apply' => [
'headers' => [
'Content-Type' => 'application/json',
'Accept' => 'application/json',
],
'response_calls' => [
'methods' => ['GET'],
'config' => [
'app.env' => 'documentation',
// 'app.debug' => false,
],
'queryParams' => [],
'bodyParams' => [],
'fileParams' => [],
'cookies' => [],
],
],
],
],
'type' => 'laravel',
'static' => [
'output_path' => 'public/docs',
],
'laravel' => [
'add_routes' => true,
'docs_url' => '/docs',
'assets_directory' => null,
'middleware' => [],
],
'try_it_out' => [
'enabled' => true,
'base_url' => null,
'use_csrf' => true,
'csrf_url' => '/sanctum/csrf-cookie',
],
'auth' => [
'enabled' => true,
'default' => true,
'in' => 'bearer',
'name' => 'key',
'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',
],
'postman' => [
'enabled' => true,
'overrides' => [],
],
'openapi' => [
'enabled' => true,
'overrides' => [],
],
'groups' => [
'default' => 'Endpoints',
'order' => [],
],
'logo' => false,
'last_updated' => 'Last updated: {date:F j, Y}',
'examples' => [
'faker_seed' => null,
'models_source' => ['factoryCreate', 'factoryMake', 'databaseFirst'],
],
'strategies' => [
'metadata' => [
Strategies\Metadata\GetFromDocBlocks::class,
Strategies\Metadata\GetFromMetadataAttributes::class,
],
'urlParameters' => [
Strategies\UrlParameters\GetFromLaravelAPI::class,
Strategies\UrlParameters\GetFromLumenAPI::class,
Strategies\UrlParameters\GetFromUrlParamAttribute::class,
Strategies\UrlParameters\GetFromUrlParamTag::class,
],
'queryParameters' => [
Strategies\QueryParameters\GetFromFormRequest::class,
Strategies\QueryParameters\GetFromInlineValidator::class,
Strategies\QueryParameters\GetFromQueryParamAttribute::class,
Strategies\QueryParameters\GetFromQueryParamTag::class,
],
'headers' => [
Strategies\Headers\GetFromRouteRules::class,
Strategies\Headers\GetFromHeaderAttribute::class,
Strategies\Headers\GetFromHeaderTag::class,
],
'bodyParameters' => [
Strategies\BodyParameters\GetFromFormRequest::class,
Strategies\BodyParameters\GetFromInlineValidator::class,
Strategies\BodyParameters\GetFromBodyParamAttribute::class,
Strategies\BodyParameters\GetFromBodyParamTag::class,
],
'responses' => [
Strategies\Responses\UseResponseAttributes::class,
Strategies\Responses\UseTransformerTags::class,
Strategies\Responses\UseApiResourceTags::class,
Strategies\Responses\UseResponseTag::class,
Strategies\Responses\UseResponseFileTag::class,
Strategies\Responses\ResponseCalls::class,
],
'responseFields' => [
Strategies\ResponseFields\GetFromResponseFieldAttribute::class,
Strategies\ResponseFields\GetFromResponseFieldTag::class,
],
],
'fractal' => [
'serializer' => null,
],
'routeMatcher' => \Knuckles\Scribe\Matching\RouteMatcher::class,
'database_connections_to_transact' => [config('database.default')],
];
What happened?
When I use attributes to document example responses the status code is not included in the output.
Screenshots and stack traces:
Using an attribute:
results in:
Using a docblock:
results in:
As you can see, the first response example screenshot using attributes is missing the status code, whereas the second response example screenshot using a docblock includes the status code.
My environment:
php -v
): 8.1.12composer show laravel/framework
orcomposer show laravel/lumen-framework
): 9.40.1composer show knuckleswtf/scribe
): 4.5.0My Scribe config (minus the comments):