Merge allof object schemas for reading - #78
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.