当前位置:网站首页>Swagger document configuration
Swagger document configuration
2022-07-03 08:18:00 【Children haha】
swagger:
swagger Is a specification and complete framework , Can generate , describe , Invocation and visualization RESTful Style Web service .
springboot Integrate swagger
Add dependency
There are two patterns , One is swagger-ui.html, One is doc.html( Take according to your own requirements )
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version>
</dependency>
<!--swagger-ui.html Pattern -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.9.2</version>
</dependency>
<!--doc.html Pattern -->
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>swagger-bootstrap-ui</artifactId>
<version>1.9.2</version>
</dependency>establish swagger Configuration class :
package com.yan.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
@Configuration // tell springboot You need to load this configuration class
@EnableSwagger2 // Enable swagger
public class SwaggerConfig {
@Bean
public Docket createRestApi() {
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
// adopt select Return an instance , Used to control which interfaces are exposed to swagger To show .
.select()
// For all api monitor
.apis(RequestHandlerSelectors.any())
.paths(PathSelectors.any())
.build();
}
// establish api Basic information of ,( This information will be displayed in the document , such as title Describe something like that )
public ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("spring-web project ")
.description(" Description of the project ").build();
}
}
verification :
After the project starts , You can visit localhost:8080/swagger-ui.html perhaps localhost:8080/doc.html Came to visit. .( Choose according to your dependence on import )
Some notes :
Controller layer
Define the interface name :@Api(tags="xxx")
Define method name :@ApiOperation(value="xxx")
Definition param Attributes of parameters :@ApiImplicitParam(name = "xx", value = "xx", paramType = "xx")
Such as : @ApiImplicitParam(name = "pid", value = " product id", paramType = "String")
Entity
Define object name :@ApiModel("xxx")
Define the parameter name :@ApiModelProperty(value = "xxx")边栏推荐
- Golang time format sorting
- Conversion between JSON and object
- Minimap plug-in
- Free use until 2015 -- viz artist multi touch plug-in package
- Idea dereference display effect
- Golang的range
- Kwai 20200412 recruitment
- Un système de gestion de centre commercial pour la conception de cours de technologie d'application de base de données
- the installer has encountered an unexpected error installing this package
- 方正锐利重磅升级到12.0版本,包装印前处理更加便捷、高效!
猜你喜欢

Oracle insert single quotation mark

WPF:解决MaterialDesign:DialogHost 无法关闭问题

Multi traveling salesman problem -- overview of formula and solution process

C language - Introduction - essence Edition - take you into programming (I)

the installer has encountered an unexpected error installing this package

简易入手《SOM神经网络》的本质与原理

Redis data structure

一条通往服务器所有端口的隧道

Basic operation and process control
![[end of 2021] National Meteorological Short Video (Kwai, Tiktok) influence list in December](/img/51/81ceaf8746ec7455ea8abf9f038e81.jpg)
[end of 2021] National Meteorological Short Video (Kwai, Tiktok) influence list in December
随机推荐
Transfinite hacker cognition
Scite change background color
【更新中】微信小程序学习笔记_3
十六进制编码简介
jupyter远程服务器配置以及服务器开机自启
String class
Oracle insert single quotation mark
About Wireshark's unsuccessful installation of npcap
Product creation and commercial realization of chat robot (according to La Ma Bang - Dr. Wang Jingjing - speech)
L'installateur a été installé avec une erreur inattendue
[global product discovery 2] the first pure cloud augmented reality (AR) platform - Israel
Unity4.3.1 engine source code compilation process
Basic operation and process control
Map的实现类的顺序性
Luaframwrok handles resource updates
A tunnel to all ports of the server
oracle中的 (+)是什么意思
MaxCompute字符串分割函数-SPLIT_PART
My touch screen production "brief history" 2
Use of ue5 QRcode plug-in