Skip to content
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

[BUG][PYTHON-FASTAPI] Generator README.md uses hard-coded default packageName #19480

Closed
5 of 6 tasks
DavidRV00 opened this issue Aug 28, 2024 · 1 comment · Fixed by #20371
Closed
5 of 6 tasks

[BUG][PYTHON-FASTAPI] Generator README.md uses hard-coded default packageName #19480

DavidRV00 opened this issue Aug 28, 2024 · 1 comment · Fixed by #20371

Comments

@DavidRV00
Copy link
Contributor

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

When I run the python-fastapi generator, with the python-fastapi templates provided in this repo, and specify packageName, the generated README.md doesn't pick it up for the example uvicorn command: PYTHONPATH=src uvicorn openapi_server.main:app --host 0.0.0.0 --port {{serverPort}}

openapi-generator version

Latest master branch as of Aug 28 2024.

OpenAPI declaration file content or url

I'm using the provided petstore.yaml, but it shouldn't matter.

Generation Details
openapi-generator generate \
    -i https://raw.githubusercontent.com/openapitools/openapi-generator/master/modules/openapi-generator/src/test/resources/3_0/petstore.yaml \
    -g python-fastapi \
    -t modules/openapi-generator/src/main/resources/python-fastapi \
    --additional-properties packageName=my_custom_name,fastapiImplementationPackage=my_custom_name.impl \
    -o ~/myprojects/api
Steps to reproduce

Run the above generator command and open the README.md. You will see that the uvicorn command specifies openapi_server.main:app even though packageName was used to specify something other than openapi_server (should be my_custom_name.main:app)

Related issues/PRs
Suggest a fix

Change the line in the provided template README.mustache from:

PYTHONPATH=src uvicorn openapi_server.main:app --host 0.0.0.0 --port {{serverPort}}

to:

PYTHONPATH=src uvicorn {{packageName}}.main:app --host 0.0.0.0 --port {{serverPort}}
@wing328
Copy link
Member

wing328 commented Aug 29, 2024

can you please file a PR with the suggested fix?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants