How to understand the structure of schemaDir files?

I think that you might be looking at an old (very old?) version of JSON schema RFC.

This is no longer present in the current version. Instead, the resolution of $ref values is described in detail in JSON Schema RFC (2020-12) section 7.7.1.1: JSON Schema: A Media Type for Describing JSON Documents

In short, the $ref works like a set of defaults. For example, looking at the mentioned tracker.json file:

{
  // removed shortcuts and metadata for brevity
  "title": "Notebook",
  "description": "Notebook settings.",
  "definitions": {
    "editorConfig": {
      "properties": {
        "autoClosingBrackets": {
          "type": "boolean"
        },
        "tabSize": {
          "type": "number"
        }
        // other properties follow
      },
      "additionalProperties": false,
      "type": "object"
    }
  },
  "properties": {
    "codeCellConfig": {
      "title": "Code Cell Configuration",
      "description": "The configuration for all code cells.",
      "$ref": "#/definitions/editorConfig",
      "default": {
        "autoClosingBrackets": true,
        "tabSize": 4
      }
    },
    // other properties follow
  },
  "additionalProperties": false,
  "type": "object"
}

codeCellConfig inherits type (object), additionalProperties (false) and properties (presets for autoClosingBrackets, tabSize) from $ref; they do not have defaults set in $ref so the defaults get defined on codeCellConfig level: autoClosingBrackets gets default true, while tabSize default is set to 4. This way different editors can share the same setting types but different defaults.

Does it help?

1 Like