Skip to content

Add --naming-strategy and --duplicate-name-suffix CLI options#2761

Merged
koxudaxi merged 8 commits intomainfrom
feature/naming-strategy-option
Dec 23, 2025
Merged

Add --naming-strategy and --duplicate-name-suffix CLI options#2761
koxudaxi merged 8 commits intomainfrom
feature/naming-strategy-option

Conversation

@koxudaxi
Copy link
Copy Markdown
Owner

Fixes: #2042

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Dec 23, 2025

Warning

Rate limit exceeded

@koxudaxi has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 0 minutes and 3 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 419b1c2 and d50e389.

⛔ Files ignored due to path filters (3)
  • tests/data/jsonschema/naming_strategy/complex_input.json is excluded by !tests/data/**/*.json and included by none
  • tests/data/jsonschema/naming_strategy/input.json is excluded by !tests/data/**/*.json and included by none
  • tests/data/jsonschema/naming_strategy/primary_first_input.json is excluded by !tests/data/**/*.json and included by none
📒 Files selected for processing (23)
  • docs/cli-reference/index.md
  • docs/cli-reference/model-customization.md
  • docs/cli-reference/quick-reference.md
  • pyproject.toml
  • src/datamodel_code_generator/__init__.py
  • src/datamodel_code_generator/__main__.py
  • src/datamodel_code_generator/arguments.py
  • src/datamodel_code_generator/cli_options.py
  • src/datamodel_code_generator/parser/base.py
  • src/datamodel_code_generator/parser/graphql.py
  • src/datamodel_code_generator/parser/jsonschema.py
  • src/datamodel_code_generator/parser/openapi.py
  • src/datamodel_code_generator/reference.py
  • tests/data/expected/main/jsonschema/naming_strategy/complex_duplicate_suffix/output.py
  • tests/data/expected/main/jsonschema/naming_strategy/complex_numbered/output.py
  • tests/data/expected/main/jsonschema/naming_strategy/complex_parent_prefixed/output.py
  • tests/data/expected/main/jsonschema/naming_strategy/complex_primary_first/output.py
  • tests/data/expected/main/jsonschema/naming_strategy/duplicate_name_suffix/output.py
  • tests/data/expected/main/jsonschema/naming_strategy/full_path/output.py
  • tests/data/expected/main/jsonschema/naming_strategy/numbered/output.py
  • tests/data/expected/main/jsonschema/naming_strategy/parent_prefixed/output.py
  • tests/main/jsonschema/test_main_jsonschema.py
  • tests/main/test_main_general.py
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/naming-strategy-option

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.

🤖 Generated by GitHub Actions
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Dec 23, 2025

CodSpeed Performance Report

Merging #2761 will not alter performance

Comparing feature/naming-strategy-option (d50e389) with main (419b1c2)

Summary

✅ 73 untouched
⏩ 10 skipped1

Footnotes

  1. 10 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.

Comment thread src/datamodel_code_generator/__main__.py Dismissed
Comment thread src/datamodel_code_generator/__main__.py Dismissed
@codecov
Copy link
Copy Markdown

codecov Bot commented Dec 23, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.48%. Comparing base (419b1c2) to head (d50e389).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2761   +/-   ##
=======================================
  Coverage   99.47%   99.48%           
=======================================
  Files          85       85           
  Lines       12627    12721   +94     
  Branches     1506     1517   +11     
=======================================
+ Hits        12561    12655   +94     
  Misses         35       35           
  Partials       31       31           
Flag Coverage Δ
unittests 99.48% <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.

- Add test for --naming-strategy primary-first
- Add test for invalid JSON in --duplicate-name-suffix
- Add test for --parent-scoped-naming backward compat (CLI)
- Add test for generate() with parent_scoped_naming=True (API)
@koxudaxi koxudaxi merged commit 994cd34 into main Dec 23, 2025
38 checks passed
@koxudaxi koxudaxi deleted the feature/naming-strategy-option branch December 23, 2025 15:24
@github-actions
Copy link
Copy Markdown
Contributor

Breaking Change Analysis

Result: No breaking changes detected

Reasoning: This PR adds new features without breaking existing functionality. The new --naming-strategy and --duplicate-name-suffix CLI options are purely additive. The deprecated --parent-scoped-naming flag still works with full backward compatibility - it automatically maps to --naming-strategy parent-prefixed and only emits a deprecation warning. The default naming strategy is numbered, which preserves the existing default behavior for duplicate model names (e.g., Address, Address1, Address2). The new NamingStrategy enum and generate() function parameters are optional additions to the Python API. No changes affect generated code for existing users, no template updates are required, and no error handling behavior has changed.


This analysis was performed by Claude Code Action

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.

workaround: better class names

2 participants