Reputation: 5720
I'm integrating into my Laravel5 project swagger :
"darkaonline/l5-swagger": "^5.5"
I have two projects with no problem having the following block of code defined at the top of ../routes/api.php
/**
* @SWG\Swagger(
* basePath="/api",
* @SWG\Info(
* title="MyApp API",
* version="0.2"
* )
* )
*/
Now with a new project I'm experiencing @SWG\Info() not found error when :
php artisan l5-swagger:generate
If I move the @SWG\Swagger block of code form routes\api.php to
..../app/Http/Controllers/ApiController.php
Command l5-swagger:generate will instead succeed.
Why is that? Laravel Projects looks the same. What could prevent from generating the swagger having the SWG\info in routes\api.php?
Upvotes: 1
Views: 3458
Reputation: 2069
I got this problem as well.
Laravel version:5 5.7
After running command:
composer require zircote/swagger-php:2.*require zircote/swagger-php:2.*
Then add the following setting .env
SWAGGER_VERSION=2.0
Changing a line in Config/l5-swagger.php
'swagger_version' => env('SWAGGER_VERSION', '2.0'),
Problem solved~solved.
Upvotes: 1
Reputation: 725
You already installed this below the library.
"darkaonline/l5-swagger": "^5.5"
Then put this below code in parent controller below the class name like this.
/**
* @SWG\Swagger(
* @SWG\Info(
* title="Site Title",
* version="1.0",
* description="Site description",
* @SWG\Contact(
* email="[email protected]"
* )
* )
* )
*/
class Controller extends BaseController
{
}
Upvotes: 3