在swagger-php的例子下有例子写法。拿着它分析记录。Swagger官方点评:https://bfanger.nl/swagger-explained/#schemaObjectgo1。文档标题部分/***@SWG\Swagger(*schemes={"http"},*host="api.com",*basePath="/v1",*@SWG\Info(*version="1.0.0",*title="API接口文档",*description="测试swagger文档项目",*@SWG\Contact(*name="wxp",*email="panxxxx@163.com"*)*),*@SWG\ExternalDocumentation(*description="wxp",*url="./"*)*)*/效果图:schemes:接口支持的协议(可填写多个协议)host:主机名或知识产权。basePath:提供API的基本路径,相对于宿主机。必须以前导斜杠(/)开头。基本URL由host+basePath连接而成。信息:文档描述。版本:版本号。标题:标题。description:描述信息。ExternalDocumentation”:外部文档链接。description:描述url:跳转链接contact:联系开发者并发邮件。name:开发者姓名email:邮箱地址。2.标签部分用于文档分类/***@SWG\Tag(*name="pet",*description="你的宠物信息",*@SWG\ExternalDocumentation(*description="Seemore",*url=""*)*)*@SWG\Tag(*name="store",*description="查看宠物商店订单"*)*@SWG\Tag(*name="user",*description="User操作记录",*@SWG\ExternalDocumentation(*description="AboutPetShop",*url="http://swagger.io"*)*)*/name:名称(功能模块)description:描述3.接口注释写法/***@SWG\Get(*path="/pet/{petId}",*summary="通过ID查询宠物",*description="返回宠物信息",*operationId="getPetById",*tags={"pet"},*consumes={"application/json","application/xml"},*produces={"application/xml","application/json"},*@SWG\Parameter(*description="要返回的宠物ID",*in="path",*name="petId",*required=true,*type="integer",*format="int64"*),*@SWG\回应e(*response=200,*description="成功操作",*@SWG\Schema(ref="#/definitions/Pet")*),*@SWG\Response(*response="400",*description=“提供的ID无效”*),*@SWG\Response(*response="404",*description="Petnotfound"*),*security={*{"api_key":{}}*}*)*/Get:请求的HTTP方式,支持GET/POST/PUT/DELETE等HTTP标准请求方式path:请求的路径summary:接口介绍,不超过120个字符tags:接口标签,可以bemultipledescription:接口描述,支持Markdown语法operationId:操作ID,全局唯一接口标识consumes:接口接收的MIME类型,如application/jsonproduces:接口返回的MIME类型,如application/jsonparameters:参数列表描述:参数说明in:参数来自To的地方。必需的。取值限制为:"query","header","path","formData","body"")必须为true.type=参数类型。取值限制为:"string","number"","integer","boolean","array","file"format:参数格式,如"int64"response:描述来自API操作的单个响应responsese:返回码description=Description@SWGSchema(ref="#/definitions/Pet"):引用definitions/Pet定义的对象4.定义对象5.类型为array
