From c108ff41a99ae8eb3c99a000a652b68803f6c3e5 Mon Sep 17 00:00:00 2001 From: Inf1mum Date: Sat, 7 Nov 2026 20:05:16 +0300 Subject: [PATCH 1/2] fix(config): add openapiGeneratorIgnoreList to the config schema The runtime option openapiGeneratorIgnoreList works but was missing from apps/generator-cli/src/config.schema.json, so editors flag configs using it as invalid (Fixes #1138). The option is typed as Set upstream in openapi-generator's GeneratorSettings/CodegenConfigurator and pre-populates the .openapi-generator-ignore file, so the new property accepts an array of strings; a comma separated list is accepted as well, mirroring the --openapi-generator-ignore-list CLI flag. Adds ajv-based tests validating the schema itself and configs using the new option. --- apps/generator-cli/src/config.schema.json | 14 ++++ apps/generator-cli/src/config.schema.spec.ts | 72 ++++++++++++++++++++ package.json | 1 + yarn.lock | 2 +- 4 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 apps/generator-cli/src/config.schema.spec.ts diff --git a/apps/generator-cli/src/config.schema.json b/apps/generator-cli/src/config.schema.json index 0979e1f6ff7..ebc3d553bf4 100644 --- a/apps/generator-cli/src/config.schema.json +++ b/apps/generator-cli/src/config.schema.json @@ -446,6 +446,20 @@ } } }, + "openapiGeneratorIgnoreList": { + "description": "specifies a list of files or patterns to be ignored during generation, pre-populating the .openapi-generator-ignore file in the output folder. Can be provided as an array of strings or a comma separated list", + "anyOf": [ + { + "type": "string" + }, + { + "type": "array", + "items": { + "type": "string" + } + } + ] + }, "packageName": { "type": "string", "description": "package for generated classes (where supported)" diff --git a/apps/generator-cli/src/config.schema.spec.ts b/apps/generator-cli/src/config.schema.spec.ts new file mode 100644 index 00000000000..ee50d25e5dd --- /dev/null +++ b/apps/generator-cli/src/config.schema.spec.ts @@ -0,0 +1,72 @@ +import Ajv from 'ajv'; + +// eslint-disable-next-line @typescript-eslint/no-var-requires +const configSchema = require('./config.schema.json'); + +// strict mode is disabled because the `generator-cli.repository` block uses +// non-standard nesting (queryUrl/downloadUrl are not declared as properties), +// which ajv strict mode reports as unknown keywords +const validate = new Ajv({ strict: false }).compile(configSchema); + +const baseConfig = { + $schema: './node_modules/@openapitools/openapi-generator-cli/config.schema.json', + spaces: 2, + 'generator-cli': { + version: '7.12.0', + generators: { + kotlin: { + generatorName: 'kotlin', + inputSpec: './openapi/petstore.yaml', + output: './generated/kotlin', + }, + }, + }, +}; + +function configWithIgnoreList(ignoreList: unknown) { + return { + ...baseConfig, + 'generator-cli': { + ...baseConfig['generator-cli'], + generators: { + kotlin: { + ...baseConfig['generator-cli'].generators.kotlin, + openapiGeneratorIgnoreList: ignoreList, + }, + }, + }, + }; +} + +describe('config.schema', () => { + it('is a valid JSON schema', () => { + expect(new Ajv({ strict: false }).validateSchema(configSchema)).toBe(true); + }); + + it('validates a config without openapiGeneratorIgnoreList', () => { + expect(validate(baseConfig)).toBe(true); + expect(validate.errors).toBeNull(); + }); + + describe('openapiGeneratorIgnoreList', () => { + it.each([[['README.md', 'pom.xml', 'docs/*.md']], [['single']], [[]]])( + 'accepts the array of strings %j', + (ignoreList) => { + expect(validate(configWithIgnoreList(ignoreList))).toBe(true); + expect(validate.errors).toBeNull(); + } + ); + + it('accepts a comma separated list', () => { + expect(validate(configWithIgnoreList('README.md,pom.xml'))).toBe(true); + expect(validate.errors).toBeNull(); + }); + + it.each([[42], [true], [null], [[42]], [[{}]], [{}]])( + 'rejects the invalid value %j', + (invalidValue) => { + expect(validate(configWithIgnoreList(invalidValue))).toBe(false); + } + ); + }); +}); diff --git a/package.json b/package.json index 423907634ef..32a3aa91c4f 100644 --- a/package.json +++ b/package.json @@ -119,6 +119,7 @@ "@types/node": "^22.0.0", "@typescript-eslint/eslint-plugin": "7.18.0", "@typescript-eslint/parser": "7.18.0", + "ajv": "^8.20.0", "dotenv": "17.4.2", "eslint": "9.39.5", "eslint-config-prettier": "^10.0.0", diff --git a/yarn.lock b/yarn.lock index 380e4b89d74..0b2ddd4458a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4244,7 +4244,7 @@ ajv@^6.12.5, ajv@^6.14.0: json-schema-traverse "^0.4.1" uri-js "^4.2.2" -ajv@^8.0.0, ajv@^8.11.0, ajv@^8.12.0, ajv@^8.9.0: +ajv@^8.0.0, ajv@^8.11.0, ajv@^8.12.0, ajv@^8.20.0, ajv@^8.9.0: version "8.20.0" resolved "https://registry.yarnpkg.com/ajv/-/ajv-8.20.0.tgz#304b3636add88ba7d936760dd50ece006dea95f9" integrity sha512-Thbli+OlOj+iMPYFBVBfJ3OmCAnaSyNn4M1vz9T6Gka5Jt9ba/HIR56joy65tY6kx/FCF5VXNB819Y7/GUrBGA== From 1fc35a7b93f164b5c0c9908e732bcf62036afbab Mon Sep 17 00:00:00 2001 From: Inf1mum Date: Sun, 8 Nov 2026 00:37:03 +0300 Subject: [PATCH 2/2] fix(generator): serialize array config values as comma separated lists buildCommand rendered array values through Object.entries, producing indexed assignments such as 0=README.md,1=pom.xml, so array configs like openapiGeneratorIgnoreList never reached the generator as the intended list. Array values are now joined with ',', matching the csv semantics of flags such as --openapi-generator-ignore-list; string and plain object values keep their existing serialization. --- .../app/services/generator.service.spec.ts | 27 +++++++++++++++++++ .../src/app/services/generator.service.ts | 5 ++++ 2 files changed, 32 insertions(+) diff --git a/apps/generator-cli/src/app/services/generator.service.spec.ts b/apps/generator-cli/src/app/services/generator.service.spec.ts index 93338ce87c1..580097b2cc9 100644 --- a/apps/generator-cli/src/app/services/generator.service.spec.ts +++ b/apps/generator-cli/src/app/services/generator.service.spec.ts @@ -104,6 +104,18 @@ describe('GeneratorService', () => { ext: '#{ext}', }, }, + ['ignore-list.json']: { + ignoreListArray: { + inputSpec: 'http://example.local/openapi.json', + output: 'ignore-list-array/#{name}', + openapiGeneratorIgnoreList: ['README.md', 'pom.xml', 'docs/*.md'], + }, + ignoreListString: { + inputSpec: 'http://example.local/openapi.json', + output: 'ignore-list-string/#{name}', + openapiGeneratorIgnoreList: 'README.md,pom.xml', + }, + }, }; const specFiles = { @@ -229,6 +241,21 @@ describe('GeneratorService', () => { ], ['none.json', []], ['also-none.json', []], + [ + 'ignore-list.json', + [ + cmd('[ignoreListArray] http://example.local/openapi.json', [ + `--input-spec="http://example.local/openapi.json"`, + `--output="ignore-list-array/openapi"`, + `--openapi-generator-ignore-list="README.md,pom.xml,docs/*.md"`, + ]), + cmd('[ignoreListString] http://example.local/openapi.json', [ + `--input-spec="http://example.local/openapi.json"`, + `--output="ignore-list-string/openapi"`, + `--openapi-generator-ignore-list="README.md,pom.xml"`, + ]), + ], + ], [ 'no-glob.json', [ diff --git a/apps/generator-cli/src/app/services/generator.service.ts b/apps/generator-cli/src/app/services/generator.service.ts index 327273e2fbe..c039ec94a0b 100644 --- a/apps/generator-cli/src/app/services/generator.service.ts +++ b/apps/generator-cli/src/app/services/generator.service.ts @@ -169,6 +169,11 @@ export class GeneratorService { .toLowerCase(); const value = (() => { + // arrays are passed as comma separated lists, matching the csv + // semantics of CLI flags like --openapi-generator-ignore-list + if (Array.isArray(v)) { + return `"${v.join(',')}"`; + } switch (typeof v) { case 'object': return `"${Object.entries(v)