Skip to content

[BUG] If cleanupOutput is set to true, then .openapi-generator-ignore is deleted #15047

@gilbertotcc

Description

@gilbertotcc

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

I'm using the Gradle plugin of the OpenAPI generator and I've upgraded from version 6.2.0 to 6.4.0. With the new version I've tried the cleanupOutput parameter to clean up the generated files before the generation of new ones.

Unfortunately, with that parameter set to true, the .openapi-generator-ignore is not honored. In other terms, generation of new files also delete and overwrite .openapi-generator-ignore that is a bit disturbing if I need to use that file to prevent the manipulation of certain files.

Is this behavior expected or it is an issue?

openapi-generator version

6.4.0.

OpenAPI declaration file content or url

The issue is not related to the OpenAPI parsing.

Steps to reproduce

I start from this content (I've omitted some files):

% tree -a src/gen
src/gen
└── java
    ├── .openapi-generator
    │   ├── FILES
    │   └── VERSION
    ├── .openapi-generator-ignore
    └── com
        └── example
            └── package
                └── api
                    ├── ApiUtil.java
                    ├── ...
                    └── model
                        ├── ...

8 directories, 30 files

Herein the content of .openapi-generator.

# OpenAPI Generator Ignore
pom.xml
README.md

Then, I try this:

% ./gradlew clean openApiGenerate

And the resulting directory tree is the following:

% tree src/gen
src/gen
└── java
    ├── README.md
    ├── com
    │   └── example
    │       └── package
    │           └── api
    │               ├── ApiUtil.java
    │               ├── ...
    │               └── model
    │                   ├── ...
    └── pom.xml

7 directories, 29 files

Where the cleanup also delete the content of the README.md with default content:


# OpenAPI generated API stub

Spring Framework stub


## Overview
This code was generated by the [OpenAPI Generator](https://openapi-generator.tech) project.
By using the [OpenAPI-Spec](https://openapis.org), you can easily generate an API stub.
This is an example of building API stub interfaces in Java using the Spring framework.
...

And .openapi-generator overwritten by a default file:

# OpenAPI Generator Ignore
# Generated by openapi-generator https://github.com/openapitools/openapi-generator

# Use this file to prevent files from being overwritten by the generator.
...
Related issues/PRs

This is the PR that introduced the new functionality: #13659.

Suggest a fix

I think that the problem is caused by the functionality that ignores the content within .openapi-generator, if defined. The fix should access that file and manage its content to not cleanup the files that are listed there.

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