[FAQ] swagger-php @OA\JsonContent 与 @MediaType @OA\Schema 的用法

通过llama.cpp与羊驼聊天的网页界面- 详解 Serge 的启动使用

 

@OA\JsonContent 是对 @MediaType @OA\Schema 两者的封装,类似于 laravel 中 JsonResponse 对 Response 的封装。

@OA\JsonContent 例子:

     *      @OA\Response(
     *          response=200,
     *          description="failure data",
     *          @OA\JsonContent(
     *              type="object",
     *              @OA\Property(property="data", default=""),
     *              @OA\Property(property="message", type="string", default="xx not correct"),
     *              @OA\Property(property="code", type="integer", default=-1)
     *         )
     *      ),

 @MediaType 和 @OA\Schema 例子:

     *      @OA\Response(
     *          response=200,
     *          description="success data",
     *          @OA\MediaType(
     *              mediaType="application/json",
     *              @OA\Schema(
     *                  @OA\Property(property="data", type="object",
     *                      @OA\Property(property="token", type="string")
     *                  ),
     *                  @OA\Property(property="message", default="success"),
     *                  @OA\Property(property="code", type="integer")
     *              )
     *          )
     *      ),

 

Doc:https://zircote.github.io/swagger-php/Getting-started.html#shortcuts

Link:https://www.cnblogs.com/farwish/p/14015753.html

posted on 2020-11-21 18:09  ercom  阅读(916)  评论(0编辑  收藏  举报