x-simile-constraints describes relationships that ordinary OpenAPI keywords cannot express
inside a single payload. It turns cross-field invariants into executable contract: Simile uses the
same declaration both to construct sound payloads and to reject payloads that violate the declared
relationship.
Place the extension on the object schema whose values participate in the relationship:
What belongs here
Usex-simile-constraints for public relationships among two or more values in the same document:
- ordering and relative bounds;
- equality, uniqueness, and scalar-set relationships;
- conditional presence or values;
- arithmetic equations and collection aggregates;
- lifecycle states and their associated timestamps; and
- strings derived from other public fields.
required, enum, minimum,
maxLength, oneOf, and format. Use
x-simile-from-request when the relationship crosses from an
operation request into its response.
Clause families
Compilation and proof
Simile resolves every selector against the schema while compiling the service. Invalid paths, incompatible types, contradictory clauses, and unsupported operators fail compilation instead of being ignored. At runtime, the compiled clauses have two responsibilities:- Construction establishes the declared relationships during request or response synthesis.
- Proof validates the completed payload after every construction and repair step.
Continue into the grammar
- Constraint mechanics covers placement, JSON Pointers, selectors, and authoring rules.
- Value relationships covers ordering, bounds, equality, uniqueness, and sets.
- Conditional and derived values covers implications, equations, and aggregates.
- Lifecycles and templates covers state transitions and rendered strings.