我试图覆盖SpringDoc中的Swagger配置,如下所述:
https://springdoc.org/#swagger-ui-properties
我在(kotlin类) init块中设置这些代码。
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
发布于 2022-02-08 06:30:48
正如SpringDoc作者在https://github.com/springdoc/springdoc-openapi/issues/1485中所建议的那样,可以这样做:
@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
}https://stackoverflow.com/questions/70936708
复制相似问题