admin 管理员组

文章数量: 1184232


2024年3月13日发(作者:健康管理系统)

swagger配置使用说明

1、系统使用swagger-springmvc0.6.6版本,后续版本系统spring无法支持。

2、相关pom配置

actory

swagger-springmvc

0.6.6

servlet-api

t

spring-webmvc

framework

spring-web

framework

framework

spring-core

E

framework

spring-beans

E

3、系统配置文件

a、

b、

app_ties

,设置系统根路径和API版本

设置需要查看的URI

"swaggerArrowUri"

value-type=

""

>

/app/..

/appserver/..

list-class=

"ist"

/user

/txt/demo

/..为通配符,支持子路径模糊匹配

4、类上加API注解

对contorller类添加API注解

类的头部添加@API注解

类的方法上添加@ApiOperation注解

@Api(value="用户",description="有关于用户的CURD操作")

@Controller

@RequestMapping("/user")

publicclassTestController{

@ResponseBody

@RequestMapping(value="/addUser",method=RequestMethod.

GET

,produces

="application/json;charset=utf-8")

@ApiOperation(value="addUser",notes="Thiscanonlybedonebythe

loggedinuser.",responseClass="")

publicStringaddUser(@ApiParam(required=true,name="postData",

value="用户信息json数据")@RequestParam(

value="postData")StringpostData,HttpServletRequest

request)throwsJSONException

{

JSONObjectjson=newJSONObject();

("postData",postData);

ng();

}

......}

@API表示一个开放的API,可以通过description简要描述该API的功能。

在一个@API下,可有多个@ApiOperation,表示针对该API的CRUD操作。

在ApiOperationAnnotation中可以通过value,notes描述该操作的作

用,response描述正常情况下该请求的返回对象类型。

@ApiParam用于描述该API操作接受的参数类型


本文标签: 系统 版本 描述 操作