OpenAPITools / OpenAPITools/openapi-generator
[REQ] Ability to restrict generated model/api files to only those required by --openapi-normalizer FILTER="" APIs
Nobody has claimed this yet.
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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