php之swagger用法

之前项目中从来没有接触过swagger,对这个名词也很陌生,后来项目中使用,感觉没有很完整的文档,所以写起来对我来说还是有点费劲的,经过几个接口的书写大概知道了。
swagger在线编译器
swagger doc
swagger-laravel-l5 github
在这里插入图片描述

OA\Request的用法
在这里插入图片描述

/**
     * @OA\Get(
     *     path="/api/check-app-version",
     *     tags={"appVersion"},
     *     operationId="checked",
     *     @OA\Parameter(
     *         name="channel_name",
     *         in="query",
     *         required=true,
     *         @OA\Schema(
     *             type="string",
     *         )
     *     ),
     *     @OA\Parameter(
     *         name="version",
     *         in="query",
     *         required=true,
     *         @OA\Schema(
     *             type="integer",
     *         )
     *     ),
     * @OA\Post(
     *     path="/admin/file-import",
     *     tags={"appVersion"},
     *     operationId="updated",
     *     @OA\RequestBody(
     *         description="Import App Version Template",
     *         @OA\MediaType(
     *             mediaType="multipart/form-data",
     *             @OA\Schema(
     *                 type="object",
     *                 required={"file"},
     *                 @OA\Property(
     *                     description="enter file",
     *                     type="file",
     *                     property="file",
     *                 ),
     *             )
     *         )
     *     ),
     */

文件类型的上传用法
在这里插入图片描述

    /**
     * Import App Version Template.
     * @OA\Post(
     *     path="/admin/file-import",
     *     tags={"appVersion"},
     *     operationId="updated",
     *     @OA\RequestBody(
     *         description="Import App Version Template",
     *         @OA\MediaType(
     *             mediaType="multipart/form-data",
     *             @OA\Schema(
     *                 type="object",
     *                 required={"file"},
     *                 @OA\Property(
     *                     description="enter file",
     *                     type="file",
     *                     property="file",
     *                 ),
     *             )
     *         )
     *     ),
     */

OA\Response的3种用法

response包含注释返回
在这里插入图片描述
在这里插入图片描述

  /*     @OA\Response(
  *         response=204,
  *         description="Success",
  *         @OA\MediaType(
  *             mediaType="application/json",
  *           @OA\Schema(
  *             @OA\Property(property="data", type="object"),
  *             @OA\Property(property="token", type="string")
  *             ),
  *         ),
  *     ),
  *     @OA\Response(
  *         response=200,
  *         description="Success",
  *         @OA\JsonContent(
  *             type="object",
  *           @OA\Property(property="channel_name", type="string",description="channel_name"),
  *           @OA\Property(property="download_url", type="string",description="download_url"),
  *           @OA\Property(property="is_force", type="integer",description="is_force"),
  *           @OA\Property(property="force_version", type="integer",description="force_version"),
  *         ),
  *     ),
  *     @OA\Response(
  *         response=400,
  *         description="Bad Request"
  *     ),
  * )
  */
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值