{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://catalog.lintel.tools/schemas/schemastore/hulak-configuration/latest.json",
  "title": "hulakApiRequest",
  "description": "Schema for Hulak request YAML files\n<https://github.com/xaaha/hulak>",
  "x-lintel": {
    "source": "https://raw.githubusercontent.com/xaaha/hulak/refs/heads/main/assets/schema.json",
    "sourceSha256": "ac476aa5b482f9ca5cc730a414197a57b1bf285b9fb3eec59e970ae379490622",
    "fileMatch": [
      "**/*.hk.yaml",
      "**/*.hk.yml",
      "**/*.hk.json"
    ],
    "parsers": [
      "json",
      "yaml"
    ]
  },
  "type": "object",
  "properties": {
    "kind": {
      "title": "requestKind",
      "type": "string",
      "description": "Request type that determines the flow to follow.",
      "enum": [
        "API",
        "Auth",
        "GraphQL",
        "graphql",
        "api",
        "auth"
      ]
    },
    "method": {
      "title": "httpMethod",
      "type": "string",
      "description": "HTTP method for the request\n<https://developer.mozilla.org/docs/Web/HTTP/Methods>",
      "enum": [
        "GET",
        "POST",
        "PUT",
        "PATCH",
        "DELETE",
        "HEAD",
        "OPTIONS",
        "TRACE",
        "CONNECT"
      ]
    },
    "url": {
      "title": "requestUrl",
      "type": "string",
      "description": "Target URL for the API request\n<https://developer.mozilla.org/docs/Web/HTTP/URLs>",
      "format": "uri"
    },
    "urlparams": {
      "title": "queryParameters",
      "type": "object",
      "description": "URL query parameters for the request\n<https://developer.mozilla.org/docs/Web/API/URLSearchParams>",
      "additionalProperties": {
        "type": "string"
      }
    },
    "headers": {
      "title": "httpHeaders",
      "type": "object",
      "description": "HTTP headers included in the request\n<https://developer.mozilla.org/docs/Web/HTTP/Headers>",
      "properties": {
        "Content-Type": {
          "title": "contentType",
          "type": "string",
          "description": "The MIME type of the body content\n<https://developer.mozilla.org/docs/Web/HTTP/Headers/Content-Type>",
          "enum": [
            "application/json",
            "application/xml",
            "application/x-www-form-urlencoded",
            "application/octet-stream",
            "application/pdf",
            "application/zip",
            "application/vnd.api+json",
            "application/javascript",
            "application/msword",
            "application/vnd.ms-excel",
            "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
            "multipart/form-data",
            "multipart/byteranges",
            "multipart/related",
            "text/plain",
            "text/html",
            "text/css",
            "text/javascript",
            "text/csv",
            "text/markdown",
            "text/xml",
            "image/png",
            "image/jpeg",
            "image/gif",
            "image/svg+xml",
            "image/webp",
            "image/bmp",
            "image/tiff",
            "audio/mpeg",
            "audio/wav",
            "audio/ogg",
            "audio/aac",
            "audio/webm",
            "video/mp4",
            "video/mpeg",
            "video/ogg",
            "video/webm",
            "video/x-msvideo",
            "font/ttf",
            "font/woff",
            "font/woff2"
          ]
        },
        "Accept": {
          "type": "string",
          "description": "Acceptable content types for the response",
          "enum": [
            "application/json",
            "application/xml",
            "application/x-www-form-urlencoded",
            "application/octet-stream",
            "application/pdf",
            "application/zip",
            "application/vnd.api+json",
            "application/javascript",
            "application/msword",
            "application/vnd.ms-excel",
            "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
            "multipart/form-data",
            "multipart/byteranges",
            "multipart/related",
            "text/plain",
            "text/html",
            "text/css",
            "text/javascript",
            "text/csv",
            "text/markdown",
            "text/xml",
            "image/png",
            "image/jpeg",
            "image/gif",
            "image/svg+xml",
            "image/webp",
            "image/bmp",
            "image/tiff",
            "audio/mpeg",
            "audio/wav",
            "audio/ogg",
            "audio/aac",
            "audio/webm",
            "video/mp4",
            "video/mpeg",
            "video/ogg",
            "video/webm",
            "video/x-msvideo",
            "font/ttf",
            "font/woff",
            "font/woff2",
            "*/*"
          ]
        },
        "Authorization": {
          "type": "string",
          "description": "Authentication credentials for the request",
          "default": "'{{.token}}'"
        },
        "Cache-Control": {
          "type": "string",
          "description": "Directives for caching mechanisms in both requests and responses"
        },
        "User-Agent": {
          "type": "string",
          "description": "Information about the user agent originating the request"
        },
        "Content-Length": {
          "type": "string",
          "description": "The size of the request body in octets (8-bit bytes)"
        },
        "Accept-Encoding": {
          "type": "string",
          "description": "The encoding algorithm, usually a compression algorithm, that the client can understand"
        },
        "Accept-Language": {
          "type": "string",
          "description": "The natural languages that are preferred for the response"
        },
        "Connection": {
          "type": "string",
          "description": "Control options for the current connection",
          "enum": [
            "keep-alive",
            "close"
          ]
        },
        "Cookie": {
          "type": "string",
          "description": "Contains stored HTTP cookies previously sent by the server with Set-Cookie"
        },
        "Host": {
          "type": "string",
          "description": "The domain name of the server and the TCP port number on which the server is listening"
        },
        "Origin": {
          "type": "string",
          "description": "Indicates where a fetch originates from"
        },
        "Referer": {
          "type": "string",
          "description": "The address of the previous web page from which a link to the currently requested page was followed"
        },
        "X-Requested-With": {
          "type": "string",
          "description": "Identifies Ajax requests (most JavaScript frameworks send this field with value of XMLHttpRequest)"
        },
        "X-Forwarded-For": {
          "type": "string",
          "description": "A de-facto standard header for identifying the originating IP address of a client connecting through a proxy"
        },
        "X-Forwarded-Proto": {
          "type": "string",
          "description": "A de-facto standard header for identifying the protocol that a client used to connect to a proxy"
        },
        "X-Csrf-Token": {
          "type": "string",
          "description": "Used to prevent cross-site request forgery"
        }
      },
      "additionalProperties": {
        "type": "string"
      }
    },
    "body": {
      "title": "requestBody",
      "type": "object",
      "description": "Request body content\n<https://developer.mozilla.org/docs/Web/API/Request/body>",
      "oneOf": [
        {
          "title": "rawBody",
          "properties": {
            "raw": {
              "type": "string",
              "description": "Raw body content as string"
            }
          },
          "additionalProperties": false,
          "type": "object"
        },
        {
          "properties": {
            "formdata": {
              "type": "object",
              "description": "Form data (multipart/form-data)",
              "additionalProperties": {
                "type": "string"
              }
            }
          },
          "additionalProperties": false,
          "type": "object"
        },
        {
          "properties": {
            "urlencodedformdata": {
              "type": "object",
              "description": "URL encoded form data (application/x-www-form-urlencoded)",
              "additionalProperties": {
                "type": "string"
              }
            }
          },
          "additionalProperties": false,
          "type": "object"
        },
        {
          "properties": {
            "graphql": {
              "type": "object",
              "description": "GraphQL query and variables",
              "required": [
                "query"
              ],
              "properties": {
                "query": {
                  "type": "string",
                  "description": "GraphQL query string",
                  "minLength": 1,
                  "default": "{{getFile `path/to/file.gql`}}"
                },
                "variables": {
                  "type": "object",
                  "description": "GraphQL variables object",
                  "additionalProperties": true
                }
              },
              "additionalProperties": false
            }
          },
          "required": [
            "graphql"
          ],
          "additionalProperties": false,
          "type": "object"
        }
      ]
    },
    "auth": {
      "title": "oauthConfig",
      "type": "object",
      "description": "OAuth 2.0 authentication configuration\n<https://oauth.net/2/>",
      "properties": {
        "type": {
          "title": "authType",
          "type": "string",
          "description": "OAuth 2.0 flow type\n<https://oauth.net/2/grant-types/>",
          "enum": [
            "OAuth2.0"
          ]
        },
        "access_token_url": {
          "title": "tokenUrl",
          "type": "string",
          "description": "Endpoint to obtain the OAuth 2.0 access token\n<https://oauth.net/2/access-tokens/>",
          "format": "uri"
        }
      },
      "additionalProperties": true
    }
  },
  "required": [
    "method",
    "url"
  ],
  "allOf": [
    {
      "if": {
        "properties": {
          "kind": {
            "const": "Auth"
          }
        },
        "required": [
          "kind"
        ],
        "type": "object"
      },
      "then": {
        "required": [
          "auth"
        ],
        "properties": {
          "auth": {
            "title": "oauthConfig",
            "type": "object",
            "description": "OAuth 2.0 authentication configuration\n<https://oauth.net/2/>",
            "properties": {
              "type": {
                "title": "authType",
                "type": "string",
                "description": "OAuth 2.0 flow type\n<https://oauth.net/2/grant-types/>",
                "enum": [
                  "OAuth2.0"
                ]
              },
              "access_token_url": {
                "title": "tokenUrl",
                "type": "string",
                "description": "URL for obtaining the OAuth 2.0 access token\n<https://oauth.net/2/access-tokens/>",
                "format": "uri"
              }
            },
            "required": [
              "type",
              "access_token_url"
            ],
            "additionalProperties": false
          }
        },
        "type": "object"
      }
    }
  ]
}
