I use Swagger UI to display API documentation. By default, it displays the "Models" section at the bottom:
How to hide it?
Using @ApiModelProperty We can use the hidden property of the annotation to hide a field in the definition of a model object in Swagger UI. Let's try it for the id field: @ApiModelProperty(hidden = true) private int id; In the above scenarios, we find that the id field is hidden for both GET and POST APIs.
How to do it? add this property in your Swagger UI Options defaultModelsExpandDepth: -1 for hide schema section and for more reference refer this swagger.io/docs/open-source-tools/swagger-ui/usage/… Can you please add your swagger ui configuration settings in your question.
By default, Swagger UI uses BaseLayout , which is built into the application. You can specify a different layout to be used by passing the layout's name as the layout parameter to Swagger UI. Be sure to provide your custom layout as a component to Swagger UI.
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.
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");
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With