Nswag: UseSwaggerUi3WithApiExplorer doesn't load any page

Created on 19 Apr 2018  路  6Comments  路  Source: RicoSuter/NSwag

I tried using UseSwaggerUi3WithApiExplorer but whne I try to navigate to the index page nothing is rendered, and in the browser console I can see an error stating that "RedirectUrl" is undefined.
I tracked this down in sources and it seems the problem is that in the UseSwaggerUi3WithApiExplorer extension a SwaggerUiSettings is used while it should be a SwaggerUi3Settings

high bug

Most helpful comment

v11.17.2

All 6 comments

I found a workaround for this, until the issue is fixed. The problem is that the correct Middleware is not registered, so just register it with an additional call to UseSwaggerUi3, then call UseSwaggerUi3WithApiExplorer, which will override the previous one, but keep the necessary registration working:

csharp app.UseSwaggerUi3(typeof(Startup).GetTypeInfo().Assembly, s => { })); app.UseSwaggerUi3WithApiExplorer(s => { });

v11.17.2

Thanks, I can confirm it works now without the extra call.

Thanks giggio. You just made my day

@giggio and @mainmen this will hide the call of:

app.UseSwaggerUi3WithApiExplorer(s => { });

completely i think...
I this still an issue?

app.UseSwaggerUi3WithApiExplorer();

should be enough

Is still an issue, we need to call
app.UseSwaggerUi3WithApiExplorer();
twice to make it work:

` app.UseSwaggerUi3WithApiExplorer(settings => {

            settings.GeneratorSettings.DefaultPropertyNameHandling = PropertyNameHandling.CamelCase;
            settings.PostProcess = options =>
            {
                options.Info.Version = "v1";
                options.Info.Title = "Reseller API";
                options.Info.Description = "services to Reseller clients";
                options.Info.TermsOfService = "None";
                options.Info.Contact = new NSwag.SwaggerContact
                {
                    Name = "Gerencia Senpai",
                    Email = "[email protected]",
                    Url = "http://senpai.com.co"
                };
                //settings.Info.License = new NSwag.SwaggerLicense
                //{
                //    Name = "Use under LICX",
                //    Url = "https://example.com/license"
                //};
            };
        });
        app.UseSwaggerUi3WithApiExplorer();`
Was this page helpful?
0 / 5 - 0 ratings