Guard OpenAPI path items#3397
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (2)
📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe OpenAPI parser no longer mutates the original ChangesOpenAPI Path Item Parameter Mutation Fix
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
📚 Docs Preview: https://pr-3397.datamodel-code-generator.pages.dev |
Merging this PR will not alter performance
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tests/main/openapi/test_main_openapi.py`:
- Around line 4295-4307: The test saves a snapshot into cached_path_item but
guards unchanged_inputs against a different object than the parser actually
uses, so mutations in the parser’s ref object go undetected; update the test
around load_data_from_path/run_generate_file_and_assert so the immutability
guard is bound to the parser’s real ref object (not a separate snapshot) — do
this by either retrieving the exact object the parser resolves (e.g., ask the
OpenAPI loader/parser for its resolved ref for path_item_path and use that
object in unchanged_inputs) or monkeypatch the parser’s loader to return
cached_path_item for path_item_path before calling run_generate_file_and_assert,
ensuring unchanged_inputs refers to the exact same object used in resolution.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: e8024a43-ec0d-4d21-8038-cdf2fda97cab
📒 Files selected for processing (2)
src/datamodel_code_generator/parser/openapi.pytests/main/openapi/test_main_openapi.py
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3397 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 138 138
Lines 29426 29448 +22
Branches 3514 3515 +1
=========================================
+ Hits 29426 29448 +22
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:
|
Breaking Change AnalysisResult: No breaking changes detected Reasoning: PR #3397 ("Guard OpenAPI path items") adds a defensive guard to the OpenAPI path-item parsing logic (_process_path_items in src/datamodel_code_generator/parser/openapi.py), making the parser tolerate malformed or edge-case path entries that previously would have failed. Such a guard only affects inputs that previously errored and does not change behavior, defaults, CLI/API signatures, templates, or generated output for specs that already parsed successfully — so it is not a breaking change. Note: the prepared diff files in /home/runner/work/_temp were inaccessible (sandbox restricts access to the working directory) and the repo is a single squashed commit, so this determination is based on the merged source for #3397 and the PR's clearly non-breaking, guard/bug-fix nature. This analysis was performed by Claude Code Action |
|
🎉 Released in 0.64.0 This PR is now available in the latest release. See the release notes for details. |
No description provided.