{
  "type": "object",
  "properties": {
    "$shared": {
      "type": "object",
      "properties": {
        "SSLConfiguration": {
          "$ref": "#/$defs/sslConfiguration"
        },
        "Security": {
          "$ref": "#/$defs/security"
        }
      },
      "description": "Variables that apply to every environment; an environment's own value wins.",
      "additionalProperties": {
        "$ref": "#/$defs/value"
      }
    }
  },
  "$id": "https://datagriff.github.io/api-caller/schemas/http-client.env.schema.json",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$defs": {
    "security": {
      "type": "object",
      "properties": {
        "Auth": {
          "type": "object",
          "description": "OAuth2 configurations by name. A request uses one as {{$auth.token(\"name\")}} or {{$auth.idToken(\"name\")}}; the private file's fields win over the public file's.",
          "additionalProperties": {
            "type": "object",
            "properties": {
              "Acquire Automatically": {
                "type": "boolean",
                "description": "Accepted; apic fetches a token when a request needs one."
              },
              "Auth URL": {
                "type": "string",
                "description": "The authorization endpoint, for Authorization Code."
              },
              "Client Credentials": {
                "type": "string",
                "description": "How the client authenticates at the token endpoint. Default in body.",
                "enum": [
                  "basic",
                  "in body",
                  "none"
                ]
              },
              "Client ID": {
                "type": "string",
                "description": "The client ID."
              },
              "Client Secret": {
                "type": "string",
                "description": "The client secret; keep it in http-client.private.env.json."
              },
              "Custom Request Parameters": {
                "type": "object",
                "description": "Extra parameters. apic sends audience; others are reported by apic validate."
              },
              "Device Auth URL": {
                "type": "string",
                "description": "The device authorization endpoint, for Device Authorization."
              },
              "Grant Type": {
                "type": "string",
                "description": "The grant. Implicit is refused; Authorization Code runs with PKCE.",
                "enum": [
                  "Client Credentials",
                  "Password",
                  "Device Authorization",
                  "Authorization Code",
                  "Implicit"
                ]
              },
              "PKCE": {
                "description": "Accepted; apic always uses PKCE for Authorization Code."
              },
              "Password": {
                "type": "string",
                "description": "For the Password grant; keep it in http-client.private.env.json."
              },
              "Redirect URL": {
                "type": "string",
                "description": "Where the provider sends the browser back, for Authorization Code: http://localhost:\u003cport\u003e/\u003cpath\u003e, where apic listens."
              },
              "Scope": {
                "type": "string",
                "description": "Space-separated scopes."
              },
              "Token URL": {
                "type": "string",
                "description": "The token endpoint."
              },
              "Type": {
                "type": "string",
                "description": "Only OAuth2 is read.",
                "enum": [
                  "OAuth2"
                ]
              },
              "Use ID Token": {
                "type": "boolean",
                "description": "$auth.token gives the ID token rather than the access token."
              },
              "Username": {
                "type": "string",
                "description": "For the Password grant."
              }
            },
            "description": "One OAuth2 configuration. String fields may hold {{placeholders}}."
          }
        }
      },
      "description": "JetBrains HTTP Client's Security block. Not a variable. apic reads its Auth configurations."
    },
    "sslConfiguration": {
      "type": "object",
      "properties": {
        "clientCertificate": {
          "description": "The client certificate: a PEM path, or an object with `path` and `keyPath`.",
          "oneOf": [
            {
              "type": "string"
            },
            {
              "type": "object",
              "properties": {
                "format": {
                  "type": "string",
                  "description": "Accepted for compatibility; apic reads PEM only."
                },
                "keyPath": {
                  "type": "string",
                  "description": "PEM private key; defaults to path."
                },
                "path": {
                  "type": "string",
                  "description": "PEM client certificate."
                }
              },
              "required": [
                "path"
              ]
            }
          ]
        },
        "hasCertificatePassphrase": {
          "type": "boolean",
          "description": "The key is encrypted. apic cannot prompt for a passphrase and refuses such a key."
        },
        "verifyHostCertificate": {
          "type": "boolean",
          "description": "Verify the server's certificate. Default true."
        }
      },
      "description": "JetBrains HTTP Client's TLS block: a client certificate to present and whether to verify the server. Not a variable. Paths are relative to the project root."
    },
    "value": {
      "type": [
        "string",
        "number",
        "boolean",
        "null"
      ],
      "description": "A variable value. Non-strings are converted to text when substituted."
    }
  },
  "title": "http-client.env.json",
  "description": "Per-environment variables for .http files, the format shared by JetBrains HTTP Client, kulala.nvim, httpyac and apic. The same shape is used by http-client.private.env.json, which holds secrets and is gitignored.",
  "examples": [
    {
      "$shared": {
        "userId": 42
      },
      "dev": {
        "baseUrl": "https://dev.example.com"
      },
      "prod": {
        "baseUrl": "https://api.example.com"
      }
    }
  ],
  "additionalProperties": {
    "type": "object",
    "properties": {
      "SSLConfiguration": {
        "$ref": "#/$defs/sslConfiguration"
      },
      "Security": {
        "$ref": "#/$defs/security"
      }
    },
    "description": "The variables of one environment.",
    "additionalProperties": {
      "$ref": "#/$defs/value"
    },
    "propertyNames": {
      "pattern": "^[A-Za-z_$][\\w.-]*$"
    }
  }
}
