【问题标题】:How to use "Authorization code" for securitySchemes for OpenAPI 3.0.0?如何为 OpenAPI 3.0.0 的 securitySchemes 使用“授权码”?
【发布时间】:2020-04-25 21:43:16
【问题描述】:

在 OpenAPI 3.0.0 文档中,没有针对 授权代码 类型的示例代码。

这里只有 implicit 类型的唯一代码。

    petstore_auth:
      type: oauth2
      flows:
        implicit:
          authorizationUrl: 'http://petstore.swagger.io/api/oauth/dialog'
          scopes:
            'write:pets': modify pets in your account
            'read:pets': read your pets

如果有人知道这个概念,请提供一个 YAMLJSON 中的示例。

【问题讨论】:

    标签: json yaml openapi openapi-generator


    【解决方案1】:

    支持授权代码流程 - 我正在阅读规范 http://spec.openapis.org/oas/v3.0.2.html#oauth-flows-object 中的内容,看起来您可以将 implicit 替换为 authorizationCode,如下所示:

    flows:
      authorizationCode:
        authorizationUrl: https://example.com/api/oauth/dialog
        tokenUrl: https://example.com/api/oauth/token
        scopes:
          write:pets: modify pets in your account
          read:pets: read your pets 
    

    【讨论】:

      猜你喜欢
      • 2022-01-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-11-07
      • 2020-05-29
      • 2022-10-13
      • 2020-09-17
      • 1970-01-01
      相关资源
      最近更新 更多