【问题标题】:L5-swagger api documentation: Getting error Required @OA\PathItem() not foundL5-swagger api 文档:获取错误需要 @OA\PathItem() 未找到
【发布时间】:2022-07-05 18:13:39
【问题描述】:

在 Stackoverflow 上阅读这 2 篇文章后: How to Solved ErrorException : Required @OA\PathItem() not found Can't generate API documentation in l5-swagger

运行 php artisan l5-swagger:generate 后,我仍然收到错误 Required @OA\PathItem() not found

这是我的 Controller.php 部分:

/**
 * @OA\Info(
 *     title="My First API Documentation",
 *     version="0.1",
 *      @OA\Contact(
 *          email="info@yeagger.com"
 *      ),
 * ),
 *  @OA\Server(
 *      description="Learning env",
 *      url="https://foo.localhost:8000/api/"
 *  ),
 */
class Controller extends BaseController
{

这是我的 ProfileController 部分:

   /**
     * @OA\Get(
     *      path="/profiles",
     *      @OA\Response(
     *          response=200,
     *          description="Successful operation",
     *      ),
     *     @OA\PathItem (
     *     ),
     * )
     */
   function index()
    {
        return new ProfileCollection(Profile::with('user')->paginate());
    }

我在这里忽略了什么? 如果有人能解释和帮助那就太好了:)

编辑 - 解决方案

出现问题是因为我使用的是 laravel 模块包,我不得不更改 l5-swagger.php 配置文件中的一些代码:

'annotations' => [
                    base_path('Modules/Api/Http'), <-- changed the base path to the correct module
                ],

然后我将主 Controller.php 从 App/Http/Controllers 复制到同一个模块,以消除之后出现的 @OA\Info() not found 错误。

【问题讨论】:

    标签: openapi


    【解决方案1】:

    根据migration documentation,您需要导入注释类use OpenApi\Annotations as OA;,这将解决您的问题。

    【讨论】:

      【解决方案2】:

      /**

      • @OA\Get(
      • path="/",
        
      • description="Home page",
        
      • @OA\Response(response="default", description="Welcome page")
        
      • ) */

      【讨论】:

        猜你喜欢
        • 2022-11-22
        • 1970-01-01
        • 1970-01-01
        • 2018-10-24
        • 2016-01-03
        • 1970-01-01
        • 2019-04-14
        • 1970-01-01
        • 2014-02-22
        相关资源
        最近更新 更多