【问题标题】:Swagger UI doesn't show module name in its url andSwagger UI 不在其 url 中显示模块名称,并且
【发布时间】:2019-04-21 23:11:16
【问题描述】:

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

我使用了以下配置,但我希望 module-name 在这里打印出来。此外,@Api(tags = "User Catalouge", description = "List Of Users")description 已弃用。

@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;
    }
}

【问题讨论】:

    标签: swagger-2.0 springfox


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-06-10
      • 2016-09-29
      • 1970-01-01
      • 1970-01-01
      • 2018-09-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多