springfox

【Swagger2】【2】SpringBoot整合Swagger2

 ̄綄美尐妖づ 提交于 2019-11-27 21:08:25
前言: 做前后端分离的项目,非常重要的一点就是写好接口文档,用Swagger可以自动同步代码里的注解内容,同时可以直接在页面请求接口。 使用过程中,也发现了一些缺点,比如不能记录上次请求接口的数据,必须先发布代码才能看到Swagger页面。所以我们已经改用YApi了,YApi的接口可以手写,也可以从Swagger导入,这个属于工具,不属于代码范畴了。不过我们依然在代码里保留了Swagger,因为注解看着挺清晰的 项目为:SpringBoot + Maven 正文: 访问地址: http://localhost:8080/swagger-ui.html 配置: pom.xml <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> <version>2.6.1</version> </dependency> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger-ui</artifactId> <version>2.6.1</version> </dependency> Swagger配置类 package com.bf; import org

Swagger2 WebFlux小试牛刀

≯℡__Kan透↙ 提交于 2019-11-27 20:45:57
序 本文主要展示一下如何使用支持WebFlux的Swagger maven <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> <version>${swagger.version}</version> </dependency> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-spring-webflux</artifactId> <version>${swagger.version}</version> </dependency> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger-ui</artifactId> <version>${swagger.version}</version> </dependency> swagger.version目前是3.0.0-SNAPSHOT,因而没有发布到maven官方仓库里头,需要从jcenter-snapshots中拉取 <repositories> <repository> <id>jcenter-snapshots</id>

Api annotation's description is deprecated

本小妞迷上赌 提交于 2019-11-27 20:40:00
问题 In Swagger, @Api annotation's description is deprecated. Is there a newer way of providing the description? 回答1: I found a solution for my Spring Boot application. Firstly, use the tags method for specify the tags definitions in your Docket : @Configuration @EnableSwagger2 public class SwaggerConfig { @Bean public Docket productApi() { return new Docket(DocumentationType.SWAGGER_2).select() .apis(RequestHandlerSelectors.basePackage("my.package")).build() .apiInfo(apiInfo()) .tags(new Tag(

springboot 整合Swagger2的使用

一笑奈何 提交于 2019-11-27 19:40:24
Swagger2相较于传统Api文档的优点 手写Api文档的几个痛点: 文档需要更新的时候,需要再次发送一份给前端,也就是文档更新交流不及时。 接口返回结果不明确 不能直接在线测试接口,通常需要使用工具,比如postman 接口文档太多,不好管理 Swagger也就是为了解决这个问题,当然也不能说Swagger就一定是完美的,当然也有缺点,最明显的就是代码移入性比较强。 可以直接使用Swagger editor编写接口文档,我们这里讲解的是SpringBoot整合Swagger2,直接生成接口文档的方式。 依赖文件 <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> <version>2.6.1</version> </dependency> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger-ui</artifactId> <version>2.6.1</version> </dependency> 配置类 package com.boss.hr.train.fishkkmybatis.config; import org.springframework

How to configure Spring Security to allow Swagger URL to be accessed without authentication

亡梦爱人 提交于 2019-11-27 16:59:41
My project has Spring Security. Main issue: Not able to access swagger URL at http://localhost:8080/api/v2/api-docs . It says Missing or invalid Authorization header. Screenshot of the browser window My pom.xml has the following entries <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> <version>2.4.0</version> </dependency> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger-ui</artifactId> <version>2.4.0</version> </dependency> SwaggerConfig : @Configuration @EnableSwagger2 public class SwaggerConfig { @Bean public Docket api() {

Remove Basic Error Controller In SpringFox SwaggerUI

孤人 提交于 2019-11-27 15:02:49
Is there a way i can remove the "basic-error-controller" from springfox swagger-ui? Picture: You can restrict the request handler selector to scan only the package of your project: return new Docket( DocumentationType.SWAGGER_2) .select() .apis( RequestHandlerSelectors.basePackage( "your package" ) ) ... It can be done using Predicates.not() . @Bean public Docket api() { return new Docket(DocumentationType.SWAGGER_2) .select() .apis(RequestHandlerSelectors.any()) .paths(PathSelectors.any()) .paths(Predicates.not(PathSelectors.regex("/error.*"))) .build(); } I think, the most elegant solution

教育

这一生的挚爱 提交于 2019-11-27 09:49:43
创建父工程guli-parent 在项目guli下创建模块:使用 Spring Initializr 快速初始化一个 Spring Boot 模块,版本:2.0.7.RELEASE 配置 pom.xml (修改版本为 :2.0.7.RELEASE <artifactId> 节点后面添加 <packaging>pom</packaging> spring-boot-starter 改成 spring-boot-starter-web) <properties> <java.version>1.8</java.version> <guli.version>0.0.1-SNAPSHOT</guli.version> <mybatis-plus.version>3.0.5</mybatis-plus.version> <velocity.version>2.0</velocity.version> <swagger.version>2.7.0</swagger.version> </properties>替换 <java.version>1.8</java.version> <dependencyManagement> <dependencies> <!--mybatis-plus 持久层--> <dependency> <groupId>com.baomidou</groupId>

Spring boot中使用Swagger2

不羁的心 提交于 2019-11-27 05:49:30
问题 最近需要做接口开发,给客户端们调用,但是我又不想写文档,听说REST风格的接口都在用Swagger做IDL(Interface description language),中文就是接口描述语言,简单的说就是给调用方的开发人员看的。具体可以看危机百科: 接口描述语言 。 Maven <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> Gradle ... ext { springfoxSwagger2Version = "2.8.0" } ... dependencies{ implementation "io.springfox:springfox-swagger2:${springfoxSwagger2Version}"

swagger-ui 系统配置过程(基于spring+springmvc+swagger+springfox配置 web-api 管理系统)

拟墨画扇 提交于 2019-11-27 05:03:32
web工程部分框架信息:spring springmvc swagger springfox maven 参考文档: https://www.cnblogs.com/exmyth/p/7183753.html https://www.cnblogs.com/arctictern/p/7498838.html https://my.oschina.net/wangmengjun/blog/907679 http://springfox.github.io/springfox/docs/current/ pom.xml 对于 swagger-ui 的依赖 <!-- https://mvnrepository.com/artifact/com.mangofactory/swagger-springmvc --> <dependency> <groupId>com.mangofactory</groupId> <artifactId>swagger-springmvc</artifactId> <version>0.9.5</version> </dependency> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> <version>2.7.0<

SpringMVC整合SpringFox实践总结

℡╲_俬逩灬. 提交于 2019-11-27 04:51:37
项目中使用的swagger框架在生成api文档时存在一些问题: 1、 控制器下方法无法点击展开 2、api内容结构混乱 基于上述原因,重新整合重构了一下api文档生成的代码。在此将重整过程记录下来,方便后续查看。 Maven依赖引入 要整合SpringFox所需的依赖如下: <!--springfox-swagger需要的最小依赖 start--> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> <version>2.6.1</version> </dependency> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger-ui</artifactId> <version>2.6.1</version> </dependency> <!--jackson用于将springfox返回的文档对象转换成JSON字符串--> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-annotations</artifactId> <version>${version