{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://schemas.apps.smartmate.io/processes/serviceTasks/httpRequest/httpRequest.schema.json",
  "$$target": "https://schemas.apps.smartmate.io/processes/serviceTasks/httpRequest/httpRequest.schema.json",
  "title": "httpRequest",
  "description": "HTTP Request Service Task allows to perform HTTP(S) calls, and map results of the response back to fields or variables.",
  "allOf": [{"$ref": "https://schemas.apps.smartmate.io/processes/serviceTasks/_base/_baseServiceTask.schema.json"}],
  "properties": {
    "name": {},
    "retries": {},
    "mapping": {},
    "type": {
      "description": "Must be ``httpRequest``",
      "type": "string",
      "enum": ["httpRequest"]
    },
    "method": {
      "type": "string",
      "description": "Defines the method to use",
      "enum": ["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS", "HEAD"]
    },
    "url": {
      "type": "string",
      "description": "The URL. Fields, variables or secrets can be used (using double curly braces).",
      "examples": ["https://example.com/my-endpoint/{{_vars.myVariable}}"]
    },
    "query": {
      "type": "object",
      "description": " Key/Value pairs for the query string. Fields, variables or secrets can be used (using double curly braces).",
      "propertyNames": {
        "type": "string"
      },
      "patternProperties": {
        "": {
          "type": "string"
        }
      }
    },
    "headers": {
      "type": "object",
      "description": "key/value pairs of the headers to be sent to the request. Fields, variables or secrets can be used (using double curly braces).",
      "propertyNames": {
        "type": "string"
      },
      "patternProperties": {
        "": {
          "type": "string"
        }
      }
    },
    "body": {
      "description": "The body to be sent in the HTTP Request. Fields, variables or secrets can be used (using double curly braces).",
      "oneOf": [
        {
          "description": "It can be a string.",
          "type": "string"
        },
        {
          "type": "object",
          "description": "It can be an object, in which case, it will be sent as form data.",
          "propertyNames": {
            "type": "string"
          },
          "patternProperties": {
            "": {
              "type": "string"
            }
          }
        }
      ]
    }
  },
  "required": [ "type", "url" ],
  "additionalProperties": false
}
