Search code examples
.net-coreswaggerswagger-ui

.Net Core 3.1 Remove Schema on Swagger UI


I have .Net 3.1 Web Api, I would like to remove this sections "Schemas" on Swagger UI.
How to do it? .net


Solution

  • No need for a schema filter. After busting on it for days I have found out:

    All needs to be done is in

    app.UseSwaggerUI(options =>
    {
        options.DefaultModelsExpandDepth(-1);
    });
    

    Note: It is DefaultModels (plural) not DefaultModel (singular). Difference is DefaultModels is the default expansion depth for the model on the model-example section, whereas DefaultModels is the expansion depth for models.