如何为OpenAPI 3.0.0的securitySchemes使用“授权代码”?

时间:2020-01-08 11:03:05

标签: json yaml openapi openapi-generator

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

这里唯一的代码仅用于隐式类型。

    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

如果有人知道这个概念,请提供 YAML JSON 的示例。

1 个答案:

答案 0 :(得分:2)

存在对authorizationCode流程的支持-我从规范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