Skip to content

Add support for additional_imports in extra-template-data JSON#2793

Merged
koxudaxi merged 1 commit intomainfrom
feature/additional-imports-in-extra-template-data
Dec 24, 2025
Merged

Add support for additional_imports in extra-template-data JSON#2793
koxudaxi merged 1 commit intomainfrom
feature/additional-imports-in-extra-template-data

Conversation

@koxudaxi
Copy link
Copy Markdown
Owner

Fixes: #2421

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Dec 24, 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 59 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 602193a and f243a2d.

⛔ Files ignored due to path filters (3)
  • tests/data/graphql/additional-imports-in-extra-template-data.json is excluded by !tests/data/**/*.json and included by none
  • tests/data/graphql/additional-imports-list-format.json is excluded by !tests/data/**/*.json and included by none
  • tests/data/graphql/additional-imports-partial.json is excluded by !tests/data/**/*.json and included by none
📒 Files selected for processing (2)
  • src/datamodel_code_generator/__main__.py
  • tests/main/graphql/test_main_graphql.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/additional-imports-in-extra-template-data

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.

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Dec 24, 2025

CodSpeed Performance Report

Merging #2793 will not alter performance

Comparing feature/additional-imports-in-extra-template-data (f243a2d) with main (f59786f)1

Summary

✅ 73 untouched
⏩ 10 skipped2

Footnotes

  1. No successful run was found on main (602193a) during the generation of this report, so f59786f was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

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

@koxudaxi koxudaxi enabled auto-merge (squash) December 24, 2025 19:31
@koxudaxi koxudaxi merged commit 0efefaf into main Dec 24, 2025
36 checks passed
@koxudaxi koxudaxi deleted the feature/additional-imports-in-extra-template-data branch December 24, 2025 19:34
@codecov
Copy link
Copy Markdown

codecov Bot commented Dec 24, 2025

Codecov Report

❌ Patch coverage is 92.30769% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 99.47%. Comparing base (f59786f) to head (f243a2d).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
src/datamodel_code_generator/__main__.py 88.23% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2793      +/-   ##
==========================================
- Coverage   99.48%   99.47%   -0.02%     
==========================================
  Files          88       88              
  Lines       13365    13412      +47     
  Branches     1565     1573       +8     
==========================================
+ Hits        13296    13341      +45     
  Misses         36       36              
- Partials       33       35       +2     
Flag Coverage Δ
unittests 99.47% <92.30%> (-0.02%) ⬇️

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.

@github-actions
Copy link
Copy Markdown
Contributor

Breaking Change Analysis

Result: No breaking changes detected

Reasoning: PR #2793 adds a new feature allowing users to specify additional_imports within the --extra-template-data JSON file, which is then merged with the --additional-imports CLI option. This is purely additive functionality. While the implementation uses .pop() to remove the additional_imports field from extra_template_data before passing to templates, additional_imports was not a documented or supported field in extra-template-data before this PR. The built-in Jinja2 templates do not use this field. Users with custom templates that happened to use a field named additional_imports for their own purposes would be affected, but this would be an undocumented usage pattern. The existing --additional-imports CLI option continues to work as before, and users can now alternatively (or additionally) specify imports in their extra-template-data JSON. No changes to generated code output, CLI interface signatures, default behavior, or Python version support.


This analysis was performed by Claude Code Action

koxudaxi added a commit that referenced this pull request Dec 25, 2025
* Add --collapse-root-models-name-strategy option

* docs: update CLI reference documentation and prompt data

🤖 Generated by GitHub Actions

* Add pragma no cover for defensive edge cases

* Achieve 100% diff coverage for collapse-root-models-name-strategy

* Use cast instead of type ignore comment

* Remove line comments from collapse-root-models implementation

* Add complex e2e tests for collapse-root-models-name-strategy

* Update reference metadata when renaming in parent strategy

* Refactor collapse-root-models tests to use parameterization for v1/v2

* Add schema path context to error messages (#2786)

* Return str or dict when output=None in generate() (#2787)

* Add --http-timeout CLI option (#2788)

* Add --http-timeout CLI option for configurable HTTP request timeout

* docs: update CLI reference documentation and prompt data

🤖 Generated by GitHub Actions

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

* Pass schema extensions to templates (#2790)

* Pass schema extensions to templates

* Move model_base import to top of file

* Add schema extensions documentation

Document how x-* schema extensions are passed to custom templates
via the extensions variable, with examples for database model
configuration and other use cases.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

* Add propertyNames and x-propertyNames support (#2789)

* Add propertyNames and x-propertyNames support

* Fix Pydantic v1 compatibility for x-propertyNames

Use the model_validate utility function from util module instead of
calling JsonSchemaObject.model_validate() directly, which only
exists in Pydantic v2.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

* Add test for x-propertyNames non-dict branch coverage

Test that x-propertyNames with non-dict value (e.g., boolean) is
correctly ignored, achieving 100% diff coverage.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

* Add support for additional_imports in extra-template-data JSON (#2793)

* Update zensical to 0.0.15 (#2794)

* Add --use-field-description-example option (#2792)

* Add --use-field-description-example option

* docs: update CLI reference documentation and prompt data

🤖 Generated by GitHub Actions

* Add tests for complete branch coverage of docstring property

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

* Fix formatting in test file

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
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.

[Enhancement] Add support for specifying additional-imports in the extra-template-data json file.

1 participant