OpenAPITools / OpenAPITools/openapi-generator

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

Open
#16,192 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

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

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the generate.sh script and reproduce both commands using petstore.yaml, comparing output with and without the default_templates directory. Inspect the python-fastapi templates under modules/openapi-generator/src/main/resources/python-fastapi and the related issue #16200; done means both generation paths produce identical code.

Written by the indexing model from the issue text.

Assessment

Tech stack
fastapi, openapi, python
Domain
api, cli, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.