OpenAPITools / OpenAPITools/openapi-generator

[REQ] Ability to restrict generated model/api files to only those required by --openapi-normalizer FILTER="" APIs

Open
#20,929 3 comments 25 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.

I only need a handful of endpoints from the GitHub definition, but I still end up with 1741 model files, most of which are unused.

Describe the solution you'd like

It seems --openapi-normalizer FILTER="operationId:|tag:" could analyse its requests and responses to schedule production of only the model files it needs to compile.

Additionally, supporting FILTER="path:" would be useful if a third-party's definition file doesn't set tags or operationId at the granularity the user finds useful. Ideally it would be possible to have path:post:/app-manifests/{code}/conversions or similar.

While it seems unlikely someone might WANT all the model files even if they don't need the API files that use them, it's a change of behaviour, so perhaps --openapi-normalizer MODELS="required-only" would trigger it

Describe alternatives you've considered

I've used .openapi-generator-ignore to exclude everything from the api, model, infrastructure, and auth directories except for the api files I know I need, and then iteratively copy/pasting 'missing class' errors and converting them into exceptions to the directory-level excludes. I managed 145 files - 12% - but it was a nuisance to do and it's still not as minimal as it could be.

I considered editing GitHub's file down to only what I wanted, but that amounts to the same thing as the ignore file, but from the other end.

Additional context

This issue https://github.com/OpenAPITools/openapi-generator/issues/18897 is related, but --openapi-normalizer FILTER="operationId:apps/create-installation-access-token" only filters API - I still have a complete model directory even though the filtered API only needs a handful of the generated files.

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 --openapi-normalizer FILTER option and the related issue 18897, then define how operationId, tag, and path selections should determine required models. Consider the proposed MODELS="required-only" behavior; done means filtered APIs generate only the models they require while preserving current all-model generation by default.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, openapi
Domain
api, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.