Skip to content

Write an allOf whose parts admit no object as the intersection of its parts instead of a model without fields - #5406

Merged
Koudai Aono (koxudaxi) merged 10 commits into
fix-5387-builtin-submodulefrom
fix-5401-allof-scalar-items
Oct 28, 2026
Merged

Koudai Aono (koxudaxi) merged 10 commits into
fix-5387-builtin-submodulefrom
fix-5401-allof-scalar-items

Conversation

@koxudaxi

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

Copy link
Copy Markdown
Member

Fixes: #5401

Summary by CodeRabbit

  • Bug Fixes
    • Generated models now retain applicable scalar, array, and string constraints in allOf schemas, including minimum item counts and combined patterns.
    • Scalar and collection schemas are represented with appropriate value types instead of empty placeholder models, across supported output formats.
    • Updated CLI documentation examples to reflect generated constrained root models.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 28, 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-28T07:28:40.090259Z ebd8268 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 28, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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 437f4f0 and ebd8268.

Files ignored due to path filters: 14
  • docs/llms-full.txt is excluded by none and included by none
  • tests/data/expected/main/generation_platform/codecs/plan/dialects.txt is excluded by !tests/data/**/*.txt and included by none
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_payloads[allof_scalar_refs].txt is excluded by !tests/data/**/*.txt and included by none
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_payloads_without_option[allof_ref_item_constraints].txt is excluded by !tests/data/**/*.txt and included by none
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_payloads_without_option[allof_refs].txt is excluded by !tests/data/**/*.txt and included by none
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_payloads_without_option[allof_scalar_refs].txt is excluded by !tests/data/**/*.txt and included by none
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_payloads_without_option[allof_values].txt is excluded by !tests/data/**/*.txt and included by none
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_payloads_without_option[root_forms].txt is excluded by !tests/data/**/*.txt and included by none
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_payloads_without_option[root_site_null].txt is excluded by !tests/data/**/*.txt and included by none
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_payloads_without_option[root_site_null_oas30].txt is excluded by !tests/data/**/*.txt and included by none
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_payloads_without_option[root_value_items_draft07].txt is excluded by !tests/data/**/*.txt and included by none
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_payloads_without_option[root_value_keywords].txt is excluded by !tests/data/**/*.txt and included by none
  • tests/data/jsonschema/schema_intersection/allof_scalar_refs.json is excluded by !tests/data/**/*.json and included by none
  • tests/data/payloads/schema_intersection.json is excluded by !tests/data/**/*.json and included by none
