【问题标题】:I want scope checkbox checked by default swagger Nswag我希望默认选中范围复选框 swagger Nswag
【发布时间】:2022-04-25 12:58:18
【问题描述】:

这里是 Swagger/OpenAPI 的定义:

 services.AddOpenApiDocument(document =>
        {
            document.DocumentProcessors.Add(new SecurityDefinitionAppender("Bearer", Enumerable.Empty<string>(),
                new OpenApiSecurityScheme
                {
                    Type = OpenApiSecuritySchemeType.OAuth2,
                    Flow = OpenApiOAuth2Flow.AccessCode,
                    Scopes = new Dictionary<string, string> {{"myScope", "myScope"}},
                    AuthorizationUrl = "redacted",
                    TokenUrl = "redacted"
                }));
        }); 

和 Swagger-UI 配置选项:

app.UseSwaggerUi3(settings =>
        {
            settings.OAuth2Client = new OAuth2ClientSettings
            {
                ClientId = "MyClientID",
                ClientSecret = string.Empty,
                AppName = "My App",
                UsePkceWithAuthorizationCodeGrant = true
            };
        });

我希望默认检查范围,这可能吗?

【问题讨论】:

  • 你找到答案了吗?
  • 不,先生。有一些建议可以围绕它写一些 JS
  • @claudekennilol,这是一种解决方法 - stackoverflow.com/a/60960871/968003。看起来很丑,但我还没有看到更好的选择

标签: asp.net-core-webapi nswag


【解决方案1】:

在6.0版本中可以通过OAuthScopes方法实现。

参考:https://github.com/abpframework/abp/pull/7740

【讨论】:

    猜你喜欢
    • 2017-01-16
    • 2021-01-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-03-10
    • 2018-12-31
    相关资源
    最近更新 更多