{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/emporix/json-schema/emporix-oauth-response-schema.json",
  "title": "OAuthResponse",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/emporix-oauth-api-openapi.yml#/components/schemas/OAuthResponse",
  "allOf": [
    {
      "$ref": "#/$defs/OAuth"
    },
    {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "description": "Unique identifier of the entity."
        },
        "clientSecretToken": {
          "$ref": "#/$defs/ExpandableTokenResponse"
        },
        "metadata": {
          "$ref": "#/$defs/MetadataResponse"
        }
      }
    }
  ],
  "$defs": {
    "ExpandableTokenResponse": {
      "oneOf": [
        {
          "$ref": "#/$defs/IdResponse"
        },
        {
          "$ref": "#/$defs/ExpandedTokenResponse"
        }
      ],
      "description": "The full response representing token. If the `expand=token` is **not** used, then only `id` field is returned, otherwise all fields are returned."
    },
    "ExpandedTokenResponse": {
      "allOf": [
        {
          "$ref": "#/$defs/IdResponse"
        },
        {
          "type": "object",
          "properties": {
            "name": {
              "type": "string",
              "description": "Name of the token."
            },
            "metadata": {
              "$ref": "#/$defs/MetadataResponse"
            }
          }
        }
      ]
    },
    "IdResponse": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "description": "Identifier of the resource."
        }
      }
    },
    "MetadataRequest": {
      "type": "object",
      "properties": {
        "version": {
          "minimum": 1,
          "type": "integer",
          "description": "Version of the object. The version is required during the update operation because of the optimistic locking mechanism."
        }
      },
      "required": [
        "version"
      ]
    },
    "MetadataResponse": {
      "allOf": [
        {
          "$ref": "#/$defs/MetadataRequest"
        },
        {
          "type": "object",
          "properties": {
            "createdAt": {
              "description": "Date and time when the object was created. The value is approved as an ISO-8601 representation of an Instant. For example: `2022-04-30T13:18:02.379Z`",
              "type": "string"
            },
            "modifiedAt": {
              "description": "Date and time when the object was last modified. The value is approved as an ISO-8601 representation of an Instant. For example: `2022-04-30T13:18:02.379Z`",
              "type": "string"
            }
          },
          "required": [
            "version",
            "createdAt",
            "modifiedAt"
          ]
        }
      ]
    },
    "OAuth": {
      "type": "object",
      "description": "OAuth 2.0 client-credentials settings for authenticating with a self-hosted LLM backend.",
      "properties": {
        "url": {
          "type": "string",
          "format": "uri",
          "description": "Token endpoint URL of the OAuth 2.0 authorization server used to request an access token."
        },
        "clientId": {
          "type": "string",
          "description": "OAuth 2.0 client identifier registered with the authorization server."
        },
        "grantType": {
          "type": "string",
          "description": "OAuth 2.0 grant type used to obtain an access token. Currently only `client_credentials` is supported.",
          "enum": [
            "client_credentials"
          ]
        },
        "scope": {
          "type": "string",
          "description": "Optional space-separated list of scopes to request for the access token."
        },
        "enabled": {
          "type": "boolean",
          "description": "Indicates whether the OAuth configuration is enabled."
        }
      },
      "required": [
        "url",
        "clientId",
        "grantType"
      ]
    }
  }
}