OpenAPI swagger UI 没有响应较大的响应

Jen*_*nny 6 spring swagger-ui openapi

我有一个 SpringBoot 应用程序并使用 OpenAPI 来记录 Spring REST API。应用程序返回的有效负载非常巨大,因此 Swagger 开始挂起并且不显示。我调查了这个开放的 Github 问题https://github.com/swagger-api/swagger-ui/issues/3832。其中一条评论建议关闭syntaxHighlight参数https://github.com/swagger-api/swagger-ui/issues/3832#issuecomment-698531637。但是,我不确定在使用 OpenAPI 时如何设置该参数。

我当前的代码为 OpenAPI 创建一个 bean。班级如下。

@SpringBootApplication
public class SampleWebApplication extends SpringBootServletInitializer{
 
 public static void main(String[] args) {
  SpringApplication.run(SampleWebApplication.class,args);
 }

@Bean
public OpenAPI customOpenAPI(@Value("${spring.app.name}") String appDesciption, @Value("${version}") String appVersion) {
        return new OpenAPI()
                .info(new Info()
                                .title("test API")
                                .version(appVersion)
                                .description(appDesciption)
                                .termsOfService("http://swagger.io/terms/")
                                .license(new License().name("Apache 2.0").url("http://springdoc.org")));
    }

}
Run Code Online (Sandbox Code Playgroud)

如果使用 OpenAPI 时有任何其他方式显示大负载,请告诉我。谢谢!