Reset L5-swagger API Documentation in Laravel

938 Views Asked by At

I have been using swagger to generate API docs for a long time but all of a sudden I began getting this error message anytime I run php artisan L5-swagger:generate.

 ErrorException 

  Unable to merge @OA\Post() in \App\Http\Controllers\PostController->update() in /home/leslie/LARAVEL-PROJECTS/ACTIVE-MEDIA/letivi-api/app/Http/Controllers/PostController.php on line 193

  at vendor/zircote/swagger-php/src/Loggers/DefaultLogger.php:31
     27▕         } else {
     28▕             $error_level = E_USER_WARNING;
     29▕         }
     30▕ 
  ➜  31▕         trigger_error($message, $error_level);
     32▕     }
     33▕ }
     34▕ 

      +22 vendor frames 

  23  artisan:37
      Illuminate\Foundation\Console\Kernel::handle()

This is my api documentation

     * @OA\Post(
     * path="/api/post/edit/{id}",
     * operationId="Update Post",
     * tags={"Edit Post"},
     * summary="User Update Post",
     * description="Update Post here",
     *     @OA\RequestBody(
     *         @OA\JsonContent(),
     *         @OA\MediaType(
     *            mediaType="multipart/form-data",
     *            @OA\Schema(
     *               type="object",
     *               required={"title"},
     *               @OA\Property(property="title", type="string"),
     *            ),
     *        ),
     *    ),
     *      @OA\Response(
     *          response=201,
     *          description="Post Created  Successfully",
     *          @OA\JsonContent()
     *       ),
     *      @OA\Response(response=400, description="Bad request"),
     * )
     */```

I have been searching everywhere and cant seem to find the solution to my problem. Is there a way for me to reset the l5-swagger JSON file and then re-run the `swagger:generate` command again?
1

There are 1 best solutions below

1
H_R_Li On

how are you? I've solve this problem by only configuring 'pattern' section to config/l5-swagger.php to scan by filename (to exclude migrations, etc.):

  'defaults' => [
      'scanOptions' => [
          'pattern' => ['*Controller.php', '*Schema.php'],
      ],
      ...
    ]

Credits to: https://github.com/DarkaOnLine/L5-Swagger/issues/484#issuecomment-1198901551