Skip to main content
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:
This contract proves that the timestamps are individually valid and appear in chronological order. Simile also establishes that order when it synthesizes the object.

What belongs here

Use x-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.
Use ordinary OpenAPI keywords for field-local rules such as 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:
  1. Construction establishes the declared relationships during request or response synthesis.
  2. Proof validates the completed payload after every construction and repair step.
This symmetry matters: an annotation that can only describe an invariant, but cannot participate in construction and proof, is not an executable Simile constraint.

Continue into the grammar

For the end-to-end proof model, read Payload soundness.