Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

swagger-ui hangs on big responses

One of my endpoints returns a JSON (not huge, around 2MB). Trying to run GET on this endpoint in swagger-ui results in the browser hanging for a few minutes. After this time, it finally displays the JSON.

Is there a way to define that the response shouldn't be rendered but provided as a file to download instead?

I'm using OpenAPI 3, and I tried the following:

content:
    application/json:
        schema:
            type: string
            format: binary

taken from the documentation. Still, swagger-ui renders the response.

Has anyone had the same problem?

like image 818
idetyp Avatar asked Aug 27 '20 11:08

idetyp


People also ask

Is swagger deprecated?

The Swagger API interface in the AppDynamics Platform is deprecated starting version 4.5. 15.

What is the difference between swagger and Swagger UI?

Swagger Editor: Swagger Editor lets you edit OpenAPI specifications in YAML inside your browser and to preview documentations in real time. Swagger UI: Swagger UI is a collection of HTML, Javascript, and CSS assets that dynamically generate beautiful documentation from an OAS-compliant API.

Is swagger API RESTful?

Introduction. Swagger™ is a project used to describe and document RESTful APIs. The Swagger specification defines a set of files required to describe such an API. These files can then be used by the Swagger-UI project to display the API and Swagger-Codegen to generate clients in various languages.

What is swagger stack overflow?

Swagger is a framework implementation for describing, producing, consuming, and visualizing RESTful web services, based on the OpenAPI specification.


1 Answers

Lex45x proposes in this github issue to disable syntax highlighting. In ASP.Net Core you can do this with

app.UseSwaggerUI(config =>
{
    config.ConfigObject.AdditionalItems["syntaxHighlight"] = new Dictionary<string, object>
    {
        ["activated"] = false
    };
});

This significantly improves render performance.

like image 106
PeterB Avatar answered Oct 10 '22 14:10

PeterB