OpenAPITools / OpenAPITools/openapi-generator

[BUG][CORE] Api change with project regeneration yields unused files

Open
#4,076 0 comments 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
  • What's the version of OpenAPI Generator used?
    v4.1.3+
  • Have you search for related issues/PRs?
Description

If an api is updated and for example some model names changed which results into a new file the old file which is no longer needed is not removed thus the project accumulates garbage files.

openapi-generator version

v4.1.3+

Steps to reproduce

Generate a client/server, rename a model, regenerate. The old model name will still be existent.

Related issues/PRs
Suggest a fix

I talked with @jimschubert about this issue and he suggested to keep track of previously generated files which would result in following scenario:

  • On generation collect all files which were generated and persist those alongside the openapi generator version in .openapi.
  • On generation check if an old file list is available, delete all those files, generate code with new file list and warn about every file which is in the same directory as generated code but was not deleted since these could be outdated files. Do not delete a file if it is referenced in openapi-ignore.

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 reproducing the issue with an API model rename and regeneration, then trace how generated files and .openapi metadata are handled. Define done as tracking prior generated files, removing obsolete files unless protected by openapi-ignore, and warning about remaining possible outdated files.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
build-system, tooling
Issue type
Bug
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.