Open OnkelTem opened 4 years ago
I am too facing the same issue with openapi-generator-cli v5.0.1. It just ignores the .openapi-generator-ignore
file and overwrites it as well every time.
we just released v5.1.0 (https://twitter.com/oas_generator/status/1373636654024380423). can you give it a try to see if you're still facing the same issue?
@wing328 Imho it still does not work.
Please have a look at this repos https://github.com/rcky/openapi-generator-all-of using
generate -i /local/openapi/openapi.yml -g php -o /local --ignore-file-override=/local/openapi/.openapi-generator-ignore.dist
to generate the sources. As you can see in the repos, the test/
folder is still generated.
It worked for me with v5.1.0
The ignore file format doesn't appear to handle directories relative to the current working directory.
For example, you can't successfully ignore a path like ../../.dockerignore
, which is useful when passing a relative parent directory to --output
(like --output ../..
).
Is there a resolution for this issue please? I am facing the same thing with SpringJava generator. Whatever I put on the ignore file path is ignored and it always fall back to the original ignore file.
I am also facing similar issue. I am using CLI v5.1.0 to generate aspnetcore server and created ignore file with file name entry to ignore but CLI ignoring the ignore file name and overwriting my existing file. I have ignore file in my root folder as per document.
@pawar-ram did you ever get the aspnetcore generator to respect your ignore file? thanks...
@pawar-ram did you ever get the aspnetcore generator to respect your ignore file? thanks...
I faced the same problem
Here is an example no how to use .openapi-generator-ignore: https://github.com/OpenAPITools/openapi-generator/blob/master/samples/client/petstore/csharp-netcore/OpenAPIClientCore/.openapi-generator-ignore#L3
Hello! It's not about CLI tool but may be helpful. I'm using the gradle plugin org.openapi.generator version 5.0.0
My .openapi-generator-ignore is in the root of the project . In the openApiGenerate
configuration I defined ignoreFileOverride.set("$rootDir/.openapi-generator-ignore")
and the ignoring works if I put paths from the project root.
For example. My output directory is $rootDir/backend/build/generated
, so README.md generates in $rootDir/backend/build/generated/openapi/README.md
. And the ignoring works if I put backend/build/generated/openapi/README.md
in .openapi-generator-ignore.
I'm using the gradle plugin org.openapi.generator version 5.0.0 My .openapi-generator-ignore is in the root of the project . In the
openApiGenerate
configuration I definedignoreFileOverride.set("$rootDir/.openapi-generator-ignore")
and the ignoring works if I put paths from the project root. For example. My output directory is$rootDir/backend/build/generated
, so README.md generates in$rootDir/backend/build/generated/openapi/README.md
. And the ignoring works if I putbackend/build/generated/openapi/README.md
in .openapi-generator-ignore.
I'm using gradle plugin version '6.0.1' and your solution didn't work:
I output my files here: $buildDir/generated
.
Path from content root to generated README.md
is build/generated/README.md
.
Despite specifying that in ignore file, it still appears on generation.
I also tried generated/README.md
and just README.md
.
What did finally work was: **/README.md
Here's the final example file for generating code for spring with Delegator pattern:
**/README.md
**/pom.xml
**/src/test/
**/src/main/java/**/configuration/
**/OpenApiGeneratorApplication.java
**/RFC3339DateFormat.java
**/src/main/resources/
I'm using the gradle plugin org.openapi.generator version 5.0.0 My .openapi-generator-ignore is in the root of the project . In the
openApiGenerate
configuration I definedignoreFileOverride.set("$rootDir/.openapi-generator-ignore")
and the ignoring works if I put paths from the project root. For example. My output directory is$rootDir/backend/build/generated
, so README.md generates in$rootDir/backend/build/generated/openapi/README.md
. And the ignoring works if I putbackend/build/generated/openapi/README.md
in .openapi-generator-ignore.I'm using gradle plugin version '6.0.1' and your solution didn't work:
I output my files here:
$buildDir/generated
. Path from content root to generatedREADME.md
isbuild/generated/README.md
. Despite specifying that in ignore file, it still appears on generation.I also tried
generated/README.md
and justREADME.md
. What did finally work was:**/README.md
Here's the final example file for generating code for spring with Delegator pattern:**/README.md **/pom.xml **/src/test/ **/src/main/java/**/configuration/ **/OpenApiGeneratorApplication.java **/RFC3339DateFormat.java **/src/main/resources/
I am using version 6.2.1 and generating a Java client and running it with gradle plugin.
I can confirm that the solution is to use **
My .openapi-generator-ignore is just this:
**build.gradle
I believe the docs should be updated?
Hello! It's not about CLI tool but may be helpful. I'm using the gradle plugin org.openapi.generator version 5.0.0 My .openapi-generator-ignore is in the root of the project . In the
openApiGenerate
configuration I definedignoreFileOverride.set("$rootDir/.openapi-generator-ignore")
and the ignoring works if I put paths from the project root. For example. My output directory is$rootDir/backend/build/generated
, so README.md generates in$rootDir/backend/build/generated/openapi/README.md
. And the ignoring works if I putbackend/build/generated/openapi/README.md
in .openapi-generator-ignore.
I needed the same solution but in maven. Your comment has helped me to solve my problem:
Problem: In my case, I had two folders A and B. In A I have my main project codes which uses openapi-generator-maven-plugin in pom.xml to generate source codes into the folder B (which is outside root folder A). The problem I had is that I keep a pom.xml file inside B and every time, openapi-generator-maven-plugin generates code it overwrites my pom.xml in B.
Solution I already had a '.openapi-generator-ignore' file in root folder A and I tried adding ../B/pom.xml in it. But the ignore file cannot ignore files outside the root folder A. After reading 'openapi-generator-maven-plugin' documentation and your comment, I got the solution.
pom.xml .openapi-generator-ignore
The first one for keeping pom.xml intact and second one for keeping the ignore file intact.
<executions><configuration>
part of 'openapi-generator-maven-plugin', I added the following:<ignoreFileOverride>../B/.openapi-generator-ignore</ignoreFileOverride>
Now the plug in will use the ignore file inside B and will use the relative paths inside B.
Thus the files inside B are not overwritten even though the generated source codes are falling inside it.
I think you can do the same for gradle as well.
I ran into this issue and figured out my paths in the ignore file was wrong. I have all the generated stuff in the folder <root>/generated
and my override ignore file is at <root>
. The content ignore file was like this:
.npmignore
git_push.sh
It should have been like this:
generated/.npmignore
generated/git_push.sh
Once I used these new paths, it finally worked.
For the following CLI command:
generate -i /local/_spec/openapi.yml -g php -o /local/src --ignore-file-override=/local/_spec/.openapi-generator-ignore
ignoring does not work as intended as files in /local/_spec/
and /local/src/
do not share the exactly identical hierarchical path, leading to confusing results of CodegenIgnoreProcessor::allowsFile()
.
IMHO --ignore-file-override
option (with arbitrary location, e.g. /local/_spec/.openapi-generator-ignore
) should behave exactly the same as storing this very file directly file into output folder (e.g. /local/src/.openapi-generator-ignore
).
Especially, the behavior documented in https://openapi-generator.tech/docs/faq-extending/#how-do-i-skip-files-during-code-generation should be retained:
The contents of that file will be evaluated relative to the output directory.
Side note:
The mentioned workaround of prefixing every rule with **/
is limited to trivial cases as excluding "deep paths" while including others may become tedious for paths with common sub-parts:
# Exclude general README.md
docs/README.md
# But KEEP specific ones:
# models/docs/README.md
# api/docs/README.md
I am at 2.13.5 and it doesn't work for me either. The option is completly ignored. I just moved the ignore file one level up to prevent it from being deleted.
Command:
rimraf ./src/openapi && openapi-generator-cli generate --generator-key csvbe --ignore-file-override=./src/.openapi-generator-ignore && npx prettier ./src/openapi --write
Note: I have to use rimraf because the generator does not remove outdated files itself. I also need a solution which works for POSIX and Windows.
I run generation using
openapitools/openapi-generator-cli
.And whevern I write inside
.openapi-generator-ignore
gets absolutely ignored.