Skip to content

fix(what-changed): report example edits once and ignore schema type order - #731

Merged
daveshanley merged 4 commits into
mainfrom
codex/example-value-and-schema-type-diffs
Nov 26, 2026
Merged

daveshanley merged 4 commits into
mainfrom
codex/example-value-and-schema-type-diffs

Conversation

@daveshanley

@daveshanley daveshanley commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

Changes

  • Report one modification when an existing example value or dataValue changes. 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.
  • Compare schema type values the way the schema hash reads them. Order is ignored, including members supplied by YAML aliases. A bare YAML null is the type name null, 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 PropertyAdded or PropertyRemoved. It now raises Modified. 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 and dataValue examples) passed the full suite on Go 1.27.4, with what-changed/model at 100% coverage and the race detector clean on what-changed and datamodel/low/base.

Addresses pb33f/openapi-changes#286 and pb33f/openapi-changes#291. The CLI needs a dependency update to ship the fixes.

@daveshanley
daveshanley marked this pull request as ready for review November 25, 2026 16:37
@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 (b9309bc) to head (03be841).
⚠️ Report is 1 commits behind head on main.

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     
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 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.

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.

  1. The type order fix misses bare null. type: [null, string] reordered next to a description edit is still a breaking change.
  2. The example fix only covers object values. Array examples and dataValue objects 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.

Comment thread what-changed/model/schema.go Resolved
Comment thread what-changed/model/schema_test.go Resolved
Comment thread what-changed/model/example.go Resolved
@daveshanley
daveshanley merged commit ef96408 into main Nov 26, 2026
8 checks passed
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