如何在 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?
试试这个:
new Docket(DocumentationType.SWAGGER_2)
.host("www.mydomain.com")
.pathProvider(new RelativePathProvider(servletContext) {
@Override
public String getApplicationBasePath() {
return "/myapi";
}
});
如果您遇到任何问题:https://github.com/springfox/springfox/issues/1443
在 SwaggerConfig.java 中包含以下类级别的注释:
@PropertySource("classpath:swagger.properties"( 和 @ComponentScan
然后在资源目录中创建 swagger.properties 文件(与 application.properties 文件的位置相同(