Repository navigation
Compare standalone JSON Schema resources and collections - #732
daveshanley wants to merge 27 commits into
Conversation
This comment has been minimized.
This comment has been minimized.
Codecov Report✅ All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
a8c5a3f to
3b07cb1
Compare
daveshanley
left a comment
There was a problem hiding this comment.
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.
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]>
Behaviour changes
Expose
jsonschema.Load,LoadCollection,MatchResources, andComparefor 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.dependentRequiredmembers keep their authored names and locations, includingschemaDialectand$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, andgo 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
schemaDialectand$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.