Swagger UI在其url和

时间:2018-11-19 14:55:30

标签: swagger-2.0 springfox

我遵循https://dzone.com/articles/spring-boot-restful-api-documentation-with-swagger并使用springfox-swagger-uispringfox-swagger2版本2.9.2开发Swagger。

我使用了以下配置,但我想在此处打印 模块名称 。此外,不推荐使用@Api(tags = "User Catalouge", description = "List Of Users")说明

@Configuration
@EnableSwagger2
public class SwaggerConfig {
    @Bean
    public Docket productApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .select()
                .apis(RequestHandlerSelectors.basePackage("guru.springframework.controllers"))
                .paths(regex("/product.*"))
                .build()
                .apiInfo(metaData());
    }
    private ApiInfo metaData() {
        ApiInfo apiInfo = new ApiInfo(
                "Spring Boot REST API",
                "Spring Boot REST API for Online Store",
                "1.0",
                "Terms of service",
                new Contact("John Thompson", "https://springframework.guru/about/", "john@springfrmework.guru"),
               "Apache License Version 2.0",
                "https://www.apache.org/licenses/LICENSE-2.0");
        return apiInfo;
    }
}

enter image description here

1 个答案:

答案 0 :(得分:0)

您只需要设置servlet context path Spring Boot和Swagger 足够聪明,可以识别URL并将其带入URL。

server.servlet.context-path=/product-details