I've configured Swashbuckle (5.0.0-rc2) on ASP.NET Core to work with my OpenID server (Openiddict) but Swagger doesn't show any available authorization. Only an empty modal.
This is the snippet where I set OpenID on swagger
services.AddSwaggerGen(c =>
{
//... omitted for brevity
//baseAccountsUrl is "https://localhost:5401"
c.AddSecurityDefinition("AccountsOpenID", new OpenApiSecurityScheme
{
Type = SecuritySchemeType.OpenIdConnect,
OpenIdConnectUrl = new Uri($"{baseAccountsUrl}/.well-known/openid-configuration")
});
}
If I login before getting here every action works fine, otherwise every method will be redirected to login and shown in server response.
If I use OAuth2 instead of OpenID with password flow (it's configured this way on Openiddict) and not logged-in in browser it's not successful either.
What am I doing wrong?
Support for OpenID Connect Discovery was added in Swagger UI v. 3.38.0. Swashbuckle needs to update the bundled Swagger UI to the latest version:
https://github.com/domaindrivendev/Swashbuckle.AspNetCore/issues/1241
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