{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "OpenWorld Format YAML file",
  "description": "One file of a YAML world folder: either world.yaml (world metadata) or one object, with contained objects nested in `contents`. See SPEC.md §14.2.",
  "oneOf": [
    { "$ref": "world.schema.json#/$defs/meta-file" },
    { "$ref": "#/$defs/file-object" }
  ],

  "$defs": {
    "contents": {
      "type": "array",
      "description": "Objects whose parent is the object they are nested in: contained objects, or the nodes and sub-quests of a quest.",
      "items": { "$ref": "#/$defs/nested-object" }
    },

    "file-object": {
      "$ref": "world.schema.json#/$defs/object",
      "properties": {
        "$schema": { "type": "string" },
        "contents": { "$ref": "#/$defs/contents" }
      },
      "unevaluatedProperties": false
    },

    "nested-object": {
      "$ref": "world.schema.json#/$defs/nestable",
      "not": { "required": ["parent"] },
      "properties": {
        "contents": { "$ref": "#/$defs/contents" }
      },
      "unevaluatedProperties": false
    }
  }
}
