springfox

swagger-ui集成

柔情痞子 提交于 2019-12-11 04:02:53
swagger-ui集成 相信无论是前端还是后端开发,都或多或少地被接口文档折磨过。前端经常抱怨后端给的接口文档与实际情况不一致。后端又觉得编写及维护接口文档会耗费不少精力,经常来不及更新。其实无论是前端调用后端,还是后端调用后端,都期望有一个好的接口文档。但是这个接口文档对于程序员来说,就跟注释一样,经常会抱怨别人写的代码没有写注释,然而自己写起代码起来,最讨厌的,也是写注释。所以仅仅只通过强制来规范大家是不够的,随着时间推移,版本迭代,接口文档往往很容易就跟不上代码了。 swagger简介 Swagger是一款RESTFUL接口的文档在线自动生成+功能测试功能软件。Swagger是一个规范和完整的框架,用于生成、描述、调用和可视化RESTfu风格的web服务。目标是使客户端和文件系统作为服务器一同样的速度来更新文件的方法,参数和模型紧密集成到服务器。这个解释简单点来讲就是说,swagger是一款可以根据restful风格生成的接口开发文档,并且支持做测试的一款中间软件。 swagger-ui集成步骤 (在一个现有的springboot项目中集成测试的,不要在意包路径以及类的名称) 1、集成swagger相关依赖 < ! -- swagger - api 依赖开始 -- > < dependency > < groupId > io . springfox < / groupId

Swagger dependency not recognized by maven

蓝咒 提交于 2019-12-11 01:59:35
问题 i'm trying to add springfox/swagger to my spring boot app, however when added to pom file, versions of dependencies are not recognized by maven. Unfortunatley i couldn't find the reason behind it. Here fragment of my pom file: <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> <version>2.9.2</version> </dependency> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger-ui</artifactId> <version>2.0.2</version> </dependency> Versions are

how to do friendly base url for swagger 2.8.0

送分小仙女□ 提交于 2019-12-10 16:29:16
问题 I'm trying to change base access url for API documentation. The url is "http://localhost:8080/swagger-ui.html". I want to get something like "http://localhost:8080/myapi/swagger-ui.html". I use Springfox 2.8.0 Swagger, Java 8, Spring Boot 2.0 The swagger configuration is: @Configuration @EnableSwagger2 public class SwaggerConfiguration { @Bean public Docket api(ServletContext servletContext) { return new Docket(DocumentationType.SWAGGER_2) .pathProvider(new RelativePathProvider(servletContext

How do do slice testing in Spring Boot 1.4 using @DataJpaTest with SpringFox @EnableSwagger2

不问归期 提交于 2019-12-10 15:06:10
问题 Re: https://spring.io/blog/2016/04/15/testing-improvements-in-spring-boot-1-4 I tried the @DataJpaTest to test my repository but my application is using Springfox, so with Springfox @EnableSwagger2 the test execution will fail with the following error: java.lang.IllegalStateException: Failed to load ApplicationContext ... Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'documentationPluginsBootstrapper' defined ... Caused by: org

Render html in springfox-swagger-ui

筅森魡賤 提交于 2019-12-10 13:55:55
问题 I recently updated an application running springfox-swagger2 and springfox-swagger-ui 2.5.0 to use version 2.6.0. The application's API documentation uses <li> , <b> and <br> tags, which were rendered correctly with 2.5.0, but with version 2.6.0 the <li> and <br> tags are ignored by the swagger-ui. What do I have to do to make springfox render the HTML tags again? The tags are used at the following positions: ApiInfoBuilder().description("HERE") @ApiOperation(notes="HERE") @ApiResponse

Swagger API Tag Description Not Coming

你离开我真会死。 提交于 2019-12-10 11:57:39
问题 I am using below swagger maven depedepncy. <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> <version>2.8.0</version> <scope>compile</scope> </dependency> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger-ui</artifactId> <version>2.8.0</version> <scope>compile</scope> </dependency> Config public Docket productApi() { return new Docket(DocumentationType.SWAGGER_2) .select() .apis(RequestHandlerSelectors.basePackage("com.it"))

Change location to call swagger-ui in Spring

两盒软妹~` 提交于 2019-12-10 11:44:34
问题 How I can change location to call swagger api docs from http://localhost:8081/swagger-ui.html to http://localhost:8081/my-api-doc ? My SwaggerConfig is @Configuration @EnableSwagger2 public class SwaggerConfig { @Bean public Docket api() { return new Docket(DocumentationType.SWAGGER_2) .select() .apis(RequestHandlerSelectors.basePackage("com.package")) .paths(PathSelectors.any()) .build() .apiInfo(apiInfo()); } And I use springfox-swagger2 and springfox-swagger-ui both with version 2.7.0 .

使用Spring MVC开发RESTful API(续)

陌路散爱 提交于 2019-12-10 04:06:06
使用多线程提高REST服务性能 异步处理REST服务,提高服务器吞吐量 使用Runnable异步处理Rest服务 AsyncController.java @RestController @GetMapping("/async") public class AsyncController { private Logger logger = LoggerFactory.getLogger(getClass()); @RequestMapping("/order") public Callable<String> order() throws Exception { logger.info("主线程开始"); Callable<String> result = new Callable<String>() { @Override public String call() throws Exception { logger.info("副线程开始"); Thread.sleep(2000); // 模拟处理下单消耗的时间 logger.info("副线程结束"); return "success"; } }; logger.info("主线程结束"); return result; } } 使用DeferredResult异步处理Rest服务 应用1/线程1:接收下单请求,放到消息队列

SrpingCloud 九、Springboot 整合 Swagger2 及 SrpingCloud Zuul 网关整合 Swagger2 (API 接口文档管理)

夙愿已清 提交于 2019-12-09 14:34:54
一、Swagger 是什么,有什么用? 1、Swagger 是什么? Swagger 是生成文档的工具,随着微服务架构体系的发展和应用, 为了前后端能够更好的集成与对接,同时为了项目的方便交付,每个项目都需要提供相应的API文档。 2、传统的API文档编写存在以下几个痛点 1、对API文档进行更新的时候,需要通知前端开发人员,导致文档更新交流不及时; 2、API接口返回信息不明确,大公司中肯定会有专门文档服务器对接口文档进行更新。 3、缺乏在线接口测试,通常需要使用相应的API测试工具,比如postman、SoapUI等 4、接口文档太多,不便于管理 5、为了解决传统API接口文档维护的问题,为了方便进行测试后台Restful接口并实现动态的更新,因而引入Swagger接口工具。 3、Swagger 优点 1.功能丰富:支持多种注解,自动生成接口文档界面,支持在界面测试API接口功能; 2.及时更新:开发过程中花一点写注释的时间,就可以及时的更新API文档,省心省力; 3.整合简单:通过添加pom依赖和简单配置,内嵌于应用中就可同时发布API接口文档界面,不需要部署独立服务。 二、Springboot 整合 Swagger2 1、maven 依赖 < ! -- SpringBoot整合 swagger -- > < dependency > < groupId > io .

SpringFox not finding jax-rs endpoints

空扰寡人 提交于 2019-12-09 12:48:29
问题 After solving Using Springfox to document jax-rs services in a Spring app, I now find that SpringFox's JSON reply doesn't show any APIs: { "swagger": "2.0", "info": { "description": "Some description", "version": "1.0", "title": "My awesome API", "contact": { "name": "my-email@domain.org" }, "license": {} }, "host": "localhost:9090", "basePath": "/myapp" } Here's springfox-servlet.xml: <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema