小编moh*_*him的帖子

在Swagger UI / Spring Boot中支持多个路径映射

我在Spring Boot(版本1.5.9.RELEASE)项目中使用了swagger 2.0。Swagger可以正常工作,但是现在文档有数百个api,我想重定向文档到不同的URL。

@Configuration
@EnableSwagger2
public class SwaggerConfig {
    @Bean
    public Docket postsApi() {
        return new Docket(DocumentationType.SWAGGER_2).groupName("public-api")
                .apiInfo(apiInfo()).select().paths(postPaths()).build();
    }

    private Predicate<String> postPaths() {
        return or(regex("/api/posts.*"), or(regex("/api/.*"), regex("/secure/api/.*")));
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder().title("Swagger API")
                .description("Swagger Integration with Spring Boot")
                .termsOfServiceUrl(null)
                .license(null)
                .licenseUrl(null).version("1.0").build();
    }
}
Run Code Online (Sandbox Code Playgroud)

请提出任何建议。提前致谢。

spring swagger spring-boot swagger-2.0

2
推荐指数
1
解决办法
2226
查看次数

标签 统计

spring ×1

spring-boot ×1

swagger ×1

swagger-2.0 ×1