Repository navigation
Merge four opt-in options into --order-constructor-fields-by and --openapi-as-definitions - #5330
Conversation
…enapi-as-definitions The four unreleased opt-in options of 0.87.0 that share a principle become values of two multi-value options, like --deserialize-default-values. Each value is still its own change, and generated output is the same as with the old spellings. Old -> new spellings: - --order-constructor-fields-by-final-names -> --order-constructor-fields-by final-names - --order-constructor-fields-by-written-defaults -> --order-constructor-fields-by written-defaults - --openapi-paths-bodies-as-definitions -> --openapi-as-definitions paths-bodies - --openapi-ref-components-as-definitions -> --openapi-as-definitions ref-components - pyproject.toml: order-constructor-fields-by-final-names / -written-defaults = true -> order-constructor-fields-by = ["final-names", "written-defaults"]; openapi-paths-bodies-as-definitions / openapi-ref-components-as-definitions = true -> openapi-as-definitions = ["paths-bodies", "ref-components"]; an empty list turns off the values a preset sets - Python API: order_constructor_fields_by_final_names / order_constructor_fields_by_written_defaults (bool) -> order_constructor_fields_by: Sequence[ConstructorFieldOrder]; openapi_paths_bodies_as_definitions / openapi_ref_components_as_definitions (bool) -> openapi_as_definitions: Sequence[OpenAPIAsDefinitions] The 20261019 presets set both values of each option in one group, and the openapi.paths-bodies-as-definitions recommender rule recommends both as-definitions values.
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Option types and configuration contract src/datamodel_code_generator/enums.py, src/datamodel_code_generator/arguments.py, src/datamodel_code_generator/config.py, src/datamodel_code_generator/base_config.py, src/datamodel_code_generator/_types/*, src/datamodel_code_generator/cli_options.py, src/datamodel_code_generator/__init__.py, tests/main/test_public_api_signature_baseline.py, tests/data/expected/main/input_model/config_class.py |
Adds ConstructorFieldOrder and OpenAPIAsDefinitions. Replaces the related boolean configuration fields with sequence-valued fields and updates CLI options and public signature baselines. |
Parser selection and preset values src/datamodel_code_generator/parser/base.py, src/datamodel_code_generator/parser/openapi.py, src/datamodel_code_generator/__init__.py, src/datamodel_code_generator/preset.py, tests/main/test_preset_opt_in_options.py, tests/main/test_preset_opt_in_options.refs, tests/data/expected/main/preset_opt_in_options/* |
Parser selection checks the new enum values. Presets set list-valued options, and tests compare TOML list configuration with equivalent CLI arguments, including an empty list under a preset. |
Documentation and option test updates docs/*, src/datamodel_code_generator/_parse_memo.py, src/datamodel_code_generator/_recommend/_signals.py, src/datamodel_code_generator/model/*, src/datamodel_code_generator/parser/_finality.py, src/datamodel_code_generator/parser/_pass_decls.py, src/datamodel_code_generator/parser/_passes/render_prep.py, tests/main/jsonschema/*, tests/main/openapi/*, tests/parser/test_pipeline.py |
Updates option references and examples. Existing tests use the consolidated option names and values for constructor ordering and OpenAPI definition modes. |
Priority:
Estimated code review effort: 3 (Moderate) | ~25 minutes
Change: Refactor
Possibly related issues
- datamodel-code-generator/datamodel-code-generator#5155: The paths-bodies behavior is exposed through the new
--openapi-as-definitions paths-bodiesvalue. - datamodel-code-generator/datamodel-code-generator#5176: The ref-components behavior is exposed through the new
--openapi-as-definitions ref-componentsvalue.
Possibly related PRs
- datamodel-code-generator/datamodel-code-generator#5190: Introduced the reference-component option and configuration that this change replaces.
- datamodel-code-generator/datamodel-code-generator#5207: Moves constructor-field ordering passes into shared modules; this change updates the configuration values that select those modes.
- datamodel-code-generator/datamodel-code-generator#5158: Centralizes OpenAPI operation-schema dispatch, including the inline-body branch whose configuration value changes here.
Suggested labels: breaking-change
Merge Risk: 
Minimal · up to 0a01f
-
The consolidated options appear mergeable after normal checks; the inspected configuration paths retain their independent behaviors.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 inconclusive Passed checks: 4 passedFull details: Docstring Coverage
-
Explanation
Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 24 functions across 27 files. (11 skipped: 9 unsupported, 2 too large.)
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
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
-
- 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.
Comment @coderabbitai help to get the list of available commands.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour 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. |
Merging this PR will degrade performance by 18.03%2 warnings
Warning Please fix the performance issues or acknowledge them on CodSpeed. Performance Changes
Tip Investigate this regression by commenting Comparing Footnotes
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Summary by CodeRabbit