当前位置:网站首页>Swagger use
Swagger use
2022-06-30 08:14:00 【sashaSloan】
swagger Use
( Novice notes , Crazy Porter )
** This chapter is based on the optimization part of the crazy God Ruiji takeout project
swagger Use
Introduce
Use Swagger You just need to define the interface and the interface related information according to its specifications , Re pass Swagger A series of derived projects and tools , You can generate various formats of interface documents , And online interface debugging page and so on .
Official website : https:/ /swagger.io/
knife4j Is for Java MVC Framework for the integration Swagger Generate Api Document enhancement solution .
swagger Use
swagger To configure
1、 Import maven coordinate
<dependency>
<groupld>com.github.xiaoymin</groupld>
<artifactld>knife4j-spring-boot-starter</artifactld>
<version>3.0.2</version>
</dependency>
2、 Import knife4j Related configuration classes (WebMvcConfig)
stay mvc The configuration file WebMvcConfig In the open swagger and knife4j
@EnableSwagger2
@EnableKnife4j
public class WebMvcConfig extends WebMvcConfigurationSupport {
......
// Create the following two methods in the class
@Bean
public Docket createRestApi()
{
// The document type
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.select()
.apis(RequestHandlerSelectors.basePackage("com.itheima.reggie.controller"))
.paths(PathSelectors.any())
.build();
}
private ApiInfo apiInfo(){
return new ApiInfoBuilder()
.title(" Reggie takeout "). version("1.0")
. description(" Reggie takeout interface document ").build() ;
}
3、 Set up static resources ( Otherwise, the interface document page cannot be accessed )
Set static resource mapping (WebMvcConfig Class addResourceHandlers Method ), Otherwise, the interface document page cannot be accessed .
// solve swagger cannot access
registry.addResourceHandler("/swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/");
registry.addResourceHandler("/doc.html").addResourceLocations("classpath:/META-INF/resources/");
// solve swagger Of js File not accessible
registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
4、 stay LoginCheckFilter Set the request path that does not need to be processed in 
visit localhost:8080/doc.html
Here you can see the interface information and test the interface .
swagger Commonly used annotations
Add relevant annotations to classes and methods for configuration 


边栏推荐
- ACM. Hj48 delete the node with the specified value from the one-way linked list ●●
- 在浏览器输入url到页面展示出来
- Cesium learning notes (IV) visual image & Terrain
- 【JUC系列】Fork/Join框架之概览
- Bingbing learning notes: quick sorting
- Environment configuration of ROS Aubo manipulator
- Want to ask, how to choose securities companies for stock speculation? Is it safe to open an account online?
- F12 packet capture is used for the whole process analysis of postman interface test
- Sword finger offer II 075 Array relative sort (custom sort, count sort)
- Redis设计与实现(三)| 服务器与客户端的交互(事件IO模型)
猜你喜欢
![[nvme2.0b 14 - 5] commande de téléchargement / commande du logiciel](/img/98/bb250030f3e31e71d48e3be3ea4698.png)
[nvme2.0b 14 - 5] commande de téléchargement / commande du logiciel

Redis设计与实现(三)| 服务器与客户端的交互(事件IO模型)

【花雕体验】12 搭建ESP32C3之Arduino开发环境

1162 Postfix Expression

Deep learning - residual networks resnets

Deep learning - networks in networks and 1x1 convolution
![[tensorflow GPU] building of deep learning environment under windows11](/img/10/6d30d4c310e6677049a1012d47f773.png)
[tensorflow GPU] building of deep learning environment under windows11

全栈最全性能测试理论-总结

swagger使用

【NVMe2.0b 14-5】Firmware Download/Commit command
随机推荐
增强for循环的增删操作 & 迭代器删除集合元素
Bingbing learning notes: quick sorting
Experiment 3 remote control
JS code case
C. Fishingprince Plays With Array
swagger使用
Common tools installation, configuration, compilation, link, etc
AcrelEMS能效管理平台为高层小区用电安全保驾护航
Applet uses QR code plug-in
【NVMe2.0b 14】NVMe Admin Command Set
亚马逊测评术语有哪些?
Deep learning -- recurrent neural network
Opencv image
【JUC系列】Fork/Join框架之概览
Redis设计与实现(五)| Sentinel哨兵
MIME type Encyclopedia
Recurrence relation (difference equation) -- Hanoi problem
Rendering engine development
Redis设计与实现(一)| 数据结构 & 对象
Redis设计与实现(六)| 集群(分片)