Home > Software design >  NSwag - How to hide base URL , Version , Scheme from swagger UI
NSwag - How to hide base URL , Version , Scheme from swagger UI

Time:11-14

I am using .NET Core WebAPI (Nswag) I wanted to hide below items from swagger UI. Is that possible?

  1. 'Select Definition' and dropdown (Top right corner)
  2. BaseURL and Swagger.json link
  3. Schemes and dropdown.

Highlighted in below screenshot.

enter image description here

CodePudding user response:

You can enter image description here

Is this what you want?

Update:

NSwag can also customize CSS styles:

custom.css:

.swagger-ui .topbar .download-url-wrapper {
    display : none;
}

.swagger-ui .info .base-url {
    display : none;
}

.swagger-ui .info hgroup.main a {
    display: none;
}

.swagger-ui .scheme-container {
    display : none;
}

And in Program.cs (Startup.cs in .Net5):

app.UseSwaggerUi3(c => {
        c.CustomStylesheetPath = "/swagger-ui/custom.css";
    });

Don't forget app.UseStaticFiles();.

Result: enter image description here

  • Related