OpenAPI swagger UI is not responding for large response

Viewed 826

I have a SpringBoot application and using OpenAPI to document a Spring REST API. The payload that the application is returning is really huge and therefore Swagger starts hanging and doesn't display. I looked into this open Github issue https://github.com/swagger-api/swagger-ui/issues/3832. One of the comments suggest to turn off the syntaxHighlight parameters https://github.com/swagger-api/swagger-ui/issues/3832#issuecomment-698531637. However, I am not sure how can i set that parameter when using OpenAPI.

My current code creates a bean for the OpenAPI. The class is as follows.

@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")));
    }

}

If there is any other way to display large payloads when using OpenAPI please let me know. Thanks!

0 Answers
Related