【问题标题】:How do you configure the title, description and license in Springfox Swagger UI?如何在 Springfox Swagger UI 中配置标题、描述和许可?
【发布时间】:2017-09-11 10:48:51
【问题描述】:

当您在 Spring Boot 应用程序中使用 Springfox 启动 Swagger UI 时,它看起来像这样:

如何配置标题和描述(“Api 文档”)和许可证(Apache 2.0)。

【问题讨论】:

    标签: spring spring-boot swagger swagger-ui springfox


    【解决方案1】:

    您可以通过将ApiInfo 对象传递给您的案卷来设置这些值。

    new Docket(DocumentationType.SWAGGER_2)
        ...
        .apiInfo(new ApiInfo(...))
        ...
    

    ApiInfo 的构造函数接受有关您的 API 的一些详细信息。在您的情况下,您应该查看标题、描述和许可参数。

    【讨论】:

      【解决方案2】:

      Swagger 配置类(Spring boot):

      @Configuration
      public class SpringFoxConfig {
          @Bean
          public Docket api() {
              return new Docket(DocumentationType.SWAGGER_2)
                      .apiInfo(apiInfo())
                      .select()
                      .apis(RequestHandlerSelectors.any())
                      .paths(PathSelectors.any())
                      .build();
          }
      
          ApiInfo apiInfo() {
              return new ApiInfoBuilder()
                      .title("Demo Test API")
                      .description("Demo test API task")
                      .license("© 2021 by my")
                      .build();
          }
      
      }
      

      【讨论】:

        猜你喜欢
        • 2017-07-09
        • 1970-01-01
        • 2016-11-25
        • 2021-06-16
        • 1970-01-01
        • 1970-01-01
        • 2020-03-27
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多