Files selected for processing: 100
  • docs/cli-reference/typing-customization.md
  • src/datamodel_code_generator/parser/jsonschema.py
  • tests/data/expected/main/jsonschema/allof_root_model_constraints.py
  • tests/data/expected/main/jsonschema/allof_root_model_constraints_merge.py
  • tests/data/expected/main/jsonschema/main_jsonschema/main_allof_root_model_constraints_intersect.py
  • tests/data/expected/main/openapi/main_openapi/allof_scalar_roots_without_option[dataclasses.dataclass].py
  • tests/data/expected/main/openapi/main_openapi/allof_scalar_roots_without_option[msgspec.Struct].py
  • tests/data/expected/main/openapi/main_openapi/allof_scalar_roots_without_option[pydantic_v2.BaseModel].py
  • tests/data/expected/main/openapi/main_openapi/allof_scalar_roots_without_option[pydantic_v2.dataclass].py
  • tests/data/expected/main/openapi/main_openapi/allof_scalar_roots_without_option[typing.TypedDict].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output[allof_ref_item_constraints-pydantic_v2.BaseModel-collapse-root-models].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output[allof_refs-dataclasses.dataclass-use-site-models-for-constrained-refs].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output[allof_refs-pydantic_v2.BaseModel-use-site-models-for-constrained-refs].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output[allof_refs-pydantic_v2.dataclass-use-site-models-for-constrained-refs].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output[allof_scalar_refs-dataclasses.dataclass-default].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output[allof_scalar_refs-msgspec.Struct-collapse-root-models].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output[allof_scalar_refs-msgspec.Struct-default].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output[allof_scalar_refs-pydantic_v2.BaseModel-collapse-root-models].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output[allof_scalar_refs-pydantic_v2.BaseModel-default].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output[allof_scalar_refs-pydantic_v2.BaseModel-field-constraints].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output[allof_scalar_refs-pydantic_v2.BaseModel-use-annotated].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output[allof_scalar_refs-pydantic_v2.dataclass-default].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output[allof_scalar_refs-typing.TypedDict-default].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[allof_ref_item_constraints-dataclasses.dataclass-default].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[allof_ref_item_constraints-datac~8865645e.py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[allof_ref_item_constraints-pydantic_v2.BaseModel-default].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[allof_ref_item_constraints-pydantic_v2.dataclass-default].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[allof_ref_item_constraints-pydan~0d5fce26.py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[allof_ref_item_constraints-pydan~6e66ac1f.py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[allof_ref_item_constraints-pydan~a90af8cb.py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[allof_ref_item_constraints-pydan~bb0a67f2.py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[allof_ref_item_constraints-typing.TypedDict-default].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[allof_ref_item_constraints-typin~47b4c14b.py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[allof_refs-dataclasses.dataclass-default].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[allof_refs-dataclasses.dataclass~3058eda9.py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[allof_refs-msgspec.Struct-collapse-root-models].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[allof_refs-msgspec.Struct-default].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[allof_refs-msgspec.Struct-use-site-models-for-constrained-refs].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[allof_refs-pydantic_v2.BaseModel-collapse-root-models].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[allof_refs-pydantic_v2.BaseModel-default].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[allof_refs-pydantic_v2.BaseModel-field-constraints].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[allof_refs-pydantic_v2.BaseModel-use-annotated].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[allof_refs-pydantic_v2.BaseModel~044fa25b.py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[allof_refs-pydantic_v2.BaseModel~4b663a91.py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[allof_refs-pydantic_v2.BaseModel~ff03cc9c.py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[allof_refs-pydantic_v2.dataclass-default].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[allof_refs-pydantic_v2.dataclass~9e0ac643.py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[allof_refs-typing.TypedDict-default].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[allof_refs-typing.TypedDict-use-site-models-for-constrained-refs].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[allof_scalar_refs-dataclasses.dataclass-default].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[allof_scalar_refs-msgspec.Struct-collapse-root-models].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[allof_scalar_refs-msgspec.Struct-default].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[allof_scalar_refs-pydantic_v2.BaseModel-collapse-root-models].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[allof_scalar_refs-pydantic_v2.BaseModel-default].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[allof_scalar_refs-pydantic_v2.BaseModel-field-constraints].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[allof_scalar_refs-pydantic_v2.BaseModel-use-annotated].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[allof_scalar_refs-pydantic_v2.dataclass-default].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[allof_scalar_refs-typing.TypedDict-default].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[allof_values-dataclasses.dataclass-default].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[allof_values-msgspec.Struct-collapse-root-models].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[allof_values-msgspec.Struct-default].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[allof_values-pydantic_v2.BaseModel-collapse-root-models].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[allof_values-pydantic_v2.BaseModel-default].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[allof_values-pydantic_v2.BaseModel-field-constraints].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[allof_values-pydantic_v2.BaseModel-use-annotated].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[allof_values-pydantic_v2.dataclass-default].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[allof_values-typing.TypedDict-default].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[root_forms-dataclasses.dataclass-default].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[root_forms-msgspec.Struct-collapse-root-models].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[root_forms-msgspec.Struct-default].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[root_forms-pydantic_v2.BaseModel-collapse-root-models].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[root_forms-pydantic_v2.BaseModel-default].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[root_forms-pydantic_v2.BaseModel-field-constraints].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[root_forms-pydantic_v2.BaseModel-use-annotated].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[root_forms-pydantic_v2.dataclass-default].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[root_forms-typing.TypedDict-default].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[root_site_null-dataclasses.dataclass-default].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[root_site_null-msgspec.Struct-collapse-root-models].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[root_site_null-pydantic_v2.BaseModel-collapse-root-models].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[root_site_null-pydantic_v2.BaseModel-field-constraints].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[root_site_null-pydantic_v2.BaseModel-use-annotated].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[root_site_null-pydantic_v2.dataclass-default].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[root_site_null-typing.TypedDict-default].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[root_site_null_oas30-dataclasses.dataclass-default].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[root_site_null_oas30-msgspec.Struct-collapse-root-models].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[root_site_null_oas30-pydantic_v2.BaseModel-collapse-root-models].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[root_site_null_oas30-pydantic_v2.dataclass-default].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[root_site_null_oas30-typing.TypedDict-default].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[root_value_items_draft07-dataclasses.dataclass-default].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[root_value_items_draft07-msgspec.Struct-collapse-root-models].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[root_value_items_draft07-pydantic_v2.BaseModel-collapse-root-models].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[root_value_items_draft07-pydantic_v2.dataclass-default].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[root_value_items_draft07-typing.TypedDict-default].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[root_value_keywords-dataclasses.dataclass-default].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[root_value_keywords-msgspec.Struct-collapse-root-models].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[root_value_keywords-pydantic_v2.BaseModel-collapse-root-models].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[root_value_keywords-pydantic_v2.dataclass-default].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[root_value_keywords-typing.TypedDict-default].py
  • tests/main/jsonschema/test_main_jsonschema.refs
  • tests/main/test_schema_intersection_shapes.refs
Files with no reviewable changes: 44
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[allof_refs-pydantic_v2.BaseModel-use-annotated].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[allof_refs-pydantic_v2.BaseModel-field-constraints].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[allof_refs-pydantic_v2.BaseModel~ff03cc9c.py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output[allof_refs-pydantic_v2.dataclass-use-site-models-for-constrained-refs].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[root_site_null-pydantic_v2.BaseModel-collapse-root-models].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[root_value_items_draft07-dataclasses.dataclass-default].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[root_value_keywords-pydantic_v2.BaseModel-collapse-root-models].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[allof_refs-msgspec.Struct-default].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[allof_refs-pydantic_v2.BaseModel-collapse-root-models].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[root_value_keywords-dataclasses.dataclass-default].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[root_value_keywords-typing.TypedDict-default].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[allof_refs-msgspec.Struct-collapse-root-models].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[root_value_items_draft07-msgspec.Struct-collapse-root-models].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[root_site_null-msgspec.Struct-collapse-root-models].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[root_site_null-pydantic_v2.BaseModel-field-constraints].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[root_value_items_draft07-pydantic_v2.dataclass-default].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output[allof_refs-pydantic_v2.BaseModel-use-site-models-for-constrained-refs].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[root_site_null_oas30-pydantic_v2.dataclass-default].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[root_site_null-pydantic_v2.BaseModel-use-annotated].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[allof_ref_item_constraints-pydantic_v2.dataclass-default].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[root_site_null-typing.TypedDict-default].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[root_site_null_oas30-dataclasses.dataclass-default].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[root_site_null-dataclasses.dataclass-default].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[root_site_null_oas30-msgspec.Struct-collapse-root-models].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[allof_ref_item_constraints-dataclasses.dataclass-default].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[root_value_items_draft07-pydantic_v2.BaseModel-collapse-root-models].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[allof_refs-msgspec.Struct-use-site-models-for-constrained-refs].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output[allof_ref_item_constraints-pydantic_v2.BaseModel-collapse-root-models].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[allof_refs-typing.TypedDict-default].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[allof_refs-typing.TypedDict-use-site-models-for-constrained-refs].py
  • tests/data/expected/main/jsonschema/main_jsonschema/main_allof_root_model_constraints_intersect.py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output[allof_refs-dataclasses.dataclass-use-site-models-for-constrained-refs].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[root_site_null_oas30-typing.TypedDict-default].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[root_site_null_oas30-pydantic_v2.BaseModel-collapse-root-models].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[allof_refs-pydantic_v2.BaseModel-default].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[allof_refs-pydantic_v2.dataclass-default].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[root_value_keywords-msgspec.Struct-collapse-root-models].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[root_site_null-pydantic_v2.dataclass-default].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[allof_refs-dataclasses.dataclass-default].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[allof_ref_item_constraints-pydantic_v2.BaseModel-default].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[root_value_items_draft07-typing.TypedDict-default].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[allof_ref_item_constraints-typing.TypedDict-default].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[root_value_keywords-pydantic_v2.dataclass-default].py
  • tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output_without_option[allof_refs-pydantic_v2.BaseModel~4b663a91.py

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 parser now converts eligible non-object allOf schemas into value schemas without requiring --intersect-allof-keywords. Expected outputs and test references are updated for scalar and constrained-reference schemas across model types.

Changes: JSON Schema allOf value handling

Layer / File(s) Summary
Convert eligible allOf schemas to value models
src/datamodel_code_generator/parser/jsonschema.py, docs/cli-reference/typing-customization.md, tests/data/expected/main/jsonschema/*, tests/data/expected/main/openapi/*, tests/data/expected/main/schema_intersection_shapes/...
The parser now checks whether an intersected type excludes objects when the option is off. The documentation and expected outputs show scalar and array root models with constraints.
Add scalar-reference output coverage
tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output*
Expected outputs add scalar and collection aliases, constraints, and aggregate model fields across model configurations, both with and without the option.
Align constrained-reference fixtures and test mappings
tests/data/expected/main/schema_intersection_shapes/schema_intersection_shape_output*, tests/main/*.refs
Expected-output snapshots and test references change for constrained references, allOf cases, root-site nullability, and root-value schemas.

Priority: Normal

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix · Severity of issue fixed: Medium

Sequence Diagram(s)

sequenceDiagram
  participant JsonSchemaInput
  participant JsonSchemaParser
  participant GeneratedModelOutput
  JsonSchemaInput->>JsonSchemaParser: Supply allOf schema
  JsonSchemaParser->>GeneratedModelOutput: Convert eligible non-object intersection to value schema
Loading

Possibly related issues

  • Issue 5385: The changes cover scalar allOf intersections, which is the area described in this issue.
  • Issue 4765: The parser change addresses scalar allOf constraint handling, though the supplied context does not establish coverage of every single-reference case.
  • Issue 4858: The parser change covers scalar allOf handling, but the supplied context does not establish that enum intersections are resolved.

Suggested labels: breaking-change-analyzed

Merge Risk: Minimal · previous review ebd82

The change makes eligible scalar allOf intersections generate value types rather than empty object models. No concrete merge-blocking issue is established by the supplied evidence.

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 describes the main change: representing object-excluding allOf intersections as value/root models instead of empty models.
Linked Issues check Passed Issue #5401 requires integer handling for allOf item and additionalProperties schemas that combine integer $refs with constraints. src/datamodel_code_generator/parser/jsonschema.py now convert…
Out of Scope Changes check Passed The changed source logic generalizes allOf conversion for schemas that cannot represent objects. The updated fixtures cover related scalar, array, reference, constraint, and root-form cases across s…
Docstring Coverage Passed No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Full details: Linked Issues check

Explanation

Issue #5401 requires integer handling for allOf item and additionalProperties schemas that combine integer $refs with constraints. src/datamodel_code_generator/parser/jsonschema.py now converts an allOf value schema when the intersection excludes objects. The updated Pydantic v2 expected output for allof_ref_item_constraints uses constrained integer types with ge=4 and le=5 for two_items and two_map, instead of empty BaseModel classes. The test reference files include these updated cases. This covers the required implementation and automated regression coverage.

Full details: Out of Scope Changes check

Explanation

The changed source logic generalizes allOf conversion for schemas that cannot represent objects. The updated fixtures cover related scalar, array, reference, constraint, and root-form cases across supported output types. The documentation and expected-output changes describe or test this same allOf root-value behavior. The summary provides no demonstrated unrelated product change.

Full details: Docstring Coverage

Explanation

No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 49 files. (7 skipped: 3 unsupported, 1 too large, 3 over the file limit.)

Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • 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 28, 2026 •

Copy link
Copy Markdown

Merging this PR will degrade performance by 46.44%

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

❌ 52 regressed benchmarks
⏩ 98 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
❌ test_perf_client_calls[async] 20.6 ms 46.6 ms -55.88%
❌ test_perf_client_calls[sync] 18.7 ms 42.2 ms -55.74%
❌ test_perf_load_pyproject_config[config-None] 166.9 µs 369.4 µs -54.81%
❌ test_perf_load_pyproject_config[mapping-None] 170 µs 371.5 µs -54.24%
❌ test_perf_load_pyproject_config[mapping-multiple] 174.3 µs 379.9 µs -54.13%
❌ test_perf_simple_msgspec_unset_field_rendering 232.5 ms 497.2 ms -53.25%
❌ test_perf_load_pyproject_config[config-multiple] 178.2 µs 377.9 µs -52.85%
❌ test_perf_scalar_root_collapsed_builtin 95.7 ms 199.9 ms -52.1%
❌ test_perf_local_reference_file_resolution 60.4 ms 124.9 ms -51.67%
❌ test_perf_complex_refs 1.1 s 2.2 s -51.48%
❌ test_perf_extreme_large_schema 8.3 s 17 s -51.09%
❌ test_perf_unique_items_runtime_scalar_validation 1.5 ms 3.1 ms -50.81%
❌ test_perf_unique_items_nested_model_validation 1.6 ms 3.2 ms -50.06%
❌ test_perf_pydantic_field_name_resolution 983.5 µs 1,968.7 µs -50.04%
❌ test_perf_false_reference_validation 126.7 ms 252.3 ms -49.79%
❌ test_perf_openapi_large 1.7 s 3.4 s -49.75%
❌ test_perf_duplicate_names 563.7 ms 1,120.8 ms -49.7%
❌ test_perf_deep_nested 3 s 5.9 s -49.18%
❌ test_perf_large_models_pydantic_v2 2 s 3.9 s -48.96%
❌ test_perf_graphql_style_pydantic_v2 449 ms 877.4 ms -48.82%
... ... ... ... ...

ℹ️ 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 fix-5401-allof-scalar-items (7a85156) with fix-5387-builtin-submodule (486e4b3)

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. ↩

…s under --collapse-root-models and its regex engine to itself
@codecov

codecov Bot commented Oct 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

… would need the regex engine of the models using its type alias
…nd allof_scalar_roots in the behaviour diff allowlist
…-items

# Conflicts:
#	scripts/behaviour_diff_allowlist.toml
# Conflicts:
#	tests/parser/test_generation_store_usage.py
@koxudaxi
Koudai Aono (koxudaxi) changed the base branch from main to fix-5387-builtin-submodule October 28, 2026 14:58
…ies and covering their directory input and validation probes
…yOf member, and accept the default rules its fields now take in the behaviour diff allowlist
# Conflicts:
#	scripts/behaviour_diff_allowlist.toml
@koxudaxi
Koudai Aono (koxudaxi) merged commit 0745dfa into main Oct 28, 2026
164 of 165 checks passed
@koxudaxi
Koudai Aono (koxudaxi) deleted the fix-5401-allof-scalar-items branch October 28, 2026 17:25
@github-actions

Copy link
Copy Markdown
Contributor

Breaking Change Analysis

Result: Breaking changes detected

Reasoning: The PR changes default output for JSON Schema and OpenAPI allOf sites whose intersected parts admit no object. Before, without the intersect allOf keywords option, these were written as empty models that rejected every valid value. They are now written as the constrained value type: RootModel for Pydantic v2 and type aliases for dataclasses, msgspec and TypedDict. The behaviour diff gate marks these cells as accepted, meaning default output changed for allof_root_model_constraints, allof_scalar_roots, the schema_intersection directories and allof_scalar_refs. The changes include model kind changes, changed field types, models no longer emitted under collapse-root-models, added regex_engine config and compile imports for lookaround patterns, and inverted validation results. With strip-default-none or the default-factory option, affected fields also get different defaults and constructor order. No CLI options, public API, templates or Python versions are removed or changed. The only API change adds two ClassVar hooks to DataModelFieldBase that default to None. The one changed error expectation drops a parameter error that no longer happens because an allOf of scalars now resolves to a scalar kind, so it fixes a spurious error rather than breaking anything.

Content for Release Notes

Code Generation Changes

  • Non-object allOf sites now generate the constrained value type instead of an empty model - Without --intersect-allof-keywords, some allOf sites used to be generated as an empty class (class TwoRefsProp(BaseModel): pass, or an empty Struct, dataclass or TypedDict) that rejected every valid value. These are sites whose parts admit no object, for example two integer $refs with a sibling minimum, a $ref to an array schema with minItems, or two string schemas with a pattern each. They are now generated as the intersected value type: a RootModel such as RootModel[conint(ge=3, le=5)] or RootModel[list[str]] for Pydantic v2, and a type alias for dataclasses, msgspec and TypedDict output (for example TwoPatterns: TypeAlias = str). Fields that referenced those classes change with them. Under msgspec or --collapse-root-models, some models are inlined or no longer emitted (for example two_prop: Annotated[int, Meta(ge=4, le=5)]). Merged lookaround patterns add model_config = ConfigDict(regex_engine="python-re") or a from re import compile import, and a nullable site is now typed as a union with None. Code that imports, subclasses or instantiates these former empty classes, or passes dicts to them, must be updated: valid scalar and array values now validate and objects are rejected (Write an allOf whose parts admit no object as the intersection of its parts instead of a model without fields #5406)
  • Defaults of affected properties follow their new value type with --strip-default-none or --use-default-factory-for-optional-nested-models - A property whose allOf of scalar schemas used to be an empty model now gets the default its value type gets. --use-default-factory-for-optional-nested-models no longer emits a default factory for it, and --strip-default-none keeps the None default only where the type admits null. This can change whether these fields are required and the order of constructor arguments in generated models and dataclasses (Write an allOf whose parts admit no object as the intersection of its parts instead of a model without fields #5406)

This analysis was produced by the release draft workflow

@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

🎉 Released in 0.88.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.

pydantic_v2.BaseModel rejects valid integers for items that allOf two $refs to integer schemas with a sibling minimum

1 participant