fix(diff): detect breaking changes in path-item-level parameters (rescued from stale branch)#38
Merged
Conversation
Per the OpenAPI spec, parameters declared on a path item apply to every operation under it. Previously these were ignored when comparing specs, causing a false-green gate result when path-level required parameters were removed. Changes: - Add _param_key() for consistent parameter identity hashing - Add _effective_parameters() to merge path-item and operation params - Update _diff_operations() to use effective merged parameters - Update _diff_operation_details() to accept pre-merged param lists
c3aadc3 to
c361876
Compare
🤖 Automated Code Review✅ Ruff Lint — No issues
|
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.
Rescues an unmerged bug fix that was sitting on the stale branch
cowork/improve-api-contract-guardian(flagged in #36). The fix is still relevant —maindoes not currently merge path-item-level parameters.The bug
Per the OpenAPI spec,
parametersdeclared on a path item apply to every operation under it. The current diff engine only inspects operation-level parameters (old_op.get("parameters", [])in_diff_operation_details), so a breaking change to a path-item-level parameter (e.g. removing a requiredheaderparameter declared at path scope) is not detected — producing a false-green gate. For a contract-diffing tool this is a correctness/safety bug.The fix
Adds
_effective_parameters()to merge path-item-level parameters with operation-level ones (operation-level overrides on matching(name, in)), plus_param_key()for stable identity (including$refparams). Includes 130 lines of new tests inTestPathLevelParameterDiff.Note for reviewer
This branch was authored ~2 weeks ago and is behind
main, which has since refactored_diff_operations→_diff_operation_details. It may need a rebase / conflict resolution before merge — please review the wiring of_effective_parametersinto the current operation-diff path. Opening as a PR so the fix is tracked and reviewable rather than lost on a dangling branch.