Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughAdds a new CLI flag Changes
Sequence Diagram(s)sequenceDiagram
participant CLI as CLI (click)
participant Main as main()/generate_code()
participant Parser as OpenAPIParser
participant FS as FileWriter
CLI->>Main: parse args (including --reuse-model)
Main->>Parser: instantiate with reuse_model flag
Parser->>Parser: detect identical schemas -> reuse model types
Parser->>FS: emit models.py, main.py using reused types
FS-->>CLI: generated files written
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
|
📚 Docs Preview: https://pr-568.fastapi-code-generator.pages.dev |
Merging this PR will improve performance by 52.34%
|
| Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|
| ⚡ | test_generate_default_template_benchmark |
52.4 ms | 34.4 ms | +52.34% |
Comparing support-custom-models (a6d3362) with main (71ddd8b)
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #568 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 17 17
Lines 1344 1351 +7
Branches 139 139
=========================================
+ Hits 1344 1351 +7
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
a513a0b to
51e6842
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
fastapi_code_generator/prompt_data.py (1)
188-189: Clarify the--reuse-modelhelp text for user-facing docs.Current wording is hard to parse. Consider a clearer sentence so generated CLI/help docs are easier to understand.
✏️ Suggested wording update
- 'description': 'Reuse models on the field when a module has the ' - 'model with the same content.', + 'description': 'Reuse an existing model when another model has ' + 'the same fields and content.',🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@fastapi_code_generator/prompt_data.py` around lines 188 - 189, Update the user-facing help text for the --reuse-model flag in prompt_data.py by replacing the current confusing 'description' string with a clearer sentence; locate the description value associated with the '--reuse-model' flag (the 'description' key in the prompt_data.py entry for reuse-model) and change it to a concise message such as: "Reuse identical model definitions across modules and fields so the generator treats models with the same content as the same type." Ensure the updated string is grammatical and user-facing appropriate.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@fastapi_code_generator/prompt_data.py`:
- Around line 188-189: Update the user-facing help text for the --reuse-model
flag in prompt_data.py by replacing the current confusing 'description' string
with a clearer sentence; locate the description value associated with the
'--reuse-model' flag (the 'description' key in the prompt_data.py entry for
reuse-model) and change it to a concise message such as: "Reuse identical model
definitions across modules and fields so the generator treats models with the
same content as the same type." Ensure the updated string is grammatical and
user-facing appropriate.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 7a2d470e-44b6-4b75-ba7d-f524bb1f8ace
📒 Files selected for processing (9)
README.mddocs/cli-reference.mddocs/index.mddocs/llms-full.txtfastapi_code_generator/_types/generate_config_dict.pyfastapi_code_generator/cli.pyfastapi_code_generator/config.pyfastapi_code_generator/prompt_data.pytests/main/test_main.py
bf1ef0e to
20bdda2
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@tests/data/expected/openapi/default_template/body_and_parameters_reuse_model/main.py`:
- Around line 39-44: The generated functions convert1 and convert2 currently use
a parameter named format which shadows the builtin; update the code generator to
emit a safe parameter name (e.g., format_) and wire the original API name via
FastAPI Query alias: for convert1 change signature to use format_: Optional[str]
= Query('pdf', alias='format') and for convert2 use format_: Optional[str] =
Query(None, alias='format'); ensure the generator also adds the necessary import
for Query and preserves the Request and return types.
- Around line 119-121: The parameter annotation for body in function
put_pets_pet_id is inconsistent with its default None; update the type from
PetForm to Optional[PetForm] (and import typing.Optional if not already) so the
signature reads body: Optional[PetForm] = None, ensuring the function annotation
matches the None default.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: ed049ba9-a843-44ab-8644-88bf0689821d
📒 Files selected for processing (11)
README.mddocs/cli-reference.mddocs/index.mddocs/llms-full.txtfastapi_code_generator/_types/generate_config_dict.pyfastapi_code_generator/cli.pyfastapi_code_generator/config.pyfastapi_code_generator/prompt_data.pytests/data/expected/openapi/default_template/body_and_parameters_reuse_model/main.pytests/data/expected/openapi/default_template/body_and_parameters_reuse_model/models.pytests/main/test_main.py
✅ Files skipped from review due to trivial changes (6)
- fastapi_code_generator/_types/generate_config_dict.py
- README.md
- tests/data/expected/openapi/default_template/body_and_parameters_reuse_model/models.py
- docs/index.md
- docs/llms-full.txt
- docs/cli-reference.md
🚧 Files skipped from review as they are similar to previous changes (3)
- fastapi_code_generator/config.py
- fastapi_code_generator/prompt_data.py
- tests/main/test_main.py
a7a16f7 to
9c42e57
Compare
f353f31 to
009129b
Compare
…ator into support-custom-models # Conflicts: # README.md # docs/cli-reference.md # docs/index.md # docs/llms-full.txt # docs/supported_formats.md # fastapi_code_generator/cli.py # fastapi_code_generator/config.py # fastapi_code_generator/prompt_data.py
Breaking Change AnalysisResult: No breaking changes detected Reasoning: The This analysis was performed by repository automation using PR labels and the |
Fixes: #479
Summary
--reuse-modelCLI option and pass it through to the OpenAPI parser--use-annotatedas the existing Annotated type-hint option for the issue's Annotated use caseTests
tox -e py314-parallel -- tests/main/test_main.py::test_generate_with_reuse_model tests/test_config.pytox -e py314-parallel -- tests/main/test_performance.py --benchmark-only --benchmark-min-rounds=5tox -e cli-docs -- --checktox -e config-types -- --checktox -e readmetox -e llms-txt -- --checktox -e typeSummary by CodeRabbit
New Features
Documentation
Tests