当前位置:网站首页>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());
}
边栏推荐
猜你喜欢
Find the latest staff salary and the last staff salary changes
基于微信小程序的租房小程序
Decrement operation in tf; tf.assign_sub()
The easiest trick to support quick renaming of various files
2.1-梯度下降
1003 I want to pass (20 points)
美术2.4 UV原理基础
Active users of mobile banking grew rapidly in June, hitting a half-year high
Four operations in TF
tf.cast(),reduce_min(),reduce_max()
随机推荐
TF通过feature与label生成(特征,标签)集合,tf.data.Dataset.from_tensor_slices
Pico neo3 Unity Packaging Settings
3.1-Classification-probabilistic generative model
1076 Wifi密码 (15 分)
1101 B是A的多少倍 (15 分)
Two startup methods and differences of Service
进阶-指针
场地预订系统,帮助场馆提高坪效
go sqlx 包
go-grpc TSL authentication solution transport: authentication handshake failed: x509 certificate relies on ... ...
Dynamic Agent Learning
Kaldi语音识别工具编译问题记录(踩坑记录)
4.1-支持向量机
CSDN21天学习挑战赛——封装(06)
go 操作MySQL之mysql包
8、Mip-NeRF
1003 我要通过 (20 分)
Hibernate 的 Session 缓存相关操作
【C语言】每日一题,求水仙花数,求变种水仙花数
流式结构化数据计算语言的进化与新选择