TECHNOLOGY

JSON Schema composition: additionalProperties and unevaluatedProperties

In this article
THE QUICK TAKE

Combining schemas does not turn every property declaration into one flat inheritance hierarchy or automatically close nested objects.

Composition validates constraints together

An API can compose a shared configuration schema with model-specific settings. The resulting document may look like an extended class, but JSON Schema composition evaluates constraints rather than inheriting and flattening fields in the object-oriented sense.

This matters when a shared object is already closed to additional properties. A new declaration in another subschema does not necessarily become an allowed field under that earlier closure. An apparently additive model parameter can therefore make the composed object invalid.

Additional properties are local to a subschema

The JSON Schema object guide explains that additionalProperties recognizes property declarations within the same subschema. Combining another declaration with allOf does not automatically expand that local set of known properties.

A proposed review examines where closure is applied, not just whether the keyword occurs somewhere. Moving the restriction or deliberately redeclaring shared properties changes the accepted population. Do not hide that choice inside an automatic schema merge that produces a different contract from the published components.

Unevaluated properties track successful evaluation

The newer unevaluatedProperties mechanism can account for properties successfully evaluated through relevant subschemas. It supports composition patterns that otherwise require redeclaring properties. Its behavior depends on evaluation, not simply collecting every name appearing anywhere in the schema text.

For conditional model options, that distinction is useful. A property allowed by a successful condition should not become globally accepted merely because its name exists in an inactive branch. A consumer needs the actual dialect’s evaluation semantics rather than a text-based union of field names.

The dialect and validator must agree

Ajv documents different JSON Schema version support and a separate class for the newer dialect. A keyword valid in one dialect is not evidence that an older validator enforces it. A schema can remain parseable while losing the intended closure behavior in an incompatible tool.

Preserve the declared dialect and validator configuration with any compatibility result. Generated clients and documentation renderers may support a different subset from the server validator. Their ability to display the schema does not prove agreement about which extra fields are rejected.

Nested objects need their own boundary

Closing an outer configuration object does not recursively close every nested settings object. Decide independently whether each nested structure is extensible, closed or constrained by a composed rule. That decision affects future parameter additions and typo handling.

A proposed review includes shared fields, extension fields, inactive conditional fields and unexpected nested members. It explains the accepted object boundary without claiming that a single closed keyword provides inheritance, recursive closure or identical behavior across every schema consumer.

Primary references

JSON Schema object composition guide.

JSON Schema core evaluation semantics.

Ajv dialect support.

Related explanations: Schema conformance; Schema conversion boundaries.

Earn rental income from GPUs

Have idle GPUs or looking to fund AI infrastructure? Retrivium finds a rental platform, sets up the server and helps you assess income and costs with a pilot.

Explore GPU hosting
← All articles