springfox

swagger使用总结

荒凉一梦 提交于 2020-01-07 15:32:14
项目中你可能已经使用到了swagger,或许你并没有对它过于留意,比如说springfox、swagger-springmvc、swagger-ui他们之间的关系是什么,springfox原理是什么。 先看一个pull下来就能启动的spring-boot,swagger-ui集成demo git项目地址 https://github.com/moxingwang/swagger.git 获取代码 git pull https://github.com/moxingwang/swagger.git 启动 cd swagger mvn spring-boot:run 访问 http://localhost:8080/sw/swagger-ui.html 自此一个非常方便又简单的swagger-ui集成好了,写完业务逻辑代码可以立马公布restful api给前端调用。 具体使用 基于springfox使用swagger非常简单,只需要maven依赖以及少量config配置就可以实现,上面的demo中都有体现,或者直接访问springfox的github上面的demo springfox/springfox-demos 。 springfox更详细配置请参考官方文档 Springfox Reference Documentation 。 swagger annotation具体使用

Spring Boot集成SpringFox Swagger的Pageable参数问题

五迷三道 提交于 2020-01-07 15:29:14
Spring Boot项目中常使用springfox-swagger来生成REST API文档,使用springfox-swagger-ui进行API测试。 <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> <version>2.8.0</version> </dependency> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger-ui</artifactId> <version>2.8.0</version> </dependency> REST API方法的参数含有org.springframework.data.domain.Pageable时,如未进行其它配置,Swagger根据接口Pageable的get/is方法生成了pageNumber、pageSize、offset、paged、unpaged、sort.sorted、sort.unsorted等参数,但实际上这些参数是无效的。 @ApiOperation(value = "Find airlines") @GetMapping(value = "/airlines") public

Swagger

故事扮演 提交于 2020-01-07 15:24:27
1.创建spring boot项目 2.导入jar <!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger-ui --> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger-ui</artifactId> <version>2.9.2</version> </dependency> <!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger2 --> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> <version>2.9.2</version> </dependency> 3.编写一个Hello 工程 4.配置swagger ==>Config @Configuration br/>@EnableSwagger2//开启swagger2 public class SwaggerConfig { } 5.测试运行: http://127.0.0.1:8080/swagger-ui.html

Swagger

非 Y 不嫁゛ 提交于 2020-01-07 15:24:06
1.创建spring boot项目 2.导入jar <!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger-ui --> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger-ui</artifactId> <version>2.9.2</version> </dependency> <!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger2 --> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> <version>2.9.2</version> </dependency> 3.编写一个Hello 工程 4.配置swagger ==>Config @Configuration br/>@EnableSwagger2//开启swagger2 public class SwaggerConfig { } 5.测试运行: http://127.0.0.1:8080/swagger-ui.html

springboot集成swagger

懵懂的女人 提交于 2020-01-07 12:36:39
  Swagger 是一个规范和完整的框架,用于生成、描述、调用和可视化 RESTful 风格的 Web 服务。总体目标是使客户端和文件系统作为服务器以同样的速度来更新。 作用: 接口的文档在线自动生成。 功能测试。 1、配置pom.xml <!-- swagger --> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> <version>2.9.2</version> </dependency> <!-- swagger-ui --> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger-ui</artifactId> <version>2.9.2</version> </dependency> <!-- jackson相关依赖 --> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> <version>2.5.4</version> </dependency> <dependency> <groupId

swagger 使用docker启动swagger服务

六月ゝ 毕业季﹏ 提交于 2019-12-30 11:40:34
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 一、引入jar包 implementation("io.springfox:springfox-swagger2") 二、获取swagger的json文件 项目启动时,访问 /v2/api-docs 此时会获得swagger.json 三、使用docker-compose启动swagger镜像 version: "2" services: swagger: image: swaggerapi/swagger-ui environment: - SWAGGER_JSON=/swagger/api.json volumes: - ./swagger:/swagger ports: - 17888:8080 这里的environment里面关于swagger_json的location指向第二步存储的json文件。 docker-compose up -d 来源: oschina 链接: https://my.oschina.net/edisonOnCall/blog/3150670

Added Springfox Swagger-UI and it's not working, what am I missing?

巧了我就是萌 提交于 2019-12-30 10:16:04
问题 Following the instructions here: http://www.baeldung.com/swagger-2-documentation-for-spring-rest-api I added these dependencies to my project: compile "io.springfox:springfox-swagger2:2.7.0" compile "io.springfox:springfox-swagger-ui:2.7.0" and configured SpringFox Swagger like this: import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import springfox.documentation.builders.PathSelectors; import springfox.documentation.builders

swagger date field vs date-time field

丶灬走出姿态 提交于 2019-12-30 03:21:10
问题 I am using swagger to test my rest api, one of the property of my entity class is a date field for which I need the date in yyyy-mm-dd format , but swagger model schema is showing this field as date-time instead of date field, therefore it gives date with time and zone. How can I convert this date-time into date field ? I have a java entity class TimeEntry.java one of its property is Date, it looks like this. @ApiModelProperty(required = true) @JsonFormat(pattern = DATE_FORMAT) private Date

SpringBoot整合swagger

只愿长相守 提交于 2019-12-28 19:44:32
Swagger使用 Swagger有什么用? swagger是一个流行的API开发框架,这个框架以“开放API声明”(OpenAPI Specification,OAS)为基础, 对整个API的开发周期都提供了相应的解决方案,是一个非常庞大的项目(包括设计、编码和测试,几乎支持所有语言)。 Swagger 是一个规范和完整的框架,用于生成、描述、调用和可视化 RESTful 风格的 Web 服务。 总体目标是使客户端和文件系统作为服务器以同样的速度来更新。 文件的方法,参数和模型紧密集成到服务器端的代码,允许API来始终保持同步。Swagger 让部署管理和使用功能强大的API从未如此简单。 springfox大致原理: springfox的大致原理就是,在项目启动的过种中,spring上下文在初始化的过程, 框架自动跟据配置加载一些swagger相关的bean到当前的上下文中,并自动扫描系统中可能需要生成api文档那些类, 并生成相应的信息缓存起来。如果项目MVC控制层用的是springMvc那么会自动扫描所有Controller类,并生成对应的文档描述数据. 该数据是json格式,通过路径:项目地址/ v2/api-docs可以访问到该数据,然后swaggerUI根据这份数据生成相应的文档描述界面。 因为我们能拿到这份数据,所以我们也可以生成自己的页面. SpringBoot

Swagger配置使用

坚强是说给别人听的谎言 提交于 2019-12-27 09:36:04
依赖: <!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger2 --> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> <version>2.9.2</version> </dependency> <!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger-ui --> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger-ui</artifactId> <version>2.9.2</version> </dependency> 配置: @EnableSwagger2 @Configuration public class MySwaggerConfiguration { @Bean public Docket createRestApi() { return new Docket(DocumentationType.SWAGGER_2) .apiInfo(apiInfo())