Skip to content

Compare standalone JSON Schema resources and collections - #732

Open
daveshanley wants to merge 27 commits into
mainfrom
codex/native-json-schema
Open

daveshanley wants to merge 27 commits into
mainfrom
codex/native-json-schema

Conversation

@daveshanley

@daveshanley daveshanley commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

Behaviour changes

Expose jsonschema.Load, LoadCollection, MatchResources, and Compare for Draft 2020-12 object and boolean schemas. Sources retain their own dialect, index, coordinates and reference edges. Match by resolved ID first, then by authored location. A shared definition is compared once for all its users. The public report contains its resource ID, local path, and the source for each side.

Use the existing low-level schema model and comparator for keyword changes. Newly exposed schema entry points apply directional defaults and explicit overrides. Schema resources with unsupported required vocabularies or references that need dynamic scope produce a diagnostic.

API detection now exposes datamodel.ErrUnsupportedSpecType; the previous diagnostic text is preserved. Inputs are checked against the bundled Draft 2020-12 meta-schema. Native reports preserve structured JSON values, exact numeric constraints, resolved reference targets, and original and modified resource files even for one-sided keyword edits.

dependentRequired members keep their authored names and locations, including schemaDialect and $schema. Resolution errors retain the source line while omitting credentials and signed query values. Native Windows filenames keep their basename under a configured base URL.

Verification

Ran go test ./... -count=1, go test -race ./jsonschema -count=1, and go vet ./jsonschema. The shared-reference benchmark reports one target edit for 2, 100, and 1,000 incoming references. At 1,000 uses the comparison took 0.39 ms and 338 kB on an M4 Max.

The Go 1.26 Linux suite executed all 33,107 instrumented statements on this branch. The CLI also produced distinct paths, values, and hashes for two dependencies named schemaDialect and $schema.

For 8,000 consecutive properties with identical schemas, native validation allocations fell from 57.7 MB to 17.4 MB. Invalid repeated members retain their individual diagnostic paths.

Downstream integration exercised all five openapi-changes commands on the Customer and Money fixtures, including full and lite HTML source navigation.

@blacksmith-sh

This comment has been minimized.

@codecov

codecov Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (1a94cbd) to head (18eb810).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##              main      #732     +/-   ##
===========================================
  Coverage   100.00%   100.00%             
===========================================
  Files          316       323      +7     
  Lines        40259     41504   +1245     
===========================================
+ Hits         40259     41504   +1245     
Flag Coverage Δ
unittests 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@daveshanley
daveshanley force-pushed the codex/native-json-schema branch from a8c5a3f to 3b07cb1 Compare November 26, 2026 15:30

@daveshanley daveshanley left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Read the lot and hammered the comparator with about fifty scratch pairs.

The core holds up. Polarity through not, oneOf and reference usage came out right everywhere I poked. Output was identical across 200 runs of the same comparison. Reordered oneOf operands stay quiet, and 1 against 1.0 is correctly nothing.

The inline notes are the rough edges. Two I'd fix before this gets a tag: the rules contract on Compare, and $schema showing up as a breaking change.

Comment thread jsonschema/compare.go Resolved
Comment thread jsonschema/compare.go Resolved
Comment thread jsonschema/compare.go Resolved
Comment thread jsonschema/compare.go Resolved
Comment thread jsonschema/compare.go Resolved
Comment thread jsonschema/document.go Resolved
Comment thread jsonschema/document.go Resolved
Comment thread jsonschema/reference.go Resolved
Comment thread datamodel/schema_node.go Resolved
Comment thread jsonschema/document.go Resolved
Declaring the dialect and removing a widening applicator no longer report as breaking. Out-of-range numeric bounds are compared without expansion. Load errors name their file, earlier-draft keywords in an unmarked schema are rejected, and a failed collection member is a typed MemberError.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
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