Skip to content

fix(diff): detect breaking changes in path-item-level parameters (rescued from stale branch)#38

Merged
Coding-Dev-Tools merged 1 commit into
mainfrom
cowork/improve-api-contract-guardian
Jun 29, 2026
Merged

fix(diff): detect breaking changes in path-item-level parameters (rescued from stale branch)#38
Coding-Dev-Tools merged 1 commit into
mainfrom
cowork/improve-api-contract-guardian

Conversation

@Coding-Dev-Tools

Copy link
Copy Markdown
Owner

Rescues an unmerged bug fix that was sitting on the stale branch cowork/improve-api-contract-guardian (flagged in #36). The fix is still relevantmain does not currently merge path-item-level parameters.

The bug

Per the OpenAPI spec, parameters declared 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 required header parameter 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 $ref params). Includes 130 lines of new tests in TestPathLevelParameterDiff.

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_parameters into the current operation-diff path. Opening as a PR so the fix is tracked and reviewable rather than lost on a dangling branch.

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
@Coding-Dev-Tools Coding-Dev-Tools force-pushed the cowork/improve-api-contract-guardian branch from c3aadc3 to c361876 Compare June 29, 2026 10:01
@github-actions

Copy link
Copy Markdown

🤖 Automated Code Review

✅ Ruff Lint — No issues

⚠️ Ruff Format — Formatting needed

Would reformat: src/api_contract_guardian/cli.py
Would reformat: src/api_contract_guardian/diff.py
Would reformat: src/api_contract_guardian/gate.py
Would reformat: src/api_contract_guardian/loader.py
Would reformat: src/api_contract_guardian/migration.py
Would reformat: tests/test_cli.py
Would reformat: tests/test_diff.py
Would reformat: tests/test_edge_cases.py
Would reformat: tests/test_gate.py
Would reformat: tests/test_migration.py
10 files would be reformatted, 5 files already formatted

✅ Secret Detection — Clean

✅ Large Files — Within limits

📊 Diff Stats — 2 file(s) changed

 .github/workflows/cowork-auto-pr.yml | 28 +++++++++++++++++++
 src/api_contract_guardian/diff.py    | 54 ++++++++++++++++++++++++++++++++----
 2 files changed, 76 insertions(+), 6 deletions(-)

Verdict: ⚠️ Warnings — Lint/format issues found. Recommend fixing before merge.

Automated by Coding-Dev-Tools/.github reusable workflow.

@Coding-Dev-Tools Coding-Dev-Tools merged commit 149922b into main Jun 29, 2026
6 checks passed
@Coding-Dev-Tools Coding-Dev-Tools deleted the cowork/improve-api-contract-guardian branch June 29, 2026 10:13
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