Skip to content

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

@DavidRV00

Description

@DavidRV00

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}}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions