openapi-generator: [BUG] --ignore-file-override option is ignored

I run generation using openapitools/openapi-generator-cli.

const DOCKER_IMG = 'openapitools/openapi-generator-cli';
const API_PATH = 'api/api.yaml';
const TEMPLATES_PATH = 'templates';
const IGNORE_FILE = '.openapi-generator-ignore';

const child = spawn('docker', [
  'run',
  '--rm',
  '--net=host',
  `--user=${uid}:${uid}`,
  '--mount',
  `type=bind,source=${path.join(__dirname)},target=/local`,
  DOCKER_IMG,
  'generate',
  '-i',
  path.join('/local', API_PATH),
  '-t',
  path.join('/local', TEMPLATES_PATH),
  '-c',
  path.join('/local', CONFIG),
  '--ignore-file-override=' + path.join('/local', IGNORE_FILE),
  '-g',
  'typescript-fetch',
  '-o',
  path.join('/local', 'output'),
]);

And whevern I write inside .openapi-generator-ignore gets absolutely ignored.

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Reactions: 3
  • Comments: 15 (2 by maintainers)

Most upvoted comments

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 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/

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.

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 ../..).