首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在SpringDoc中设置swagger配置参数

在SpringDoc中设置swagger配置参数
EN

Stack Overflow用户
提问于 2022-02-01 07:09:55
回答 1查看 888关注 0票数 0

我试图覆盖SpringDoc中的Swagger配置,如下所述:

https://springdoc.org/#swagger-ui-properties

我在(kotlin类) init块中设置这些代码。

代码语言:javascript
复制
init {
    System.setProperty("springdoc.swagger-ui.path", "/services/$serviceName")
    System.setProperty("springdoc.swagger-ui.url", "/services/$serviceName/v3/api-docs")
    System.setProperty("springdoc.swagger-ui.configUrl", "/services/$serviceName/v3/api-docs/swagger-config")
    // Controls the display of extensions (pattern, maxLength, minLength, maximum, minimum) fields and values for Parameters.
    System.setProperty("springdoc.swagger-ui.showCommonExtensions", "true")
}

然而,它似乎完全被忽视,没有一个字段被考虑在内。正确设置它们的位置是什么?

请注意,我需要根据SERVICE_NAME env设置配置属性,因此不能使用静态属性文件。

这里的完整配置:https://gist.github.com/knyttl/852f67f1688ea6e808b8eb89068e90d1

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-02-08 06:30:48

正如SpringDoc作者在https://github.com/springdoc/springdoc-openapi/issues/1485中所建议的那样,可以这样做:

代码语言:javascript
复制
    @Bean
    open fun swaggerUiConfig(config: SwaggerUiConfigProperties): SwaggerUiConfigProperties {
        // For details, see https://springdoc.org/#swagger-ui-properties
        // Controls the display of extensions (pattern, maxLength, minLength, maximum, minimum) fields and values for Parameters.
        config.showCommonExtensions = true
        // Allows to configure source for the documentation via query params (?url=/v3/api-docs).
        config.queryConfigEnabled = true
        return config
    }
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70936708

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档