Skip to content

Clarify inline choice inheritance and injected selector semantics #34

Description

@clemensv

Problem

Core currently leaves the normative model for inline choices internally inconsistent and underspecified.

The inline-union section says:

  • the presence of $extends on a choice selects the inline representation;
  • $extends refers to a common abstract base;
  • all alternatives extend that common base;
  • selector names an injected string property;
  • the injected property may shadow a string property of the base.

The generic $extends rules, however, say that $extends may only be used on object and tuple, excluding choice.

The text also does not define how the injected selector participates in the effective selected object schema. This matters for additionalProperties, required, property-count constraints, dependencies, composition, and constraints on a shadowed base property.

This ambiguity was exposed by json-structure/sdk#184.

Decisions required

  1. Confirm that $extends is valid on choice and is the sole switch between tagged and inline representations.
  2. State whether every alternative must independently extend the common base, or whether the choice-level $extends implicitly applies the base to each alternative.
  3. Define the effective selector property schema. At minimum, its value is a string equal to one key in choices.
  4. Define how selector shadowing combines with constraints declared by the base property.
  5. Define whether the selector counts for object-level constraints such as minProperties and maxProperties.
  6. Define how the injected selector interacts with additionalProperties: false or a schema-valued additionalProperties on the selected alternative.

Acceptance criteria

  • The inline-choice and generic $extends sections agree.
  • A conforming inline-choice example uses a closed selected object and demonstrates selector handling.
  • Invalid combinations of $extends, selector, abstract bases, and alternatives are stated explicitly.
  • The Core meta-schema is updated to enforce the resulting rules where representable.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions