{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/api-evangelist/posit/main/json-schema/posit-oauth-template-schema.json",
  "title": "OAuthTemplate",
  "description": "OAuthTemplate holds the set of available fields that can be configured when creating\nor updating an OAuth integration in Posit Connect.",
  "x-generated": "2026-10-03",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/posit-oauth-integration-templates-api-openapi.yml#/components/schemas/OAuthTemplate",
  "additionalProperties": false,
  "properties": {
    "id": {
      "description": "The primary identifier for this OAuth template.",
      "type": "string"
    },
    "name": {
      "description": "A human readable name for this OAuth template.",
      "type": "string"
    },
    "description": {
      "description": "A human readable description for this OAuth template.",
      "type": "string"
    },
    "sections": {
      "description": "The sections of the template are used to group fields and options when\nbuilding the UI.",
      "items": {
        "$ref": "#/$defs/OAuthTemplateSection"
      },
      "type": "array"
    },
    "options": {
      "description": "The options of the template are used to define the set of boolean and\ndrop-down inputs that the user configures when creating an OAuth\nintegration.",
      "items": {
        "$ref": "#/$defs/ServicePrincipalTemplateOption"
      },
      "type": "array"
    },
    "fields": {
      "description": "The fields of the template are used to define the set of text inputs that\nthe user configures when creating an OAuth integration.",
      "items": {
        "$ref": "#/$defs/ServicePrincipalTemplateField"
      },
      "type": "array"
    },
    "environment_variables": {
      "description": "The names of environment variables associated with this OAuth template.",
      "items": {
        "type": "string"
      },
      "type": "array"
    }
  },
  "type": "object",
  "$defs": {
    "OAuthTemplateSection": {
      "additionalProperties": false,
      "description": "OAuthTemplateSection defines a section within an OAuth template used to group options and fields when building the UI.",
      "properties": {
        "id": {
          "description": "The primary identifier of the template section.",
          "format": "int32",
          "type": "integer"
        },
        "order": {
          "description": "The order of this section relative to other sections within the OAuth\ntemplate.",
          "format": "int32",
          "type": "integer"
        },
        "name": {
          "description": "The name of this section.",
          "type": "string"
        },
        "description": {
          "description": "The description of this section.",
          "type": "string"
        }
      },
      "type": "object"
    },
    "ServicePrincipalTemplateField": {
      "additionalProperties": false,
      "description": "A configuration field (text input) for a service principal template.",
      "properties": {
        "name": {
          "description": "The primary identifier of the field, used as a config map key.",
          "type": "string"
        },
        "description": {
          "description": "A description of the field.",
          "type": "string"
        },
        "order": {
          "description": "The order of this field relative to other options and fields.",
          "format": "int32",
          "type": "integer"
        },
        "label": {
          "description": "The label to use for this field.",
          "type": "string"
        },
        "visibility_expression": {
          "allOf": [
            {
              "$ref": "#/$defs/ServicePrincipalTemplateVisibilityExpression"
            }
          ],
          "description": "A Boolean expression tree that indicates if this field is visible."
        },
        "default": {
          "description": "The default value of this field.",
          "type": "string"
        },
        "validation": {
          "description": "A regular expression used to determine whether the input is valid.",
          "type": "string"
        },
        "validation_description": {
          "description": "A description of the value constraints for this field.",
          "type": "string"
        },
        "secret": {
          "description": "Indicates whether the field value is secret and should be hidden.",
          "type": "boolean"
        },
        "multiline": {
          "description": "Indicates whether the field accepts multiline text input.",
          "type": "boolean"
        }
      },
      "type": "object"
    },
    "ServicePrincipalTemplateOption": {
      "additionalProperties": false,
      "description": "A configuration option (boolean or drop-down input) for a service principal template.",
      "properties": {
        "name": {
          "description": "The primary identifier of the option, used as a config map key.",
          "type": "string"
        },
        "description": {
          "description": "A description of the option.",
          "type": "string"
        },
        "order": {
          "description": "The order of this option relative to other options and fields.",
          "format": "int32",
          "type": "integer"
        },
        "label": {
          "description": "The label to use for this option.",
          "type": "string"
        },
        "visibility_expression": {
          "allOf": [
            {
              "$ref": "#/$defs/ServicePrincipalTemplateVisibilityExpression"
            }
          ],
          "description": "A Boolean expression tree that indicates if this option is visible."
        },
        "type": {
          "description": "The type of this option, either \"bool\" or \"select\".",
          "type": "string"
        },
        "values": {
          "description": "The possible values when type is \"select\".",
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        "default": {
          "description": "The default value of this option.",
          "type": "object"
        }
      },
      "type": "object"
    },
    "ServicePrincipalTemplateVisibilityExpression": {
      "additionalProperties": false,
      "description": "A Boolean expression tree that indicates if a specific option or field is\nallowed by the service principal configuration.",
      "properties": {
        "name": {
          "description": "The name of a config field being compared. Set only on leaf nodes.",
          "type": "string"
        },
        "value": {
          "description": "The value a config field is compared against. Set only on leaf nodes.",
          "type": "object"
        },
        "operator": {
          "description": "A Boolean operator applied to the operands. Set only on non-leaf nodes.",
          "type": "string"
        },
        "operands": {
          "description": "The operands a Boolean operator applies to. Set only on non-leaf nodes.",
          "items": {
            "$ref": "#/$defs/ServicePrincipalTemplateVisibilityExpression"
          },
          "type": "array"
        }
      },
      "type": "object"
    }
  }
}