Repository navigation
fix(what-changed): report example edits once and ignore schema type order - #731
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #731 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 316 316
Lines 40280 40239 -41
=========================================
- Hits 40280 40239 -41
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:
|
daveshanley
left a comment
There was a problem hiding this comment.
Deleting 61 lines of sort-and-zip key hashing and replacing them with one call is my favorite kind of diff. Both fixes do what they say for the cases in the tests. I also checked what the new type helper costs on the hot path: 54ns and zero allocs for a two entry array, under 2ns for a scalar type. No complaints.
Two things I want sorted before this goes in. Details and tested replacements are inline.
- The type order fix misses bare
null.type: [null, string]reordered next to a description edit is still a breaking change. - The example fix only covers object values. Array examples and
dataValueobjects still produce a change with nothing in it.
One for the release notes. Adding or removing a member inside an object example used to raise PropertyAdded / PropertyRemoved, and now raises Modified. Anyone running custom breaking rules for example value additions or removals will see different results. I think the new behavior is right. It needs saying out loud.
…code all example values
Changes
valueordataValuechanges. The change carries the complete old and new values for objects and arrays, including a change from one shape to the other. Edits to members use the configured example value modification rule. Adding or removing the whole value still uses the corresponding addition or removal rule.typevalues the way the schema hash reads them. Order is ignored, including members supplied by YAML aliases. A bare YAMLnullis the type namenull, and a single type equals a one entry array. A description edit can now accompany a type reorder without creating a breaking change. Removing or replacing a type still goes through the existing breaking rules.Behavior change
Adding or removing a member inside an object example used to raise
PropertyAddedorPropertyRemoved. It now raisesModified. Custom breaking rules for example value additions and removals now apply only when the whole value is added or removed.Verification
Both regressions failed on the base commit and passed with these fixes. The full Go 1.26.10 suite and the focused race tests passed. A local build of openapi-changes v0.4.4 with this branch produced one JSON entry and one Markdown detail for the example edit, and only a description entry for the reordered types.
The follow-up commit (bare
null, single types, array anddataValueexamples) passed the full suite on Go 1.27.4, withwhat-changed/modelat 100% coverage and the race detector clean onwhat-changedanddatamodel/low/base.Addresses pb33f/openapi-changes#286 and pb33f/openapi-changes#291. The CLI needs a dependency update to ship the fixes.