﻿# JSON Schema composition: additionalProperties and unevaluatedProperties

Close composed API objects at the intended schema boundary, understand subschema-local additional properties, and verify support for the selected dialect.

Author: Retrivium editorial team
Updated: 2026-11-04
Canonical URL: https://retrivium.ai/journal/guide-schema-allof-unevaluated-properties/
Language: en

## 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](https://json-schema.org/understanding-json-schema/reference/object).

[JSON Schema core evaluation semantics](https://json-schema.org/draft/2020-12/json-schema-core).

[Ajv dialect support](https://ajv.js.org/json-schema.html).

Related explanations: [Schema conformance](/journal/provider-structured-output-conformance-tests/); [Schema conversion boundaries](/journal/llama-cpp-json-schema-gbnf-validation/).
