Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple UseSwaggerUI support removed? #1996

Closed
effyteva opened this issue Feb 8, 2021 · 3 comments
Closed

Multiple UseSwaggerUI support removed? #1996

effyteva opened this issue Feb 8, 2021 · 3 comments
Labels
responded Responded with solution or request for more info

Comments

@effyteva
Copy link

effyteva commented Feb 8, 2021

Hi,

We're trying to migrate to the new 6.0.2 release,
We're currently using UseSwaggerUI twice, while each UI renders different API methods (one is used for the most common methods, and the other for all methods regardless of their usage).
The methods are excluded using the DocInclusionPredicate, based on the DocumentName.

After migrating to the new 6.0.2 release, only the second UseSwaggerUI call is actually working, and the first one seems to be completely ignored.
Is that intended behavior or a bug? Is there any other way to achieve multiple endpoints with different methods?

Thank you,
Effy

@domaindrivendev
Copy link
Owner

domaindrivendev commented Feb 8, 2021

Hi @effyteva. In the latest version, if you're configuring the Swagger, SwaggerUI, or ReDoc middleware with the overload that accepts a setup action (e.g. Action<SwaggerUIOptions>) then you're implicitly using the singleton instance of options from you're app's DI container (see the ASP.NET Core Options pattern for more info on this).

So, for your usecase you'll need to use the overload that accepts a specific instance of options instead of the setup action:

app.UseSwaggerUI(new SwaggerUIOptions
{
    RoutePrefix = "foo-docs",
    ConfigObject = new ConfigObject
    {
        Urls = new[] { new UrlDescriptor { Url = "/swagger/foo/swagger.json", Name = "Foo Docs"} }
    }
});

app.UseSwaggerUI(new SwaggerUIOptions
{
    RoutePrefix = "bar-docs",
    ConfigObject = new ConfigObject
    {
        Urls = new[] { new UrlDescriptor { Url = "/swagger/bar/swagger.json", Name = "Bar Docs"} }
    }
});

@domaindrivendev domaindrivendev added the responded Responded with solution or request for more info label Feb 8, 2021
@effyteva
Copy link
Author

effyteva commented Feb 8, 2021

Thank you @domaindrivendev
I appreciate your quick response, this worked perfect, and we've managed to upgrade to the newest release once again.

Effy

@halloersmal
Copy link

That helped me out! Thank you so much for the ConfigObject usage Example! I worked for days to have two different Swagger UIs for different endpoints!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
responded Responded with solution or request for more info
Projects
None yet
Development

No branches or pull requests

3 participants