Search code examples
swaggerswagger-uiopenapi

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?


Solution

  • 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.