{
 "$defs": {
  "series": {
   "properties": {
    "fetched": {
     "type": "string"
    },
    "freq": {
     "enum": [
      "A",
      "Q",
      "M",
      "D"
     ]
    },
    "key": {
     "type": "string"
    },
    "obs": {
     "items": {
      "items": false,
      "maxItems": 3,
      "minItems": 2,
      "prefixItems": [
       {
        "pattern": "^\\d{4}(?:M(?:0[1-9]|1[0-2])|K[1-4]|-\\d{2}-\\d{2})?$",
        "type": "string"
       },
       {
        "type": "number"
       },
       {
        "enum": [
         "preliminary",
         "revised",
         "final",
         "estimate",
         null
        ]
       }
      ],
      "type": "array"
     },
     "type": "array"
    },
    "sourceId": {
     "type": "string"
    },
    "sourceUrl": {
     "type": "string"
    },
    "unit": {
     "type": "string"
    },
    "updated": {
     "type": "string"
    }
   },
   "required": [
    "key",
    "unit",
    "freq",
    "sourceId",
    "sourceUrl",
    "obs"
   ],
   "type": "object"
  }
 },
 "$id": "https://www.gimstamumas.lt/duomenys/schema-v1.json",
 "$schema": "https://json-schema.org/draft/2020-12/schema",
 "allOf": [
  {
   "if": {
    "properties": {
     "type": {
      "const": "indicator"
     }
    }
   },
   "then": {
    "properties": {
     "series": {
      "additionalProperties": {
       "$ref": "#/$defs/series"
      },
      "type": "object"
     }
    },
    "required": [
     "indicator",
     "unit",
     "frequency",
     "defaultVariant",
     "series",
     "variants",
     "contentSha256"
    ]
   }
  },
  {
   "if": {
    "properties": {
     "type": {
      "const": "municipality"
     }
    }
   },
   "then": {
    "properties": {
     "datasets": {
      "additionalProperties": {
       "properties": {
        "series": {
         "$ref": "#/$defs/series"
        }
       },
       "required": [
        "series"
       ],
       "type": "object"
      },
      "type": "object"
     }
    },
    "required": [
     "municipality",
     "datasets",
     "contentSha256"
    ]
   }
  },
  {
   "if": {
    "properties": {
     "type": {
      "const": "catalog"
     }
    }
   },
   "then": {
    "properties": {
     "indicators": {
      "type": "array"
     },
     "municipalities": {
      "type": "array"
     }
    },
    "required": [
     "publication",
     "indicators",
     "municipalities",
     "statusVocabulary"
    ]
   }
  }
 ],
 "properties": {
  "builtAt": {
   "type": "string"
  },
  "contentSha256": {
   "pattern": "^[0-9a-f]{64}$",
   "type": "string"
  },
  "schemaVersion": {
   "const": 1
  },
  "type": {
   "enum": [
    "indicator",
    "municipality",
    "catalog"
   ]
  }
 },
 "required": [
  "schemaVersion",
  "type",
  "builtAt"
 ],
 "title": "gimstamumas.lt public data contract v1",
 "type": "object"
}
