OpenAPITools / OpenAPITools/openapi-generator

[REQ] Python FastAPI Server Code Generator Library Mode

Open
#21,079 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Enhancement: Feature
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Is your feature request related to a problem? Please describe.

Currently the server stub generated by OpenAPI Generator for Python FastAPI generator only provides support for generating complete server where we need to modify the generated code. The Spring or ASP.NET server generators have options such as delegatePattern or isLibrary in the configuration file which allows us to generate only the interfaces which can be implemented through a concrete class, which lets us easily update the OpenAPI schema and generate new interfaces without modifying existing code by hand.

Describe the solution you'd like

An option to generate the models and APIs as a library which can be published to a package repository and can be consumed by the implementing application.

Describe alternatives you've considered

We are currently updating the generated code through a bash script but that feels like a monkey patching rather than a solution itself as the script depends on the structure of the generated file, which too will change when changing the OpenAPI schema. Implementing a robust solution on the generator itself should be the way to go.

cc: @multani @fa0311 @krjakbrjak @tomplus @cbornet

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 by reviewing the Python FastAPI server generator and the analogous delegatePattern or isLibrary options in the Spring and ASP.NET generators mentioned in the issue. Define how models and APIs should be emitted as a consumable library, then verify that regeneration leaves implementing application code separate and that the generator can publish the resulting package.

Written by the indexing model from the issue text.

Assessment

Tech stack
fastapi, python
Domain
api, backend, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.