OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
21.44k stars 6.49k forks source link

[BUG] openapi-generator is generating different code without and with default mustache templates #16192

Open LarsParTec opened 1 year ago

LarsParTec commented 1 year ago

Bug Report Checklist

Description

The openapi-generator command line tool is generating Python FastAPI server code (python-fastapi) from the pet store API specs. In the first run without explicit templates. In the second run with the default templates in the openapi-generator repository.

openapi-generator generate -g python-fastapi -i petstore.yaml -o .
openapi-generator generate -g python-fastapi -i petstore.yaml -o . -t default_templates

Expected behaviour: The generated code is identical in both cases. Actual behaviour: The generated code differs.

openapi-generator version

6.6.0 on macOS 13.4.1

OpenAPI declaration file content or url

An example is given in this public repository. The current openapi-generator repository is added as submodule. For the example we make use of the pet store specs and the python-fastapi mustache templates.

This commit shows the difference of the generated code with and without explicit -t templates.

Generation Details

See this public repository and above.

Steps to reproduce

Run the generate.sh script without and with templates.

Related issues/PRs

https://github.com/OpenAPITools/openapi-generator/issues/16200

Suggest a fix

None.

wing328 commented 1 year ago

I did a test with the latest master and -t works for me:

java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate  -g python-fastapi -i modules/openapi-generator/src/test/resources/3_0/python-fastapi/petstore.yaml -o /tmp/pf/ -t /tmp/python-fastapi

Here is the diff in the output:

Screen Shot 2023-07-31 at 4 32 28 pm