php之swagger用法
之前项目中从来没有接触过swagger,对这个名词也很陌生,后来项目中使用,感觉没有很完整的文档,所以写起来对我来说还是有点费劲的,经过几个接口的书写大概知道了。swagger在线编译器swagger docOA\Request的用法/*** @OA\Get(*path="/api/check-app-version",*tags={"appVersion"},*operationId="chec
·
之前项目中从来没有接触过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条内容
所有评论(0)