feat(diff/breaking/changelog/summary): --auto-upgrade for cross-version specs#923
Merged
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #923 +/- ##
==========================================
- Coverage 90.67% 90.65% -0.03%
==========================================
Files 267 267
Lines 16053 16067 +14
==========================================
+ Hits 14556 14565 +9
- Misses 959 962 +3
- Partials 538 540 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
0e0a03a to
3daf0f8
Compare
…on specs When --auto-upgrade is set, both base and revision are canonicalised to the latest OpenAPI 3.x (via the same openapi3conv.Upgrade helper the new 'oasdiff upgrade' subcommand uses) right after load and before diff. This makes cross-version comparisons (e.g. a 3.0 base against a 3.1 revision) produce a meaningful result instead of a noisy diff dominated by dialect-level differences (nullable shape, type arrays, exclusiveMinimum, example/examples). The walker is idempotent on already-canonical specs, so calling it on a same-version pair is a safe no-op. Off by default; opt in per invocation. Applies to diff, breaking, changelog, and summary because all four flow through normalDiff / composedDiff. Tests cover the cross-version-equivalent case (a 3.0 spec and its 3.1 canonical form produce 'No changes detected' under --auto-upgrade) and the same-version idempotency case (output unchanged whether the flag is set or not). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Extend the 'Migrating from 3.0 to 3.1' section with a 'Comparing across versions with --auto-upgrade' subsection covering the new flag on diff/breaking/changelog/summary. Explains the use case (cross-version diff produces dialect-level noise without the flag) and that the walker is idempotent so setting the flag is safe even for same-version pairs.
8fc81fb to
effb23e
Compare
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.
Stacks on top of #922. Once #922 merges to main, this PR rebases onto main automatically and the base flips.
Summary
Adds an
--auto-upgradeflag todiff,breaking,changelog, andsummarythat canonicalises both specs to the latest OpenAPI 3.x before diffing. Solves the cross-version comparison problem (a 3.0 base against a 3.1 revision) which today produces a noisy diff dominated by dialect-level differences.How it works
After both specs are loaded (and before the diff runs), the same
openapi3conv.Upgradehelper introduced in #922 runs on each spec. The walker is idempotent on already-canonical specs, so a same-version pair is a safe no-op (it just bumps the version string).Off by default; opt in per invocation. Default behaviour for all four subcommands is unchanged.
Smoke test (a 3.0 spec vs its 3.1 canonical form)
--auto-upgrade--auto-upgradeNo breaking changes to report, but the specs are different(dialect noise)No changes detectedPlumbing
addCommonDiffFlags(covers all four subcommands).flags.getAutoUpgrade().Configstruct (AutoUpgrade).autoUpgradeSpecs(enabled bool, specs ...*load.SpecInfo)ininternal/upgrade.go.normalDiff(single-spec each side) andcomposedDiff(glob, applies per spec in each set).Tests
Test_AutoUpgradeBreaking_CrossVersionEquivalentNo changes detectedwith--auto-upgradeTest_AutoUpgradeChangelog_CrossVersionEquivalentchangelogTest_AutoUpgradeDiff_SameVersionIsHarmlesssummaryoutput is byte-identical with and without the flagWhat this PR deliberately does NOT do
auto_upgradedfield in JSON/YAML outputs if telemetry shows users want it.--auto-upgradeis opt-in. v2 may promote to default if it tests well.This is step 2 of the OpenAPI 3.1 readiness bundle. Step 1 was #922 (standalone
oasdiff upgrade). Step 3 will be the validate subcommand (PR #894) once the kin replace directive is stripped.