当前位置:网站首页>Swagger简单使用
Swagger简单使用
2022-08-11 07:42:00 【风铃峰顶】
Swagger的Controller可以写@Api(tags = “导航名”),会显示在Swagger网页左侧导航里,下拉可以看到里面的接口。@ApiOperation(“接口名”)。
@ApiVersion({版本号,版本号})。在Swagger网页左侧上面搜索栏里可以搜索版本号。
@Configuration
@EnableSwagger2WebMvc
public class DocConfig implements InitializingBean {
private final OpenApiExtensionResolver openApiExtensionResolver;
@Autowired
private ApplicationContext applicationContext;
@Autowired
public DocConfig(OpenApiExtensionResolver openApiExtensionResolver) {
this.openApiExtensionResolver = openApiExtensionResolver;
}
@Bean
public Docket createBusinessRestApi() {
String groupName = "";
ApiInfo businessApiInfo = new ApiInfoBuilder()
.title(groupName)
.description("")
.contact(new Contact("", "", ""))
.version("1.0")
.build();
return new Docket(DocumentationType.SWAGGER_2)
.groupName(groupName)
.apiInfo(businessApiInfo)
// 设置统一参数,如Header中的参数
.globalOperationParameters(params())
.select()
.apis(RequestHandlerSelectors.basePackage(""))
.paths(PathSelectors.any())
.build()
.extensions(openApiExtensionResolver.buildExtensions(groupName));
}
private List<Parameter> params() {
ParameterBuilder tokenParam = new ParameterBuilder();
tokenParam.name("token").description("Token")
.modelRef(new ModelRef("string")).parameterType("header").required(false).build();
}
return Lists.newArrayList(tokenParam.build());
}
边栏推荐
- Mysql JSON对象和JSON数组查询
- 1101 How many times B is A (15 points)
- Hibernate 的 Session 缓存相关操作
- Do you know the basic process and use case design method of interface testing?
- 机器学习总结(二)
- go sqlx 包
- Dynamic Agent Learning
- 记录一些遇见的bug——Lombok和Mapstruct的冲突导致,A component required a bean of type ‘com.XXX.controller.converter.
- Find the latest staff salary and the last staff salary changes
- My creative anniversary丨Thank you for being with you for these 365 days, not forgetting the original intention, and each is wonderful
猜你喜欢
1003 I want to pass (20 points)
关于Excel实现分组求和最全文档
The most complete documentation on Excel's implementation of grouped summation
1101 B是A的多少倍 (15 分)
1081 检查密码 (15 分)
JUC并发编程
Interaction of Pico neo3 in Unity
The easiest trick to support quick renaming of various files
分布式锁-Redission - 缓存一致性解决
【TA-霜狼_may-《百人计划》】图形3.7.2 command buffer简
随机推荐
1003 I want to pass (20 points)
pyqt5实现仪表盘
Distributed Lock-Redission - Cache Consistency Solution
1096 大美数 (15 分)
Service的两种启动方式与区别
Activity的四种状态
4.1 - Support Vector Machines
Do you know the basic process and use case design method of interface testing?
1046 划拳 (15 分)
1076 Wifi密码 (15 分)
记录一些遇见的bug——Lombok和Mapstruct的冲突导致,A component required a bean of type ‘com.XXX.controller.converter.
查询跟踪快递单号物流,智能分析物流中转有延误的单号
JRS303-Data Verification
Write a resume like this, easy to get the interviewer
【43. 字符串相乘】
tf.cast(), reduce_min(), reduce_max()
2021-08-11 for循环结合多线程异步查询并收集结果
Keep track of your monthly income and expenses through bookkeeping
There may be fields that cannot be serialized in the abnormal object of cdc and sqlserver. Is there anyone who can understand it? Help me to answer
1091 N-自守数 (15 分)