Exclude OpenAPI/JSON Schema extension fields (x-*)#2801
Exclude OpenAPI/JSON Schema extension fields (x-*)#2801koxudaxi merged 5 commits intokoxudaxi:mainfrom
Conversation
|
Warning Rate limit exceeded@koxudaxi has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 7 minutes and 50 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughIgnore OpenAPI/JSON Schema vendor extension keys (prefixed with Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
Pre-merge checks and finishing touches✅ Passed checks (5 passed)
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 |
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/datamodel_code_generator/parser/jsonschema.pytests/parser/test_jsonschema.py
🧰 Additional context used
🧬 Code graph analysis (2)
src/datamodel_code_generator/parser/jsonschema.py (1)
src/datamodel_code_generator/util.py (1)
get_fields_set(208-212)
tests/parser/test_jsonschema.py (1)
src/datamodel_code_generator/parser/jsonschema.py (3)
JsonSchemaObject(202-472)parse_obj(3121-3162)has_ref_with_schema_keywords(453-472)
🔇 Additional comments (1)
src/datamodel_code_generator/parser/jsonschema.py (1)
453-472: LGTM! Clear fix for recursion issue with OpenAPI extension fields.The implementation correctly filters out OpenAPI/JSON Schema extension fields (x-*) when determining if a schema has
$refcombined with schema-affecting keywords. This prevents unnecessary schema merging that was causing recursion on large schemas with many extension fields.The docstring update clearly explains the rationale, and the filter logic
not k.startswith("x-")is efficient and aligns with the OpenAPI specification requirement that extension fields use lowercase "x-" prefix.
CodSpeed Performance ReportMerging #2801 will not alter performanceComparing
|
|
@ahmetveburak # tests/parser/test_jsonschema.py:925
- obj = JsonSchemaObject.parse_obj({
+ obj = model_validate(
+ JsonSchemaObject,
+ {
"$ref": "#/$defs/Base",
"deprecated": False,
"x-internalAPI": False,
"x-custom-field": "value",
- })
+ },
+ ) |
ilovelinux
left a comment
There was a problem hiding this comment.
I'm not sure to understand how this PR affects current behavior and how it fixes the issue. A rationale is missing.
Also see #2800 (comment). Maybe this is a workaround for just that case? Maybe RecursionLimit may still be hit but this edit keep recursion under the limit for this particular case?
9680861 to
f7598fa
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2801 +/- ##
=======================================
Coverage 99.37% 99.37%
=======================================
Files 92 92
Lines 16040 16046 +6
Branches 1893 1893
=======================================
+ Hits 15939 15945 +6
Misses 52 52
Partials 49 49
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:
|
|
@Nekidev Can you provide the input schema? I want to test it. |
|
My temporary fix was to install the library as a library and import it from a script where I had previously set the recursion limit to 5000. It works, but it's not the best solution and neither is it a one-size-fits-all solution. The same repository has a |
|
That's great! You're welcome. |
|
🎉 Released in 0.51.0 This PR is now available in the latest release. See the release notes for details. |

I'm not sure if this approach meets the design. I had to proceed, and I found this solution.
Fixes: #2800
Summary by CodeRabbit
Bug Fixes
Tests
✏️ Tip: You can customize this high-level summary in your review settings.