Swagger on Laravel, using the Ref method to call a static message for a response annotation

115 Views Asked by At

I have this follow code that use the Ref method of swagger to call a static message inside another file: Anotation on a function in the controller:

 *   @OA\Response(
 *     response=422,
 *     ref="#/components/responses/Forbidden"
 *   )

File that contains the Static Message its found on the directory: /config/responses.php

It contais the follow message:


<?php

return [
    'Forbidden' => [
        'description' => 'Forbidden',
        'content' => [
            'application/json' => [
                'schema' => [
                    'type' => 'object',
                    'properties' => [
                        'message' => [
                            'type' => 'string',
                            'example' => 'Sorry, you do not have permission to access this resource.'
                        ],
                    ],
                ],
            ],
        ],
    ],
];

How can I make it so that when I run "php craftser l5-swagger:generate" this code "ref" can find the message. Furthermore, I assigned l5-swagger.php within the configuration with an address to /config/responses.php using the base_path command.

'responses' => base_path('config/responses.php'),

I tried to run the generate of the Swagger with php artisan, but it returns to me the follow error:

$ref "#/components/responses/" not found for @OA\Response(response=422) in \App\Http\Controllers\ProductReviewController->update() in /Applications/XAMPP/xamppfiles/htdocs/WEBSITE/app/Http/Controllers/ProductReviewController.php on line 90

0

There are 0 best solutions below