php 使用 swagger 自动生成 API 文档

使用 swagger 自动生成 API 文档

使用 swagger 自动生成 API 文档,有需要的朋友可以参考下。

一、下载 swagger-ui 直接上传服务器

二、下载 swagger-php 根据文档进行安装

三、PHP文件添加注释代码

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

/**

* @SWG/Resource (

* apiVersion = "版本号",

* basePath = "API地址",

* resourcePath ="项目名称",

* @SWG/Api (

* path = "API文件名",

* description = "功能描述",

* @SWG/Operation (

* method="POST", summary="操作描述", nickname = "显示名",

* @SWG/Parameter (name="参数名", description="参数说明", required = true, paramType = "query", type="string"),

* @SWG/ResponseMessage (code=200, message="返回说明")

* )

* )

*)

*/

四、使用swager-php 生成JSON地址

php ../composer/vendor/zircote/swagger-php/swagger.phar /apifolder -o /docfolder

五、修改swagger-ui 默认数据地址

六、Done

猜你喜欢

转载自blog.csdn.net/echo_hello_world/article/details/83115336