admin管理员组文章数量:1406937
I have a Web API that produces two Swashbuckle (Swagger) documents, say Doc A
and Doc B
.
I want to use different scopes on each doc, like:
- Doc A - scopeA
- Doc B - scopeA, scopeB
Here is my code:
services.AddSwaggerGen(c =>
{
var authorizationCode = new OpenApiOAuthFlow
{
AuthorizationUrl = new Uri("abc"),
TokenUrl = new Uri("xyz"),
// swaggerSettings.Scopes is Dictionary<string, string>, containing "scope-description" pairs
Scopes = swaggerSettings.Scopes
};
c.AddSecurityDefinition("oauth2", new OpenApiSecurityScheme
{
Type = SecuritySchemeType.OAuth2,
Flows = new OpenApiOAuthFlows { AuthorizationCode = authorizationCode }
});
})
...
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/swagger/swagger.json", "Doc A");
});
app.UseSwaggerUI(c =>
{
c.RoutePrefix = "swagger/anotherDoc";
c.SwaggerEndpoint("/swagger/another/swagger.json", "Doc B");
});
The specified scopes (, or SecurityDefinition
) above are used by both docs and I don't see how I can specify different scopes for each doc.
Is there a way to do it?
本文标签: swashbuckleaspnetcoreChange authorization scopes on each Swashbuckle (swagger) pagesStack Overflow
版权声明:本文标题:swashbuckle.aspnetcore - Change authorization scopes on each Swashbuckle (swagger) pages - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745055346a2639898.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论