当前位置:网站首页>St. Regis Takeaway Notes - Lecture 10 Swagger
St. Regis Takeaway Notes - Lecture 10 Swagger
2022-08-02 14:21:00 【Xiao Liyi】
I. Introduction
With Swagger, you only need to define interfaces and interface-related information according to its specifications, and then through a series of projects and tools derived from Swagger, you can generate interface documents in various formats, as well as online interface debugging pagesand many more.
Official website: https://swagger.io/
knife4j is an enhanced solution to generate Api documentation for Java MVC framework integration with Swagger.
Second, how to use
1. Import the maven coordinates of knife4j
com.github.xiaoymin knife4j-spring-boot-starter 3.0.2 2. Import knife4j related configuration classes (WebMvcConfig)
@[email protected]@[email protected] class WebMvcConfig extends WebMvcConfigurationSupport {@Beanpublic Docket createRestApi() {// document typereturn new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()).select().apis(RequestHandlerSelectors.basePackage("com.jf.controller")).paths(PathSelectors.any()).build();}private ApiInfo apiInfo() {return new ApiInfoBuilder().title("St. Regis Takeaway").version("1.0").description("Regi takeaway interface documentation").build();}
3. Set static resources (addResourceHandlers method in WebMvcConfig), otherwise the interface documentation page cannot be accessed
registry.addResourceHandler("doc.html").addResourceLocations("classpath:/META-INF/resources/");registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");4. Set the request path that does not need to be processed in LoginCheckFilter
"/doc.html","/webjars/**","/swagger-resources","/v2/api-docs"
Three, Swagger common annotations
| Notes | Description |
|---|---|
| @Api | Used on the requested class, such as Controller, to indicate the description of the class |
| @ApiModel | Used on a class, usually an entity class, representing a message that returns response data |
| @ApiModelProperty | Used on properties to describe the properties of the response class |
| @ApiOperation | Used in the requested method, explaining the purpose and function of the method |
| @ApilmplicitParams | Used in the method of the request, indicating a set of parameter description |
| @ApilmplicitParam | Used in the @ApilmplicitParams annotation to specify aspects of a request parameter |
边栏推荐
猜你喜欢

chapter7

第八单元 中间件
![[ROS] The difference between roscd and cd](/img/a8/a1347568170821e8f186091b93e52a.png)
[ROS] The difference between roscd and cd

浅浅写一下PPOCRLabel的使用及体验

Deep learning framework pytorch rapid development and actual combat chapter4

Briefly write about the use and experience of PPOCRLabel

Chapter6 visualization (don't want to see the version)

Unit 5 Hold Status

8581 Linear linked list inversion

window10下半自动标注
随机推荐
8580 合并链表
rpm包的卸载与安装[通俗易懂]
Unit 14 Viewsets and Routing
The 2nd China Rust Developers Conference (RustChinaConf 2021~2022) Online Conference Officially Opens Registration
The future of financial services will never stop, and the bull market will continue 2021-05-28
第十五单元 分页、过滤
[ROS](05)ROS通信 —— 节点,Nodes & Master
You can't accept 60% slump, there is no eligible for gain of 6000% in 2021-05-27
Sentinel源码(六)ParamFlowSlot热点参数限流
Unit 3 view layer
Building and getting started with the Flask framework
Unit 11 Serializers
8581 Linear linked list inversion
配置zabbix自动发现和自动注册。
run yolov5
[ROS] (06) ROS Communication - Topic Communication
Flask-SQLAlchemy
[ROS] The software package of the industrial computer does not compile
How does Apache, the world's largest open source foundation, work?
logback源码阅读(二)日志打印,自定义appender,encoder,pattern,converter