spring Swagger生成API文档
2018-01-12 14:29
471 查看
package com.xyh.controller; import java.net.URL; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.client.RestTemplate; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.netflix.discovery.DiscoveryClient; import com.netflix.governator.annotations.binding.Request; import com.wordnik.swagger.annotations.Api; import com.wordnik.swagger.annotations.ApiOperation; @RestController @EnableDiscoveryClient @Api(value="city",description="城市管理") @RequestMapping(value="/city") public class cityController { @Autowired private RestTemplate restTemplate; @Value("${eureka.client.service-url.defaultZone}") private String datasourceUrl; @ApiOperation(value="获取城市列表",notes="/findbycityPage") @RequestMapping(value="/findbycityPage",method= RequestMethod.POST) public JSONObject findbycityPage(@RequestBody JSONObject json) { JSONObject res= new JSONObject(); res = this.restTemplate.postForObject(datasourceUrl+"/data/findcity",json,JSONObject.class); return res; } @ApiOperation(value="保存城市信息",notes="/saveCity") @RequestMapping(value= "/saveCity",method= RequestMethod.POST) public JSONObject saveCity(@RequestBody JSONObject json) { JSONObject res= new JSONObject(); res= this.restTemplate.postForObject(datasourceUrl+"/data/saveCity", json, JSONObject.class); return res; } @ApiOperation(value="修改城市信息",notes="/updateCity") @RequestMapping(value= "/updateCity",method= RequestMethod.POST) public JSONObject updateCity(@RequestBody JSONObject json) { JSONObject res= new JSONObject(); res= this.restTemplate.postForObject(datasourceUrl+"/data/updateCity", json, JSONObject.class); return res; } @ApiOperation(value="删除城市信息",notes="/deleteCity") @RequestMapping(value= "/deleteCity",method= RequestMethod.POST) public JSONObject deleteCity(@RequestBody JSONObject json) { JSONObject res= new JSONObject(); res= this.restTemplate.postForObject(datasourceUrl+"/data/deleteCity", json, JSONObject.class); return res; } @ApiOperation(value="根据id查找城市信息",notes="/findcityById") @RequestMapping(value= "/findcityById",method= RequestMethod.POST) public JSONObject findcityById(@RequestBody JSONObject json) { JSONObject res= new JSONObject(); res= this.restTemplate.postForObject(datasourceUrl+"/data/findcityById", json, JSONObject.class); return res; } }
相关文章推荐
- Spring Boot如何让Web API自动生成文档,并解决swagger-annotations的API注解description属性废弃的问题
- SpringBoot + mybatis + Swagger快速构建REST API并生成优美的API文档
- SpringBoot&Swagger构建REST API并生成API文档
- Swagger2 生成 Spring Boot API 文档
- Spring boot结合swagger自动生成api文档
- spring-boot整合swagger生成在线api文档
- 在Spring中使用Springfox和swagger生成restful风格的API文档
- SpringBoot:番外篇SpringBoot+Swagger生成可视图的API文档
- 使用 SpringBoot + Swagger 生成接口 API 文档
- SpringMVC+Swagger UI生成可视图的API文档(详细图解)
- spring集成swagger生成api文档的丢弃接口添加删除线效果
- SpringMVC+Swagger UI生成可视图的API文档(详细图解)
- 使用Spring Boot&Swagger快速构建REST API并生成优美的API文档
- Springboot | SpringBoot 微服务整合Swagger生成API文档
- SwaggerUI自动生成API文档(SwaggerUI+SpringBoot)
- Spring3 MVC中使用Swagger生成API文档
- 利用Swagger Maven Plugin生成Rest API文档
- ASP.NET Core WebApi使用Swagger生成api说明文档看这篇就够了
- Swagger+Spring mvc生成Restful接口文档
- swagger生成API文档