Hide SwaggerUI GUI on production
See original GitHub issuehey there, is there a simple way to disable displaying the SwaggerUI when application is pushed on production. So far i tried conditioning using a classic #if !DEBUG
/// <summary>
/// Swagger Configuration
/// </summary>
public class SwaggerConfig
{
/// <summary>
/// Register
/// </summary>
public static void Register()
{
var thisAssembly = typeof(SwaggerConfig).Assembly;
#if !DEBUG
GlobalConfiguration.Configuration
.EnableSwagger(c =>
{
// By default, the service root url is inferred from the request used to access the docs.
// However, there may be situations (e.g. proxy and load-balanced environments) where this does not
// resolve correctly. You can workaround this by providing your own code to determine the root URL.
//
c.RootUrl(req => "/my.API");
// If schemes are not explicitly provided in a Swagger 2.0 document, then the scheme used to access
// the docs is taken as the default. If your API supports multiple schemes and you want to be explicit
// about them, you can use the "Schemes" option as shown below.
//
c.Schemes(new[] { "https", "http" });
// Use "SingleApiVersion" to describe a single version API. Swagger 2.0 includes an "Info" object to
// hold additional metadata for an API. Version and title are required but you can also provide
// additional fields by chaining methods off SingleApiVersion.
//
c.SingleApiVersion("v1", "my.API");
But it still trying to load a Swagger page at /my.API/swagger/ui/index and i am getting an error 404.
Any help is much appriciated and i guess i am not the only one having this kind of requirements ?
Thanks
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
How to Turn Off Swagger-ui in Production
To disable Swagger in production, let's toggle whether this configuration bean is injected. 3. Using Spring Profiles. In Spring, we can use the ......
Read more >How do you turn off swagger-ui in production
Put your swagger configuration into separate configuration class and annotate it with @Profile annotation -> so that it will be scanned into ...
Read more >Spring Boot disable Swagger-ui in Production
Spring Boot disable Swagger-ui in Production. To disable Swagger-ui for production profile, first we need to define a maven profile.
Read more >Authentication for swagger UI in production in ASP.Net Core
A Short guide on how to Secure your Swagger UI in production by providing proper authentication. ... Remove the swagger part from env....
Read more >How do I disable swashbuckle swagger UI in production ...
I using swashbuckle v 5.6.0 for api documentation and ui for test in asp.net web api2. I do ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
the 404 issue was error code on my side. I could finally the trick above (using the #if DEBUG) to hide swagger and load a start page instead of the swagger page.
glad you got it to work … but I think that your current implementation with the
#if !DEBUG
condition removing the EnableSwagger will more than just hide the UI, the swagger.json will not be generated