OpenAPITools / OpenAPITools/openapi-generator
[BUG] If cleanupOutput is set to true, then .openapi-generator-ignore is deleted
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
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: https://github.com/OpenAPITools/openapi-generator/pull/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.
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
Review PR 13659 and reproduce the behavior with the Gradle command and the .openapi-generator-ignore example described in the issue. Trace how cleanupOutput handles .openapi-generator and its ignore file; done means listed files remain protected and the ignore file is not deleted or overwritten during generation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- build-system, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100