{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "http://asyncapi.com/definitions/3.1.0/oauth2Flows.json",
  "description": "Allows configuration of the supported OAuth Flows.",
  "type": "object",
  "required": [ "type", "flows" ],
  "properties": {
    "description": {
      "description": "A short description for security scheme.",
      "type": "string"
    },
    "type": {
      "description": "The type of the security scheme.",
      "type": "string",
      "enum": [ "oauth2" ]
    },
    "flows": {
      "type": "object",
      "properties": {
        "authorizationCode": {
          "description": "Configuration for the OAuth Authorization Code flow.",
          "allOf": [
            {
              "$ref": "http://asyncapi.com/definitions/3.1.0/oauth2Flow.json"
            },
            {
              "required": [ "authorizationUrl", "tokenUrl", "availableScopes" ]
            }
          ]
        },
        "clientCredentials": {
          "description": "Configuration for the OAuth Client Credentials flow.",
          "allOf": [
            {
              "$ref": "http://asyncapi.com/definitions/3.1.0/oauth2Flow.json"
            },
            {
              "required": [ "tokenUrl", "availableScopes" ]
            },
            {
              "not": {
                "required": [ "authorizationUrl" ]
              }
            }
          ]
        },
        "implicit": {
          "description": "Configuration for the OAuth Implicit flow.",
          "allOf": [
            {
              "$ref": "http://asyncapi.com/definitions/3.1.0/oauth2Flow.json"
            },
            {
              "required": [ "authorizationUrl", "availableScopes" ]
            },
            {
              "not": {
                "required": [ "tokenUrl" ]
              }
            }
          ]
        },
        "password": {
          "description": "Configuration for the OAuth Resource Owner Protected Credentials flow.",
          "allOf": [
            {
              "$ref": "http://asyncapi.com/definitions/3.1.0/oauth2Flow.json"
            },
            {
              "required": [ "tokenUrl", "availableScopes" ]
            },
            {
              "not": {
                "required": [ "authorizationUrl" ]
              }
            }
          ]
        }
      },
      "additionalProperties": false
    },
    "scopes": {
      "description": "List of the needed scope names.",
      "type": "array",
      "items": {
        "type": "string"
      }
    }
  },
  "patternProperties": {
    "^x-[\\w\\d\\.\\x2d_]+$": {
      "$ref": "http://asyncapi.com/definitions/3.1.0/specificationExtension.json"
    }
  }
}
