We currently embed metadata (hierarchy, aliases, allowSkipLevels, allowSelfRef, rules) in schema ._metadata. This metadata is not validated by JSON Schema and could benefit from explicit validation.
Proposed Options
-
Extend JSON Schema: Create a schema definition that extends the standard JSON Schema to explicitly validate metadata fields while maintaining compatibility with existing JSON Schema validators.
-
Separate metadata file: Create a parallel metadata file (e.g., schema-name.metadata.json) that would be validated independently.
Requirements
- Validate that
hierarchy is a non-empty array of strings
- Validate that
aliases is an object mapping string → string
- Validate that
allowSkipLevels is a boolean (default false)
- Validate that
allowSelfRef is an array of strings
- Validate that
rules follows the RulesMetadata structure (validation/coherence/best-practice arrays)
- Maintain backward compatibility with schemas that don't define all metadata fields
Preference
Per discussion, preference is for Option 1 (extend JSON Schema) to keep metadata and schema in one file, but this requires careful design to avoid breaking JSON Schema validators.
We currently embed metadata (hierarchy, aliases, allowSkipLevels, allowSelfRef, rules) in schema
._metadata. This metadata is not validated by JSON Schema and could benefit from explicit validation.Proposed Options
Extend JSON Schema: Create a schema definition that extends the standard JSON Schema to explicitly validate metadata fields while maintaining compatibility with existing JSON Schema validators.
Separate metadata file: Create a parallel metadata file (e.g.,
schema-name.metadata.json) that would be validated independently.Requirements
hierarchyis a non-empty array of stringsaliasesis an object mapping string → stringallowSkipLevelsis a boolean (default false)allowSelfRefis an array of stringsrulesfollows the RulesMetadata structure (validation/coherence/best-practice arrays)Preference
Per discussion, preference is for Option 1 (extend JSON Schema) to keep metadata and schema in one file, but this requires careful design to avoid breaking JSON Schema validators.