{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "CDIF Concept Scheme",
  "description": "Profile module for SKOS concept schemes used as controlled vocabularies in CDIF metadata. Thin wrapper around skosConceptScheme.",
  "type": "object",
  "properties": {
    "@context": {
      "description": "JSON-LD context declaring the skos namespace prefix and any additional prefixes used in concept URIs. May be a single object or an array of strings and objects.",
      "type": "object",
      "properties": {
        "skos": {
          "const": "http://www.w3.org/2004/02/skos/core#"
        }
      },
      "required": [
        "skos"
      ]
    },
    "@id": {
      "type": "string",
      "description": "URI identifier for this concept scheme."
    },
    "@type": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "contains": {
        "const": "skos:ConceptScheme"
      },
      "minItems": 1
    },
    "skos:prefLabel": {
      "description": "Preferred lexical label for the concept scheme. A single string, a single language-tagged value, or an array of language-tagged values. Each language should appear at most once.",
      "anyOf": [
        {
          "type": "string"
        },
        {
          "$ref": "#/$defs/LanguageTaggedValue"
        },
        {
          "type": "array",
          "items": {
            "$ref": "#/$defs/LanguageTaggedValue"
          }
        }
      ]
    },
    "skos:altLabel": {
      "description": "Alternative lexical labels (acronyms, abbreviations, spelling variants).",
      "anyOf": [
        {
          "type": "string"
        },
        {
          "$ref": "#/$defs/LanguageTaggedValue"
        },
        {
          "type": "array",
          "items": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "$ref": "#/$defs/LanguageTaggedValue"
              }
            ]
          }
        }
      ]
    },
    "skos:definition": {
      "description": "Formal explanation of the meaning or purpose of this concept scheme.",
      "anyOf": [
        {
          "type": "string"
        },
        {
          "$ref": "#/$defs/LanguageTaggedValue"
        },
        {
          "type": "array",
          "items": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "$ref": "#/$defs/LanguageTaggedValue"
              }
            ]
          }
        }
      ]
    },
    "skos:notation": {
      "description": "Classification code or notation for this concept scheme.",
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "skos:note": {
      "description": "General note about the concept scheme.",
      "anyOf": [
        {
          "type": "string"
        },
        {
          "$ref": "#/$defs/LanguageTaggedValue"
        },
        {
          "type": "array",
          "items": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "$ref": "#/$defs/LanguageTaggedValue"
              }
            ]
          }
        }
      ]
    },
    "skos:hasTopConcept": {
      "description": "Top-level concepts in this scheme. Each item is a skos:Concept (inline or @id reference).",
      "type": "array",
      "minItems": 1,
      "items": {
        "anyOf": [
          {
            "$ref": "#/$defs/cdifConcept"
          },
          {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "@id": {
                "type": "string",
                "description": "URI reference to a concept defined elsewhere"
              }
            },
            "required": [
              "@id"
            ]
          }
        ]
      }
    },
    "schema:version": {
      "description": "Version identifier for the concept scheme.",
      "type": [
        "string",
        "number"
      ]
    },
    "schema:subjectOf": {
      "description": "Catalog record describing this concept scheme as CDIF-conformant metadata. Must declare conformance to the cdifConceptScheme profile via dcterms:conformsTo and be typed as schema:Dataset with schema:additionalType including dcat:CatalogRecord.",
      "type": "object",
      "properties": {
        "@type": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "contains": {
            "const": "schema:Dataset"
          },
          "minItems": 1
        },
        "schema:additionalType": {
          "type": "array",
          "items": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "@id"
                ],
                "properties": {
                  "@id": {
                    "type": "string"
                  }
                }
              }
            ]
          },
          "contains": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "@id"
            ],
            "properties": {
              "@id": {
                "const": "dcat:CatalogRecord"
              }
            }
          },
          "minItems": 1
        },
        "dcterms:conformsTo": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "@id": {
                "type": "string"
              }
            },
            "required": [
              "@id"
            ]
          },
          "contains": {
            "type": "object",
            "required": [
              "@id"
            ],
            "additionalProperties": false,
            "properties": {
              "@id": {
                "const": "https://w3id.org/cdif/conceptscheme/1.1"
              }
            }
          },
          "minItems": 1
        },
        "@id": {
          "type": "string",
          "description": "Identifier for the catalog record."
        },
        "schema:about": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "@id": {
              "type": "string"
            }
          },
          "required": [
            "@id"
          ]
        }
      },
      "required": [
        "@type",
        "schema:additionalType",
        "dcterms:conformsTo"
      ]
    }
  },
  "required": [
    "@type",
    "skos:prefLabel",
    "skos:definition",
    "skos:hasTopConcept"
  ],
  "$defs": {
    "LanguageTaggedValue": {
      "type": "object",
      "description": "An RDF literal value with a language tag, serialized as a JSON-LD value object. Inlined from skosConcept (the resolver does not preserve cross-file '#/$defs/...' fragment refs).",
      "properties": {
        "@value": {
          "type": "string",
          "description": "The text content."
        },
        "@language": {
          "type": "string",
          "description": "BCP 47 language tag (e.g. en, fr, de)."
        }
      },
      "required": [
        "@value"
      ]
    },
    "cdifConcept": {
      "type": "object",
      "properties": {
        "@context": {
          "description": "JSON-LD context declaring the skos namespace prefix. May be a single object or an array of strings and objects.",
          "type": "object",
          "properties": {
            "skos": {
              "const": "http://www.w3.org/2004/02/skos/core#"
            }
          },
          "required": [
            "skos"
          ]
        },
        "@id": {
          "type": "string",
          "description": "URI identifier for this concept."
        },
        "@type": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "contains": {
            "const": "skos:Concept"
          },
          "minItems": 1
        },
        "skos:prefLabel": {
          "description": "Preferred lexical label for this concept. A single string, a single language-tagged value, or an array of language-tagged values. Each language should appear at most once.",
          "anyOf": [
            {
              "type": "string"
            },
            {
              "$ref": "#/$defs/LanguageTaggedValue"
            },
            {
              "type": "array",
              "items": {
                "$ref": "#/$defs/LanguageTaggedValue"
              }
            }
          ]
        },
        "skos:notation": {
          "description": "Classification code for this concept within a scheme (a single notation string, consistent with CdifCodelistConcept).",
          "type": "string"
        },
        "skos:definition": {
          "description": "Formal explanation of the meaning of this concept.",
          "anyOf": [
            {
              "type": "string"
            },
            {
              "$ref": "#/$defs/LanguageTaggedValue"
            },
            {
              "type": "array",
              "items": {
                "anyOf": [
                  {
                    "type": "string"
                  },
                  {
                    "$ref": "#/$defs/LanguageTaggedValue"
                  }
                ]
              }
            }
          ]
        },
        "skos:note": {
          "description": "General note about this concept.",
          "anyOf": [
            {
              "type": "string"
            },
            {
              "$ref": "#/$defs/LanguageTaggedValue"
            },
            {
              "type": "array",
              "items": {
                "anyOf": [
                  {
                    "type": "string"
                  },
                  {
                    "$ref": "#/$defs/LanguageTaggedValue"
                  }
                ]
              }
            }
          ]
        },
        "skos:inScheme": {
          "description": "Concept scheme(s) this concept belongs to.",
          "anyOf": [
            {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "@id": {
                  "type": "string"
                }
              },
              "required": [
                "@id"
              ]
            },
            {
              "type": "array",
              "items": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "@id": {
                    "type": "string"
                  }
                },
                "required": [
                  "@id"
                ]
              }
            }
          ]
        },
        "skos:broader": {
          "description": "Broader (parent) concepts in the hierarchy. Items are inline concept objects or @id references.",
          "type": "array",
          "items": {
            "anyOf": [
              {
                "type": "object",
                "additionalProperties": false,
                "description": "Reference (by URI) to a skos:Concept defined elsewhere. Used inside skos:broader / skos:narrower as the @id-reference alternative to an inline Concept.",
                "properties": {
                  "@id": {
                    "type": "string",
                    "description": "URI of the referenced concept."
                  }
                },
                "required": [
                  "@id"
                ]
              },
              {
                "$ref": "#/$defs/cdifConcept"
              }
            ]
          }
        },
        "skos:narrower": {
          "description": "Narrower (child) concepts in the hierarchy. Items are inline concept objects or @id references.",
          "type": "array",
          "items": {
            "anyOf": [
              {
                "type": "object",
                "additionalProperties": false,
                "description": "Reference (by URI) to a skos:Concept defined elsewhere. Used inside skos:broader / skos:narrower as the @id-reference alternative to an inline Concept.",
                "properties": {
                  "@id": {
                    "type": "string",
                    "description": "URI of the referenced concept."
                  }
                },
                "required": [
                  "@id"
                ]
              },
              {
                "$ref": "#/$defs/cdifConcept"
              }
            ]
          }
        }
      },
      "required": [
        "@type",
        "skos:prefLabel"
      ]
    }
  }
}
