How to hide the Models section in Swagger UI?

For .Net Core 3.0 just Add c.DefaultModelsExpandDepth(-1); on your Startup.cs

// Startup.cs

app.UseSwaggerUI(c =>
{
    c.DefaultModelsExpandDepth(-1); // Disable swagger schemas at bottom
    c.SwaggerEndpoint("/swagger/v1/swagger.json", "Your API V1");
});

To hide the "Models" section, add defaultModelsExpandDepth: -1 to the Swagger UI configuration code in your index.html.

Note the option name uses plural Model*s* not Model.

// index.html

<script>
window.onload = function() {
  // Begin Swagger UI call region
  const ui = SwaggerUIBundle({
    url: "https://petstore.swagger.io/v2/swagger.json",
    dom_id: '#swagger-ui',
    defaultModelsExpandDepth: -1,   // <-------

Swagger UI also has many other configuration options that control API documentation rendering.

Tags:

Swagger Ui