Spring 如何将Zuul与招摇结合起来
在我的微服务项目中,我遇到了一个问题,那就是如何生成招摇过市的文档。当我添加zuul定制路线时,大摇大摆的文档变得不一致 示例:Spring 如何将Zuul与招摇结合起来,spring,swagger,netflix-zuul,Spring,Swagger,Netflix Zuul,在我的微服务项目中,我遇到了一个问题,那就是如何生成招摇过市的文档。当我添加zuul定制路线时,大摇大摆的文档变得不一致 示例: RestController: 祖尔路线: 招摇过市配置 我需要的:大摇大摆的UI显示/条形图端点 我得到的:Swagger UI显示/foo端点(这对于前端开发人员来说是无用的,因为他们在运行时使用Swagger生成组件) 那么,有什么解决方案可以配置swagger或zuul来避免这个问题吗?我们必须在application.yml文件中添加zuul配置 # c
- 我需要的:大摇大摆的UI显示/条形图端点
- 我得到的:Swagger UI显示/foo端点(这对于前端开发人员来说是无用的,因为他们在运行时使用Swagger生成组件)
那么,有什么解决方案可以配置swagger或zuul来避免这个问题吗?我们必须在application.yml文件中添加zuul配置
# custom configuration - used by swagger to rename endpoints in documentation
springfox:
documentation:
swagger:
v2:
path: /api/uaa/api-docs
whitelistInternal:
- method: GET
path: '/api/**/api-docs'
- method: GET
path: '/swagger-ui.html'
- method: GET
path: '/swagger-resources/**'
请检查适合您的线路
这是一个如何做到这一点的例子
zuul:
routes:
foo:
path: /bar/**
url: http://localhost:8080/foo
@Configuration
@EnableSwagger2
public class SwaggerConfig {
@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.basePackage("my.package"))
.build();
}
}
# custom configuration - used by swagger to rename endpoints in documentation
springfox:
documentation:
swagger:
v2:
path: /api/uaa/api-docs
whitelistInternal:
- method: GET
path: '/api/**/api-docs'
- method: GET
path: '/swagger-ui.html'
- method: GET
path: '/swagger-resources/**'