当前位置:网站首页>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());
}
边栏推荐
- excel 透视表 值显示内容 不显示计数
- leetcode: 69. Square root of x
- 4.1ROS运行管理/launch文件
- 动态代理学习
- Analysys and the Alliance of Small and Medium Banks jointly released the Hainan Digital Economy Index, so stay tuned!
- 机器学习(三)多项式回归
- tf.cast(),reduce_min(),reduce_max()
- tf.reduce_mean()与tf.reduce_sum()
- 1056 组合数的和 (15 分)
- 通过记账,了解当月收支情况
猜你喜欢
Redis source code: how to view the Redis source code, the order of viewing the Redis source code, the sequence of the source code from the external data structure of Redis to the internal data structu
TF generates (feature, label) set through feature and label, tf.data.Dataset.from_tensor_slices
TF中的条件语句;where()
go-grpc TSL authentication solution transport: authentication handshake failed: x509 certificate relies on ... ...
Distributed Lock-Redission - Cache Consistency Solution
tf.cast(),reduce_min(),reduce_max()
1096 big beautiful numbers (15 points)
1051 复数乘法 (15 分)
1036 Programming with Obama (15 points)
1.2 - error sources
随机推荐
1.2-误差来源
初级软件测试工程师笔试试题,你知道答案吗?
Serverless + domain name can also build a personal blog? Really, and soon
1051 Multiplication of Complex Numbers (15 points)
cdc连sqlserver异常对象可能有无法序列化的字段 有没有大佬看得懂的 帮忙解答一下
2.1-梯度下降
1003 I want to pass (20 points)
2021-08-11 For loop combined with multi-threaded asynchronous query and collect results
Service的两种状态形式
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
3.1-分类-概率生成模型
1091 N-自守数 (15 分)
1081 检查密码 (15 分)
项目1-PM2.5预测
机器学习(三)多项式回归
1056 组合数的和 (15 分)
选择收银系统主要看哪些方面?
Decrement operation in tf; tf.assign_sub()
测试用例很难?有手就行
1076 Wifi Password (15 points)