《swagger配置使用说明》由会员分享,可在线阅读,更多相关《swagger配置使用说明(4页珍藏版)》请在金锄头文库上搜索。
1、 swagger 配置使用说明1、系统使用 swagger-springmvc 0.6.6 版本,后续版本系统 spring 无法支持。2、相关 pom 配置com.mangofactoryswagger-springmvc0.6.6servlet-apijavax.servletspring-webmvcorg.springframeworkspring-weborg.springframeworkorg.springframeworkspring-core3.1.0.RELEASEorg.springframeworkspring-beans3.1.0.RELEASE3、系统配置文件a、
2、, 设置系统根路径和 API 版本app_swagger.propertiesb、wf-app-swagger.xml 设置需要查看的 URI /app/./appserver/./user/txt/demo/.为通配符,支持子路径模糊匹配4、类上加 API 注解对 contorller 类添加 API 注解类的头部添加API 注解类的方法上添加ApiOperation 注解Api(value = 用户, description = 有关于用户的CURD操作 ) ControllerRequestMapping(/user)public class TestController Respons
3、eBodyRequestMapping(value = /addUser, method = RequestMethod.GET, produces = application/json; charset=utf-8)ApiOperation(value = addUser, notes = This can only be done by the logged in user. ,responseClass=String.class)public String addUser(ApiParam(required = true, name = postData, value = 用户信息jso
4、n 数据 ) RequestParam(value = postData) String postData, HttpServletRequest request)throws JSONExceptionJSONObject json = new JSONObject();json.put(postData, postData);return json.toString();. . API 表示一个开放的 API,可以通过 description 简要描述该 API 的功能。 在一个API 下,可有多个ApiOperation,表示针对该 API 的 CRUD 操作。在 ApiOperation Annotation 中可以通过 value,notes 描述该操作的作用,response 描述正常情况下该请求的返回对象类型。 ApiParam 用于描述该 API 操作接受的参数类型