重置Laravel中的L5-swagger API文档

uqzxnwby  于 2023-04-07  发布在  其他
关注(0)|答案(1)|浏览(113)

我一直在使用swagger生成API文档很长一段时间,但突然我开始得到这个错误消息,每当我运行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()

这是我的API文档

* @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?
acruukt9

acruukt91#

你好吗?我已经解决了这个问题,只配置'pattern'部分到config/l5-swagger.php来按文件名扫描(排除迁移等):

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

图片来源:https://github.com/DarkaOnLine/L5-Swagger/issues/484#issuecomment-1198901551

相关问题