如何在Springdoc中禁用Swagger UI语法高亮?
解决Springdoc Swagger UI语法高亮禁用无效的问题
1. 修正配置属性写法
你之前的配置可能因springdoc版本差异不生效,尝试使用以下标准配置:
application.yaml 配置方式:
springdoc: swagger-ui: syntaxHighlight: false
application.properties 配置方式:
springdoc.swagger-ui.syntaxHighlight=false
2. 自定义配置类强制生效
如果上述配置仍无效果,可通过自定义配置类直接设置Swagger UI参数:
import org.springdoc.core.configuration.SwaggerUiConfigParameters; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @Configuration public class SwaggerUiCustomConfig { @Bean public SwaggerUiConfigParameters swaggerUiConfigParameters() { SwaggerUiConfigParameters configParams = new SwaggerUiConfigParameters(); configParams.setSyntaxHighlight(false); return configParams; } }
3. 清除浏览器缓存
修改配置后,按Ctrl+Shift+R(Windows/Linux)或Cmd+Shift+R(Mac)强制刷新页面,避免浏览器缓存旧的Swagger UI资源。
内容的提问来源于stack exchange,提问作者user19417550
相关产品推荐
相关产品推荐

