Skip to content

Improve code generation with fixes for recursion, aliasing, and modular references #484

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Apr 16, 2025

Conversation

sternakt
Copy link
Contributor

This PR introduces multiple improvements, bug fixes, and refactoring efforts focused on enhancing code generation and resolving several issues related to parsing and argument handling.

  • Updated datamodel-code-generator
Upgraded the dependency to leverage improved modular reference support.
  • Refactored parsing and operation logic
    • Refactored Operation.arguments and Operation.snake_case_arguments for better structure and readability.
  • Recursion Error & Duplicate Arguments
Resolved issues where recursive parsing or duplicate function arguments could occur.
  • Aliased Imports
    • Introduced a temporary patch_parse function that solves the issue with shadowed imports.
    • Fixed issues with shadowed or aliased imports that caused incorrect code generation.

Added new test examples for discovered failing cases:

  • tests/data/openapi/default_template/discriminator_in_root_with_properties.yaml
  • tests/data/openapi/default_template/duplicate_anonymus_parameter.yaml
  • tests/data/openapi/default_template/duplicate_param.yaml
  • tests/data/openapi/default_template/modular_reference.yaml
  • tests/data/openapi/default_template/recursion.yaml
  • tests/data/openapi/default_template/shadowed_imports.yaml

Copy link

codecov bot commented Apr 16, 2025

Codecov Report

Attention: Patch coverage is 90.27027% with 18 lines in your changes missing coverage. Please review.

Project coverage is 90.59%. Comparing base (3342f58) to head (748151b).
Report is 31 commits behind head on master.

Files with missing lines Patch % Lines
fastapi_code_generator/parser.py 81.35% 11 Missing ⚠️
fastapi_code_generator/patches.py 94.01% 7 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #484      +/-   ##
==========================================
+ Coverage   89.78%   90.59%   +0.81%     
==========================================
  Files           5        7       +2     
  Lines         421      585     +164     
==========================================
+ Hits          378      530     +152     
- Misses         43       55      +12     
Flag Coverage Δ
unittests 90.59% <90.27%> (+0.81%) ⬆️

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.

* fixe optional types and unions

* poetry lock rerun

* Python 3.8 removed

* Python 3.13 removed
@davorrunje davorrunje merged commit b2df313 into koxudaxi:master Apr 16, 2025
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants