springfox

How set SpringFox to show two (or more) versions of the Rest API using Spring Boot?

馋奶兔 提交于 2019-12-08 18:30:34
I'm trying to figure out how manage two (or more) version of my API endpoints using Spring Fox. To version my APIs, I'm using the Versioning through content negotiation , also know as Versioning using Accept header . The versions of each endpoint are controlled individually using the header information. Per example, for the version one I use the attribute produces : @Override @PostMapping( produces = "application/vnd.company.v1+json") public ResponseEntity<User> createUser( For version two, I use: @Override @PostMapping( produces = "application/vnd.company.v2+json", consumes = "application/vnd

How set SpringFox to show two (or more) versions of the Rest API using Spring Boot?

偶尔善良 提交于 2019-12-08 08:28:41
问题 I'm trying to figure out how manage two (or more) version of my API endpoints using Spring Fox. To version my APIs, I'm using the Versioning through content negotiation, also know as Versioning using Accept header. The versions of each endpoint are controlled individually using the header information. Per example, for the version one I use the attribute produces : @Override @PostMapping( produces = "application/vnd.company.v1+json") public ResponseEntity<User> createUser( For version two, I

Change location to call swagger-ui in Spring

旧时模样 提交于 2019-12-08 06:26:25
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 . This is all I can did it. @Override public void addViewControllers(ViewControllerRegistry registry) {

Springfox swagger inheritance support

余生颓废 提交于 2019-12-07 13:20:33
问题 Is there any way to expose inheritance/ polymorphism in springfox swagger (2.7.0)? I know that swagger specification supports allOf. Is springfox support this? Below is sample domain model. @ApiModel public abstract class Animal{ private String name; } @ApiModel(parent=Animal.class) public class Dog extends Animal{ ... } @ApiModel(parent=Animal.class) public class Cat extends Animal{ ... } If controller returns Animal, swagger contract doesn't expose Cat or Dog. It only returns Animal with it

ssm集成(maven)& 分模块开发--详细教程

坚强是说给别人听的谎言 提交于 2019-12-06 15:02:41
1 maven版本的ssm 1.1 最简单的版本步骤: (1) 创建maven web项目 (2) 在pom.xml中导入依赖的jar包 (3) 再写配置文件: web.xml <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd" > <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0"> <display-name>crm</display-name> <!-- Spring的配置文件 --> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:applicationContext

Swagger 2 accept xml instead of json

霸气de小男生 提交于 2019-12-06 05:51:52
问题 I have a project with spring boot and I want to use swagger2 to document my json web services. I have this configuration : @Configuration @EnableSwagger2 public class Swagger2Config { @Bean public Docket welcomeMessageApi() { return new Docket(DocumentationType.SWAGGER_2) .apiInfo(apiInfo()) .select() .apis(RequestHandlerSelectors.any()) .paths(PathSelectors.any()) .build(); } private ApiInfo apiInfo() { return new ApiInfoBuilder() .title("My API") .description("Lorem Ipsum is simply dummy

[转]swagger2 入门教程

强颜欢笑 提交于 2019-12-06 05:17:01
swagger2 是一个规范和完整的框架,用于生成、描述、调用和可视化Restful风格的web服务,现在我们使用spring boot 整合它 作用: 1、接口的文档在线自动生成 2、功能测试 先介绍它的常用注解 @Api 注解可以用来标记 Controller 的功能 @ApiOperation 注解用来标记一个方法的作用 @ApilmplicitParam 注解用来描述一个参数,可以配置参数的中文含义,也可以给参数设置默认值,这样在接口测试的时候可以避免手动输入 @ApilmplicitParams 如果有多个参数,则需要使用多个 @ApilmplicitParam 注解来描述, 多个 @ApilmplicitParam 注解需要放在一个 @ApilmplicitParams 注解中 @ApiModel 如果参数是一个对象,则需要在对象所在的类上加上此注解 @ApiModelProperty 如果参数是一个对象,则需要在对应的属性上加上此注解,还需要在对象所在的类上加上 @ApiModel @ApiIgnore 注解标识此参数可以忽略 下面介绍它的使用 1、引入它的依赖 <!--写接口文档的api--> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId

SpringBoot 项目脚手架

牧云@^-^@ 提交于 2019-12-05 23:32:50
写在前面 之前也一直很少有写SpringBoot项目相关的文章,今天 准备整理一个我自己初始化SpringBoot项目时的一个脚手架,便于自己后面查阅。因为SpringBoot的约定大于配置,在整合各个组件的时候,我们仅仅写很少的代码就能 整合 跑起来。 本文,也仅仅是一个简单的整合,更多个性化配置,更多调优,这个也是自己在工作中慢慢摸索的。如果你有什么更多好的建议或者意见,也可以留言交流。谢谢~ 我们开始吧 新建SpringBoot 2.0.3.RELEASE web 项目 标题1:AOP 切面统一打印请求日志 意图:可以看到,每个对于每个请求,开始与结束一目了然,并且打印了以下参数: URL: 请求接口地址; HTTP Method: 请求的方法,是 POST, GET, 还是 DELETE 等; Class Method: 对应 Controller 的全路径以及调用的哪个方法; IP: 请求 IP 地址; Request Args: 请求入参,以 JSON 格式输出; Response Args: 响应出参,以 JSON 格式输出; Time-Consuming: 请求耗时; 步骤一:添加依赖: <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter

springboot-swagger配置

十年热恋 提交于 2019-12-05 14:48:00
原文地址 https://www.cnblogs.com/softidea/p/6251249.html https://www.cnblogs.com/xiebq/p/9181517.html 1pomjar包 <!--swagger 文档注释--> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> <version>2.7.0</version> </dependency> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger-ui</artifactId> <version>2.7.0</version> </dependency> <!--swagger--> 2配置类 package com.config; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.web.bind.annotation.RestController;

【SpringBoot | Swagger】SpringBoot整合Swagger

别等时光非礼了梦想. 提交于 2019-12-05 07:18:10
SpringBoot整合Swagger 1. 什么是Swagger Swagger 是一个规范和完整的框架,用于生成、描述、调用和可视化 RESTful 风格的 Web 服务。简单说就是项目跑起来了,你的接口可视化展现出来。 2. 怎么在SpringBoot中使用Swagger 1. 配置pom.xml 这里我们导入swagger的相关内容,并额外导入了一个开源的显示界面包,左右布局符合国人界面使用习惯 <!-- 自动生成API文档 --> <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> <!-- 开源的api接口显示界面,左右布局 --> <dependency> <groupId>com.github.caspar-chen</groupId> <artifactId