[FAQ] swagger-php @OAJsonContent 与 @MediaType @OASchema 的用法

@OAJsonContent 是对 @MediaType @OASchema 两者的封装,类似于 laravel 中 JsonResponse 对 Response 的封装。

@OAJsonContent 例子:

     *      @OAResponse(
     *          response=200,
     *          description="failure data",
     *          @OAJsonContent(
     *              type="object",
     *              @OAProperty(property="data", default=""),
     *              @OAProperty(property="message", type="string", default="xx not correct"),
     *              @OAProperty(property="code", type="integer", default=-1)
     *         )
     *      ),

 @MediaType 和 @OASchema 例子:

     *      @OAResponse(
     *          response=200,
     *          description="success data",
     *          @OAMediaType(
     *              mediaType="application/json",
     *              @OASchema(
     *                  @OAProperty(property="data", type="object",
     *                      @OAProperty(property="token", type="string")
     *                  ),
     *                  @OAProperty(property="message", default="success"),
     *                  @OAProperty(property="code", type="integer")
     *              )
     *          )
     *      ),

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

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

原文地址:https://www.cnblogs.com/farwish/p/14015753.html