You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.14 16:55:28