Alfaritsi Hamdani
Alfaritsi Hamdani

Reputation: 143

Can't generate documentation using swagger on laravel

i recently use swagger in my project, i'm using L5-swagger from DarkaOnLine. I was followed installation step. After i installed it, i add this code at my controller

/**
* @SWG\Swagger(
*   basePath="/users",
*   @SWG\Info(
*     title="List all available users",
*     version="1.0.0"
*   )
* )
*/

After that, i run "php artisan l5-swagger:generate" in terminal. But i got this error :

"Required @OAS\Info() not found"

Upvotes: 2

Views: 3159

Answers (2)

Danilo Mijailovic
Danilo Mijailovic

Reputation: 15

You will need

/**
 * @OA\Info(title="My First API", version="0.1")
*/

but after this line of code, you will have a new error. So put the info below the starting brackets of class, and above the controller you need, but the second block of code, of course you need to modify it for your routes.

/**
 * @OA\Get(
 *     path="/projects",
 *     @OA\Response(response="200", description="Display a listing of projects.")
 * )
 */

Upvotes: 0

pspatel
pspatel

Reputation: 518

I think you have to replace the version of swagger-php to 2.0. The same error is mention in SwaggerLume of DarkaOnLine on Github.

See here: https://github.com/DarkaOnLine/SwaggerLume/issues/51

Upvotes: 1

Related Questions