Skip to content

Fix allOf with single ref creating unnecessary wrapper class#2902

Merged
koxudaxi merged 1 commit intomainfrom
fix/allof-single-ref-no-wrapper
Jan 2, 2026
Merged

Fix allOf with single ref creating unnecessary wrapper class#2902
koxudaxi merged 1 commit intomainfrom
fix/allof-single-ref-no-wrapper

Conversation

@koxudaxi
Copy link
Copy Markdown
Owner

@koxudaxi koxudaxi commented Jan 2, 2026

Fixes: #2900

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jan 2, 2026

Warning

Rate limit exceeded

@koxudaxi has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 11 minutes and 24 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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.

📥 Commits

Reviewing files that changed from the base of the PR and between 689cc79 and 7389fd2.

⛔ Files ignored due to path filters (1)
  • tests/data/openapi/allof_single_ref_inline.yaml is excluded by !tests/data/**/*.yaml and included by none
📒 Files selected for processing (3)
  • src/datamodel_code_generator/parser/jsonschema.py
  • tests/data/expected/main/openapi/openapi_allof_single_ref_inline.py
  • tests/main/openapi/test_main_openapi.py

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jan 2, 2026

📚 Docs Preview: https://pr-2902.datamodel-code-generator.pages.dev

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Jan 2, 2026

CodSpeed Performance Report

Merging #2902 will not alter performance

Comparing fix/allof-single-ref-no-wrapper (7389fd2) with main (689cc79)

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

Summary

✅ 11 untouched
⏩ 98 skipped1

Footnotes

  1. 98 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@codecov
Copy link
Copy Markdown

codecov Bot commented Jan 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.38%. Comparing base (99aac7b) to head (7389fd2).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2902   +/-   ##
=======================================
  Coverage   99.37%   99.38%           
=======================================
  Files          92       92           
  Lines       16268    16342   +74     
  Branches     1921     1934   +13     
=======================================
+ Hits        16167    16241   +74     
  Misses         52       52           
  Partials       49       49           
Flag Coverage Δ
unittests 99.38% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@koxudaxi koxudaxi force-pushed the fix/allof-single-ref-no-wrapper branch from add5d0c to 4d69384 Compare January 2, 2026 16:31
@koxudaxi koxudaxi force-pushed the fix/allof-single-ref-no-wrapper branch from 4d69384 to 7389fd2 Compare January 2, 2026 16:33
@koxudaxi koxudaxi enabled auto-merge (squash) January 2, 2026 16:34
@koxudaxi koxudaxi merged commit a310b6f into main Jan 2, 2026
34 checks passed
@koxudaxi koxudaxi deleted the fix/allof-single-ref-no-wrapper branch January 2, 2026 16:36
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jan 2, 2026

Breaking Change Analysis

Result: Breaking changes detected

Reasoning: This PR changes the code generation output for a specific schema pattern (allOf with single $ref and no properties). Previously, such schemas would create wrapper classes; now they directly reference the target type. Users with existing codebases may have code depending on the wrapper class names that will no longer be generated. While this is a bug fix making the output cleaner and more correct, it still constitutes a breaking change for users whose code depends on the previous (wrapper class) output structure.

Content for Release Notes

Code Generation Changes

  • allOf with single $ref no longer creates wrapper class - When a schema property uses allOf with only a single $ref and no additional properties, the generator now directly references the target type instead of creating an unnecessary wrapper class. This may affect code that depends on the previously generated wrapper class names or structure. For example, a property defined as allOf: [$ref: '#/components/schemas/ACHClass'] will now generate ach_class: ACHClass | None instead of creating an intermediate wrapper type. (Fix allOf with single ref creating unnecessary wrapper class #2902)

This analysis was performed by Claude Code Action

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jan 2, 2026

🎉 Released in 0.52.0

This PR is now available in the latest release. See the release notes for details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Schema reference in allOf block results in different class name from schema reference not in allOf block

1 participant