{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "pieces.schema.json",
  "title": "Pieces: work keys with titles, composers and every source and folio where the piece appears",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "generated",
    "pieces"
  ],
  "properties": {
    "generated": {
      "type": "string",
      "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$"
    },
    "note": {
      "type": "string"
    },
    "pieces": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "work",
          "title",
          "composers",
          "sources"
        ],
        "properties": {
          "work": {
            "type": "string",
            "pattern": "^[a-z0-9]+(-[a-z0-9]+)*$"
          },
          "title": {
            "type": "string",
            "minLength": 1
          },
          "altTitles": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "composers": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "name"
              ],
              "properties": {
                "name": {
                  "type": "string"
                },
                "wikidata": {
                  "type": "string"
                },
                "slug": {
                  "type": "string"
                }
              }
            }
          },
          "genres": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "sharesTextWith": {
            "type": "array",
            "items": {
              "type": "string",
              "pattern": "^[a-z0-9]+(-[a-z0-9]+)*$"
            }
          },
          "sources": {
            "type": "array",
            "minItems": 1,
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "slug",
                "folio"
              ],
              "properties": {
                "slug": {
                  "type": "string"
                },
                "folio": {
                  "type": "string"
                },
                "title": {
                  "type": "string"
                },
                "canvas": {
                  "type": "string"
                },
                "locus": {
                  "type": "string"
                },
                "number": {
                  "type": [
                    "integer",
                    "string"
                  ]
                },
                "source": {
                  "type": "string"
                }
              }
            }
          },
          "reportedConcordances": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "label",
                "source"
              ],
              "properties": {
                "label": {
                  "type": "string"
                },
                "folio": {
                  "type": "string"
                },
                "slug": {
                  "type": "string"
                },
                "inSource": {
                  "type": "string"
                },
                "source": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    }
  }
}
