Skip to content

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

Open
@Fjolnir-Dvorak

Description

@Fjolnir-Dvorak

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions