Skip to content

Conversation

@clemensv
Copy link
Contributor

@clemensv clemensv commented Nov 29, 2025

This PR extends the \$extends\ keyword to support multiple inheritance by accepting an array of JSON Pointers.

Changes

  1. Updated the $extends keyword value to accept either:

    • A single JSON Pointer (current behavior)
    • An array of JSON Pointers (new)
  2. Added collision resolution rule: When multiple base types define properties with the same name, the property from the first base type in the array takes precedence (first-wins).

  3. Added example demonstrating multiple inheritance with \\BaseHeader\\ and \\Metadata\\ abstract types.

Motivation

This enables composition patterns common in other schema languages like CDDL, where types can be composed from multiple base groups using the unwrap operator (\~\).

Compatibility

This is backward-compatible:

  • Existing schemas with single \\\\ values continue to work unchanged
  • Only schemas explicitly using array syntax leverage the new behavior

Fixes #18

Clemens Vasters added 2 commits November 29, 2025 16:52
…itance

- Updated $extends value to accept either a single JSON Pointer or an array
- Added rule for collision resolution: first-wins (properties from earlier
  types in the array take precedence)
- Added example demonstrating multiple inheritance with BaseHeader and Metadata

This enables composition patterns common in other schema languages like CDDL.

Fixes #18
clemensv pushed a commit to json-structure/meta that referenced this pull request Nov 29, 2025
- Added TypeReferenceArray definition for arrays of type references
- Updated $extends in ObjectType, TupleType, and ChoiceType to accept single or array
- Related to json-structure/core#20
@clemensv clemensv merged commit 4b57479 into main Nov 29, 2025
2 checks passed
@clemensv clemensv deleted the issue-18-extends-array branch November 29, 2025 16:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow \ to accept an array of JSON Pointers for multiple inheritance

2 participants