Skip to content

Accept boolean schemas in allOf - #5159

Merged
Koudai Aono (koxudaxi) merged 1 commit into
fe7a-parse-tablefrom
fix18-bool-allof
Oct 23, 2026
Merged

Koudai Aono (koxudaxi) merged 1 commit into
fe7a-parse-tablefrom
fix18-bool-allof

Conversation

@koxudaxi

@koxudaxi Koudai Aono (koxudaxi) commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • Bug Fixes
    • OpenAPI schemas with boolean entries in allOf are now handled correctly during model generation. Valid schemas can generate usable models, while schemas containing an invalid false entry produce an error instead of an output file.
    • Added coverage for generated models, payload validation, and YAML parsing to help ensure these cases behave consistently.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-22T18:17:29.569180Z 049fd8e PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
📥 Commits

Reviewing files that changed from the base of the PR and between 0bb237b and 049fd8e.

⛔ Files ignored due to path filters: 3
  • tests/data/openapi/allof_boolean_false_member.yaml is excluded by !tests/data/**/*.yaml and included by none
  • tests/data/openapi/allof_boolean_member/external.yaml is excluded by !tests/data/**/*.yaml and included by none
  • tests/data/openapi/allof_boolean_member/openapi.yaml is excluded by !tests/data/**/*.yaml and included by none
📒 Files selected for processing: 6
  • src/datamodel_code_generator/parser/openapi.py
  • tests/data/expected/main/openapi/openapi_allof_boolean_member.py
  • tests/main/openapi/test_main_openapi.py
  • tests/main/openapi/test_main_openapi.refs
  • tests/main/test_payload_validation.refs
  • tests/test_yaml_fast_constructor.refs

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 5 remain after this review.

📝 Walkthrough

The OpenAPI parser now skips non-dictionary entries when collecting allOf references. Tests cover generation with a true boolean schema member and an error for a false member.

Changes: OpenAPI allOf boolean schemas

Layer / File(s) Summary
Boolean-member handling and regression coverage
src/datamodel_code_generator/parser/openapi.py, tests/main/openapi/test_main_openapi.py, tests/data/expected/main/openapi/openapi_allof_boolean_member.py, tests/main/openapi/test_main_openapi.refs, tests/main/test_payload_validation.refs, tests/test_yaml_fast_constructor.refs
The parser skips non-dictionary entries while collecting allOf references. Tests cover generated models and payload validation for a true member, and an error when a component schema contains a false member. Expected model output and test references are added.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Possibly related issues

  • datamodel-code-generator/datamodel-code-generator#4491 — Reports an uncaught OpenAPI parsing failure when allOf contains a boolean schema. This change addresses the same behavior.
Merge Risk: ⚪ Minimal · up to 049fd

The boolean allOf cases appear consistent with the generated models and expected error behavior. No merge-blocking issue was identified; run the normal test suite before merging.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: support for boolean schemas in OpenAPI allOf entries.
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. (4 skipped: 3 …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. (4 skipped: 3 unsupported, 1 too large.)

✨ Finishing Touches: 💡 1
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
🛠️ Fix failing CI checks: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@github-actions

Copy link
Copy Markdown
Contributor

@codspeed

codspeed Bot commented Oct 22, 2026

Copy link
Copy Markdown

Merging this PR will degrade performance by 20.76%

2 warnings

⚠️ Walltime results may be unreliable

Some benchmarks used the Walltime instrument outside CodSpeed Macro Runners, which can make the results inconsistent.

Learn more about Macro Runners

See affected benchmarks

⚠️ Base and head ran on different runner types

Some benchmarks with significant performance changes were compared across different runner types, so the changes might not come from the code. Run base and head on the same runner type, or use CodSpeed Macro Runners for more stable results.

Learn more about Macro Runners

Open the report in CodSpeed to investigate

⚡ 1 improved benchmark
❌ 42 regressed benchmarks
✅ 7 untouched benchmarks
⏩ 98 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
❌ test_perf_unique_items_runtime_scalar_validation 1.6 ms 2.3 ms -31.22%
❌ test_perf_client_calls[async] 19.7 ms 28.6 ms -31.16%
❌ test_perf_client_calls[sync] 18.2 ms 26.1 ms -30.05%
❌ test_perf_unique_items_nested_model_validation 1.7 ms 2.4 ms -30.04%
❌ test_perf_pydantic_field_name_resolution 959.7 µs 1,354.8 µs -29.16%
❌ test_perf_graphql_style_pydantic_v2 453.3 ms 620 ms -26.89%
❌ test_perf_kubernetes_style_pydantic_v2 1.4 s 2 s -26.68%
❌ test_perf_duplicate_names 564.8 ms 767.2 ms -26.38%
❌ test_perf_extreme_large_schema 8.4 s 11.3 s -25.51%
❌ test_perf_large_models_pydantic_v2 2 s 2.6 s -24.81%
❌ test_perf_all_options_enabled 3.4 s 4.6 s -24.71%
❌ test_perf_stripe_style_pydantic_v2 1.2 s 1.6 s -24.59%
❌ test_perf_complex_refs 1.2 s 1.6 s -24.57%
❌ test_perf_deep_nested 3.1 s 4 s -24.01%
❌ test_perf_unique_items_runtime_nested_object_validation 4.2 ms 5.5 ms -23.63%
❌ test_perf_large_models_typed_dict[total-false-requiredness] 678.7 ms 885.8 ms -23.38%
❌ test_perf_load_yaml_openapi_large 20.1 ms 26.1 ms -23.14%
❌ test_perf_aws_style_openapi_pydantic_v2 1.4 s 1.8 s -22.68%
❌ test_perf_multiple_files_input 2.3 s 3 s -22.13%
❌ test_perf_load_pyproject_config[mapping-multiple] 177.3 µs 227.3 µs -22%
... ... ... ... ...

ℹ️ Only the first 20 benchmarks are displayed. Go to the app to view all benchmarks.

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing fix18-bool-allof (049fd8e) with fe7a-parse-table (0bb237b)

Open in CodSpeed

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

codecov Bot commented Oct 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@koxudaxi
Koudai Aono (koxudaxi) merged commit 4723fab into main Oct 23, 2026
131 of 132 checks passed
@koxudaxi
Koudai Aono (koxudaxi) deleted the fix18-bool-allof branch October 23, 2026 02:20
@github-actions

Copy link
Copy Markdown
Contributor

Breaking Change Analysis

Result: No breaking changes detected

Reasoning: The only source change is in the OpenAPI parser method that collects discriminator refs from allOf members, which now adds an isinstance dict guard so boolean schema members such as true or false no longer cause an AttributeError when calling get on a bool. This is a bug fix: inputs that previously crashed now generate code, with true members treated as no constraint. A false member leads to an error message that is not added in this diff, so it comes from existing validation code that is now reachable. Output for dict-only allOf lists is unchanged. All other changes are new test fixtures, expected outputs, tests and refs entries. No CLI options, Python API, defaults, templates, Python version support or existing generated output for valid inputs were changed, so there are no breaking changes.


This analysis was produced by the release draft workflow

Koudai Aono (koxudaxi) added a commit that referenced this pull request Oct 23, 2026
A YAML key such as `1` under `components` loads as a number. The legacy
scopes crashed on such a name under `schemas` and `requestBodies`, and the
`api` scope on every component kind it reads (and on any loaded document's
`schemas`). They now stop with "Error at schema path '<doc>#/components/<kind>/1':
component name 1 is not a string". Runs that never use such a name as a model
name, such as a legacy request body without a schema, keep their output.

Boolean schemas in `allOf` no longer crash since #5159.

Fixes: #4491
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.

1 participant