嗨,我的 spring mvc 项目中有几个 REST api,我想为每个服务创建文档并将其存储在文件中,以便与团队共享。我经常阅读 Swagger 或 Springfox 并对其进行配置,我补充说
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.2.2</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.7.0-rc1</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.1.2</version>
</dependency>
和配置类:
package com.config.core;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
import static springfox.documentation.builders.PathSelectors.*;
@Configuration
@EnableSwagger2
public class SwaggerConfig {
@Bean
public Docket api(){
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.any())
.paths(regex("/api/.*"))
.build()
.apiInfo(apiInfo());
}
private ApiInfo apiInfo() {
ApiInfo apiInfo = new ApiInfo(
"My Project's REST API",
"1.0",
"This is a description of your API.",
"API TOS",
"me@wherever.com",
"API License",
"API License URL"
);
return apiInfo;
}
}
但 swagger-ui.html 不存在,我有:
> /v2/api-docs
> /configuration/security
> /configuration/ui
> /swagger-resources
那么,如何查看我的 Web 服务器文档并将其保存在文件中?当用户必须使用网络平台时,我想避免在 url 上显示。谢谢