Skip to main content

JSON Schema support

This release uses JSON Schema 2020-12 and supports the following subset for generation. A valid schema must also fit within the service’s compilation limits.

Structural values​

FeatureGeneration support
Boolean, null, finite enum and constSupported
Declared object properties and required keysSupported within compiler limits
Bounded arraysSupported within compiler limits
Open strings and numbersSupported with execution token budgets
Numeric bounds over finite choicesSupported
One-sided integer boundsSupported: minimum, maximum and exclusive bounds
Bounds on fractional numbersSupported within compilation and execution limits
Bounded integer rangesSupported when the finite range fits compiler limits
Conditional and composed fieldsSee the keyword coverage below
Local $defs / $refSupported, including recursive definitions within execution limits
Local $dynamicAnchor / $dynamicRefSupported within execution limits
External schema fetchingNot supported; include referenced definitions in the supplied schema
Generated property namesConstrain keys and values with propertyNames, patternProperties and additionalProperties

Numeric bounds apply to integers and fractional numbers. The verified multipleOf forms use finite choices; do not infer support for arbitrary open-number combinations from them.

Conditions and composition​

These constraints apply to the generated output, not directly to request input or application state.

Use enum or const when the initial choices are finite. Conditions can also narrow open strings, for example by applying a different pattern on each branch. Branch constraints must remain compatible with the surrounding schema.

ConstructGeneration coverage
if, then, elseConditional constraints, including nested branches and conditional presence.
dependentRequiredPresence of a declared property requires companion properties; the trigger is presence, not truthiness.
dependentSchemasApply a schema to the enclosing object when a named property is present.
allOfIntersect compatible constraints, including multiple conditional rules and string assertions.
anyOfFinite or open alternatives; one or more branches may match.
oneOfFinite alternatives; exactly one branch must match.
notExclude matching values, types or combinations.

Read Conditional outputs for complete examples of conditional fields and dependencies. Combine constraints covers alternatives and exclusions; Reuse schema definitions covers local references. Compilation and execution limits apply to the complete schema, including nested combinations.

Strings​

ConstraintBehavior
minLength, maxLengthDecoded Unicode character count; character bounds up to 4,096
patternRegular subset: literals, classes, ranges, negation, groups, alternation, repetition, outer anchors and search semantics
Character escapesASCII \d and \w, ECMA whitespace, supported Unicode properties
allOfIntersection of supported string assertions

Backreferences, lookarounds, interior anchors, named groups and inline flags are also supported within service limits. Pattern complexity and combinations with other constraints can exceed compilation or execution limits.

Formats during generation​

date, time, date-time, duration, uuid, ipv4, ipv6, hostname, regex, json-pointer and relative-json-pointer are supported. Format assertions are enabled by default.

Dates obey Gregorian calendar rules. RFC 3339 time and date-time include a timezone, optional fractional seconds and valid offset/leap-second relationships. IPv4 enforces octet ranges without leading-zero octets. JSON pointers enforce valid escapes.

Open generation of email, URI and IRI strings is outside the verified forms documented here. A validator accepting supplied values of a format does not establish generation support.

Execution extensions​

Only these x-runtime annotations are approved in this release:

AnnotationSupported use
formatAssertionsRoot Boolean; enables format assertions by default.
requestSchemaRoot JSON Schema that validates the supplied input, parameters, state and user context before generation.
stateSchemaRoot JSON Schema that validates the resulting state snapshot. It does not validate the initial request.
eligibleWhenA request-context predicate controlling whether a field is allowed. Required fields must retain a legal value.
choicesPer-value eligibleWhen conditions on finite choices.
propertyOrderOn an object schema: an array listing every declared property exactly once, in generation order.
switchOrdered cases with a required default. See switches.
forEach, bindRepeat a template result for each supplied item and bind its constants or descriptions. See for-each loops.
label_permutationsA finite string choice, with {"scope":"/input/responses"} selecting an object whose keys match its enum. Independent fields may use separate scopes; request-level OPA policies are supported.
probabilitiesBoolean on the field: true returns probabilities; false or omission disables them. Works with or without label_permutations. Legacy "all"/"none" remain accepted.

The candidate probabilities guide shows a finite string choice without label permutations. Probability collection preserves ordinary token-by-token selection; it does not replace the answer with the candidate having the highest complete-label probability. See Reduce label bias for the separate permutation setting and its scope rules.

For the finite-choice eligibility shown in the guides, put x-runtime inside the controlled field's schema, alongside type or enum. choices.<value>.eligibleWhen controls whether that value is available. Required fields must retain a legal value.

Eligibility predicates can refer to input, parameters, state and user_context. They cannot depend on the generated output. For example, {"contains":[{"ref":"user_context/scopes"},"documents:publish"]} checks exact scope membership. Missing scopes do not grant that permission. Conditions using state shows each form separately, then combines eligibility with ordinary output conditions. Use state rules in OPA for richer relationships involving generated values.

Attach OPA through request-level policy or policy_id, independently of the output schema, for ordinary generation.

propertyOrder is a Struct extension, not a JSON Schema keyword. For an object declaring category and reason, use "x-runtime":{"propertyOrder":["category","reason"]} to generate the category first. Omitted, repeated or unknown property names are rejected. Without the annotation, properties use lexicographic order. Required and optional properties must both appear in the list; ordering does not make an optional property required. JSON consumers should still access values by key.

Exact source quotations​

Use x-runtime.quote on a string with maxLength from 1 to 4,096 to return an exact contiguous excerpt from request input. Its ref is a JSON Pointer to a string under /input. The number, date, word, identifier, passage and span units are semantic hints; every quoted value is still a string. Unicode spelling, whitespace and punctuation are preserved.

Allow null explicitly when absence is valid. Put the annotation on array items to extract multiple strings, with maxItems no greater than 256. Source membership and the surrounding schema constraints both apply; neither guarantees that the selected information answers the question correctly.

Quote requests can include request-level policy or policy_id. Source membership, supported schema constraints and the policy all apply. The source quoting guide includes a complete extraction example; OPA policies explains how to attach additional rules.

Probability-based branches​

Enable "probabilities": true in the measured field's x-runtime. Put the test at if.x-runtime.probability, with an output-root JSON Pointer in path, an optional typed candidate value, and at least one bound: minimum, maximum, exclusiveMinimum or exclusiveMaximum. Bounds must be finite numbers in [0, 1]. Omitting value tests the selected answer's probability; naming it tests that candidate even when another answer was selected.

A switch uses on.probability with path and optional value; its when comparisons use gte, gt, lte or lt. The switch path is relative to its containing output object, including an item in a bound loop. The decision source must have probability collection enabled. Invalid sources or thresholds are rejected.

Use required Boolean or finite-category decisions as probability sources. The probability branching guide provides complete Boolean examples with finite routes and per-item switches. Standard JSON Schema validators do not evaluate these probability predicates.

Unsupported schemas​

Compilation fails for unsupported constructs or excessive complexity. The service does not silently remove constraints and retry unconstrained. Keep the original error and simplify the schema or select a supported representation.

Strict format checking can be disabled with root "x-runtime":{"formatAssertions":false}. Only use that when formats are intended as annotations rather than guarantees.