Skip to content

Merge allof object schemas for reading - #78

Merged
noha merged 3 commits into
masterfrom
merge-allof-object-schemas-for-reading
Aug 1, 2026
Merged

Merge allof object schemas for reading#78
noha merged 3 commits into
masterfrom
merge-allof-object-schemas-for-reading

Conversation

@noha

@noha noha commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

No description provided.

noha and others added 3 commits August 1, 2026 16:34
JSONPrimitiveSchema>>read: called every attached constraint's
validate: unconditionally, unlike JSONSchema>>validate: which
correctly selects constraints by validateType: first. Found via
allOf-merge testing (JSONSchema fromString: '{"type":"integer",
"format":"int64"}'; readString: '42'): JSONSchemaFormatConstraint>>
validateType: correctly says format only applies to strings, but its
validate: still ran on the parsed Integer, crashing with
doesNotUnderstand: #readStream inside format validateString:. Affects
any numeric format (int32/int64/float/double) on read, independent of
allOf.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
A bare allOf composition of object schemas (no direct type/properties
keyword - the common "extends" pattern, e.g. OpenAPI's
Pet = allOf[NewPet, {id}]) resolves to JSONSchemaAnyObject via
JSONSchemaDefinition>>asJSONSchema, since nothing sets schemaClass for
a bare allOf. Validation already worked correctly (JSONSchemaAllOfConstraint
resolves and validates each branch), but reading was a raw passthrough
(readUsing: just did aReader next) - every field arrived as unconverted
JSON data in a plain Dictionary, with no per-property type coercion, no
merged required-property checking, and no typed NeoJSONObject result.

Added JSONSchemaAnyObject>>mergedAllOfObjectSchema, mirroring how
JSONSchemaAllOfConstraint already resolves $ref branches lazily via its
own resolveVisitor/schemaRepository at use time (construction time is
too early - allOf branches may still be unresolved References). When
all branches resolve to JSONSchemaObject, their properties/required/
additionalProperties/instanceClass are merged into one real
JSONSchemaObject (cached on first use), and read:/readUsing: delegate
to it. A mixed/primitive allOf (not all branches object-shaped) has no
sensible single merge target and keeps the existing raw-passthrough
behavior unchanged.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
4 new tests: numeric format reading no longer crashes, allOf-of-objects
merges properties and required across branches for reading, and a
mixed/primitive allOf correctly falls back to the unchanged raw
passthrough. 120/120 JSONSchema-Core-Tests, 0 regressions
(JSONSchema-Testsuite-Tests unchanged at 940/1020).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@noha
noha merged commit ec4a68d into master Aug 1, 2026
3 of 4 checks passed
@noha
noha deleted the merge-allof-object-schemas-for-reading branch August 1, 2026 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant