OpenAPITools / OpenAPITools/openapi-generator

[BUG] missing base classes `*_api_base.py` for `python-fastapi` server templates

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

Nobody has claimed this yet.

Issue: Bug Server: Python
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

I try to reproduce the minimal pet store example for the python-fastapi template in this public repository. As I understand, each mustache template generates one or more Python files, see examples in the table below.

mustache template generated code
api.mustache pet_api.py, store_api.py, user_api.py
base_api.mustache pet_api_base.py, store_api_base.py, user_api_base.py

As can be seen here, six classes are supposed to be generated: 3 *_api.py and 3 *_api_base.py.
As can be seen in my test run, only the 3 *_api.py are generated. The 3 *_api_base.py classes are missing.

Expected behaviour: Generation of six Python files *_api.py and *_api_base.py.
Actual behaviour: Generation of only three Python files *_api.py. The three files *_api_base.py are missing.

openapi-generator version

6.6.0 on macOS 13.4.1

OpenAPI declaration file content or url
Generation Details

See this public repository and above.

Steps to reproduce

Run the generate.sh script with default templates.

Related issues/PRs

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

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 python-fastapi server templates, especially api.mustache and base_api.mustache, then inspect the generation flow used by the linked generate.sh script. Reproduce the pet store generation and compare the output with samples/server/petstore/python-fastapi/src/openapi_server/apis. Done means the three expected *_api_base.py files are generated alongside the *_api.py files.

Written by the indexing model from the issue text.

Assessment

Tech stack
fastapi, python
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.