{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/newcastle/json-schema/newcastle-filters-schema.json",
  "title": "Filters",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/newcastle-items-api-openapi.yml#/components/schemas/Filters",
  "type": "object",
  "properties": {
    "options": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/FilterOption"
      }
    },
    "_links": {
      "type": "object",
      "properties": {
        "reset": {
          "$ref": "#/$defs/HateoasLink"
        }
      }
    }
  },
  "required": [
    "options",
    "_links"
  ],
  "$defs": {
    "Facet": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "count": {
          "type": "number"
        },
        "_links": {
          "type": "object",
          "properties": {
            "activate": {
              "$ref": "#/$defs/HateoasLink"
            },
            "deactivate": {
              "$ref": "#/$defs/HateoasLink"
            }
          }
        }
      },
      "required": [
        "id",
        "name",
        "count"
      ]
    },
    "FilterOption": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "active": {
          "type": [
            "array",
            "null"
          ],
          "items": {
            "allOf": [
              {
                "$ref": "#/$defs/FilterValue"
              },
              {
                "type": "object",
                "properties": {
                  "_links": {
                    "type": "object",
                    "properties": {
                      "deactivate": {
                        "$ref": "#/$defs/HateoasLink"
                      }
                    },
                    "required": [
                      "deactivate"
                    ]
                  }
                },
                "required": [
                  "_links"
                ]
              }
            ],
            "$ref": "#/$defs/FilterValue"
          }
        },
        "facets": {
          "type": [
            "array",
            "null"
          ],
          "items": {
            "allOf": [
              {
                "$ref": "#/$defs/Facet"
              }
            ]
          }
        },
        "_links": {
          "type": "object",
          "properties": {
            "reset": {
              "$ref": "#/$defs/HateoasLink"
            }
          }
        }
      },
      "required": [
        "id",
        "name",
        "active",
        "facets",
        "_links"
      ]
    },
    "FilterValue": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "_links": {
          "type": "object",
          "properties": {
            "activate": {
              "$ref": "#/$defs/HateoasLink"
            },
            "deactivate": {
              "$ref": "#/$defs/HateoasLink"
            }
          }
        }
      },
      "required": [
        "id",
        "name",
        "_links"
      ]
    },
    "HateoasLink": {
      "type": "object",
      "properties": {
        "href": {
          "type": "string"
        },
        "type": {
          "type": "string",
          "enum": [
            "GET",
            "POST",
            "PUT",
            "DELETE"
          ]
        },
        "parameters": {
          "$ref": "#/$defs/HateoasParameters"
        }
      },
      "required": [
        "href",
        "type"
      ]
    },
    "HateoasParameters": {
      "type": "object",
      "additionalProperties": true,
      "description": "Any relevant parameters that should be appended to the URL (for GET method) or passed as a payload for other HTTP methods."
    }
  }
}