Skip to content

Move the schema validator planning of the JSON Schema parser into a module of its own - #5632

Merged
Koudai Aono (koxudaxi) merged 1 commit into
impl-map5from
impl-map4
Oct 30, 2026
Merged

Koudai Aono (koxudaxi) merged 1 commit into
impl-map5from
impl-map4

Conversation

@koxudaxi

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

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • Refactor

    • Reorganized schema-validation handling while preserving existing behavior for generated models.
  • Documentation

    • Clarified how certain schema rules apply when using the single-dictionary object-map option.

@coderabbitai

coderabbitai Bot commented Oct 30, 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 122d7d115a3ddc585f1bc32da069026743b4b70d and c523deba83475b78b831c45f836985eb92ce30aa.

Files ignored due to path filters: 1
  • docs/llms-full.txt is excluded by none and included by none
Files selected for processing: 4
  • docs/architecture.md
  • scripts/decision_homes.toml
  • src/datamodel_code_generator/parser/_schema_validators.py
  • src/datamodel_code_generator/parser/jsonschema.py

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

Walkthrough

The PR moves JSON Schema validation helpers from jsonschema.py into a dedicated module. The parser delegates validation operations to the new module. Documentation and signature-scan paths are updated to reference it.

Changes: Schema validation helper extraction

Layer / File(s) Summary
Schema validation helpers and rule registration
src/datamodel_code_generator/parser/_schema_validators.py, docs/architecture.md, scripts/decision_homes.toml
The new module defines schema traversal, compatibility, input-name mapping, and runtime-rule registration helpers. The architecture note and signature-scan paths are updated to reference the module.
JSON Schema parser delegation
src/datamodel_code_generator/parser/jsonschema.py
The parser delegates schema validation operations to the new module and removes the corresponding inline implementations. Import annotations preserve selected parser-module exports.

Priority: Low

Estimated code review effort: 4 (Complex) | ~45 minutes

Change: Refactor

Merge Risk: Minimal · previous review c523d

No actionable merge-blocking issue is established for the validator-module extraction. Mergeability remains subject to normal checks.

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: moving JSON Schema parser schema-validator planning into a separate module.
Docstring Coverage Passed Docstring coverage is 89.58% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentati…
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 89.58% which is sufficient. The required threshold is 80.00%. 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 48 functions across 1 files. (3 skipped: 2 unsupported, 1 too large.)

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.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 30, 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-30T05:34:43.301351Z c523deb 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.

@github-actions

Copy link
Copy Markdown
Contributor

@codspeed

codspeed Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Merging this PR will improve performance by 22.59%

1 warning

⚠️ 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

⚡ 3 improved benchmarks
✅ 49 untouched benchmarks
⏩ 98 skipped benchmarks1

Performance Changes

Benchmark BASE HEAD Efficiency
⚡ test_perf_simple_pydantic_v2_field_construction 14.4 ms 10.8 ms +33.25%
⚡ test_perf_load_yaml_openapi_large 43.1 ms 34.3 ms +25.66%
⚡ test_perf_target_render[fastapi-small] 22.8 ms 20.7 ms +10.03%

Tip

Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.


Comparing impl-map4 (e664ae2) with impl-map5 (a7ec20f)2

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

  2. No successful run was found on impl-map5 (9c4e6e2) during the generation of this report, so 00a2570 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

@codecov

codecov Bot commented Oct 30, 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 2e73148 into main Oct 30, 2026
29 checks passed
@koxudaxi
Koudai Aono (koxudaxi) deleted the impl-map4 branch October 30, 2026 08:10
@github-actions

Copy link
Copy Markdown
Contributor

Breaking Change Analysis

Result: No breaking changes detected

Reasoning: This PR is a pure refactor that moves the schema validator rule logic for --generate-schema-validators out of parser/jsonschema.py into a new private module parser/_schema_validators.py, with JsonSchemaParser keeping thin delegating methods; a line-by-line comparison of the removed and added code shows identical logic (required groups, conditional rules, property counts, uniqueItems paths, patternProperties intersection proofs, input-name resolution). The only removals are underscore-prefixed private internals such as _get_not_required_groups, _has_required_group_validators, _has_conditional_validator, _has_core_schema_runtime_rules, _field_alias_generator_input_name, _schema_may_accept_container, the pattern-proof classmethods, _add_group_validators and the module-level _input_names helper, none of which are public API; previously used imports in parser.jsonschema are explicitly preserved as re-exports. Doc and decision_homes.toml edits only update internal references. The behaviour diff gate accepted cells all concern allOf schemas whose parts admit no object becoming root models or aliases, and its notes attribute them to an earlier allOf change measured against the last release; nothing in this diff touches that logic, so they are not attributable to this PR. No CLI options, defaults, templates, Python version support or error handling changed.


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.

2 participants