如何在swagger-ui.html之前添加默认参数
赞:
http://localhost:8080/api/swagger-ui.html
到目前为止,我已经集成了什么
Pom.xml:
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.9.2</version>
</dependency>
SwaggerConfig.java:
@Configuration
@EnableSwagger2
public class SwaggerConfig {
@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.any())
.paths(PathSelectors.any())
.build();
}
}
Do I have to map "swagger-ui.html" to something with @RequestMapping?
答案 0 :(得分:0)
尝试一下:
new Docket(DocumentationType.SWAGGER_2)
.host("www.mydomain.com")
.pathProvider(new RelativePathProvider(servletContext) {
@Override
public String getApplicationBasePath() {
return "/myapi";
}
});
答案 1 :(得分:0)
在SwaggerConfig.java中的类级别包含以下注释:
@PropertySource(“ classpath:swagger.properties”)和 @ComponentScan
然后在资源目录(与application.properties文件相同的位置)中创建swagger.properties文件