Add openapiGeneratorIgnoreList option to pre-populate .openapi-generator-ignore (#17164)

* add openapiGeneratorIgnoreList option to pre-populate .openapi-generator-ignore

* minor fix

* better code format

* add tests
This commit is contained in:
William Cheng
2023-11-23 11:10:29 +08:00
committed by GitHub
parent a93bab077f
commit 0dbc108d62
13 changed files with 270 additions and 25 deletions

View File

@@ -101,6 +101,9 @@ public class ConfigHelp extends OpenApiGeneratorCommand {
@Option(name = {"--language-specific-primitive"}, title = "language specific primitives", description = "displays the language specific primitives (types which require no additional imports, or which may conflict with user defined model names)")
private Boolean languageSpecificPrimitives;
@Option(name = {"--openapi-generator-ignore-list"}, title = "openapi generator ignore list", description = "displays the openapi generator ignore list")
private Boolean openapiGeneratorIgnoreList;
@Option(name = {"--reserved-words"}, title = "language specific reserved words", description = "displays the reserved words which may result in renamed model or property names")
private Boolean reservedWords;
@@ -588,6 +591,13 @@ public class ConfigHelp extends OpenApiGeneratorCommand {
sb.append(newline);
}
if (Boolean.TRUE.equals(openapiGeneratorIgnoreList)) {
sb.append(newline).append("OPENAPI GENERATOR IGNORE LIST").append(newline).append(newline);
String[] arr = config.openapiGeneratorIgnoreList().stream().sorted().toArray(String[]::new);
writePlainTextFromArray(sb, arr, optIndent);
sb.append(newline);
}
if (Boolean.TRUE.equals(reservedWords)) {
sb.append(newline).append("RESERVED WORDS").append(newline).append(newline);
String[] arr = config.reservedWords().stream().sorted().toArray(String[]::new);

View File

@@ -160,6 +160,13 @@ public class Generate extends OpenApiGeneratorCommand {
+ " You can also have multiple occurrences of this option.")
private List<String> languageSpecificPrimitives = new ArrayList<>();
@Option(
name = {"--openapi-generator-ignore-list"},
title = ".openapi-generaotr-ignore list",
description = "specifies entries in the .openapi-generator-ignore file relative/path/to/file1,relative/path/to/file2. For example: README.md,pom.xml"
+ " You can also have multiple occurrences of this option.")
private List<String> openapiGeneratorIgnoreList = new ArrayList<>();
@Option(
name = {"--import-mappings"},
title = "import mappings",
@@ -504,6 +511,7 @@ public class Generate extends OpenApiGeneratorCommand {
applyTypeMappingsKvpList(typeMappings, configurator);
applyAdditionalPropertiesKvpList(additionalProperties, configurator);
applyLanguageSpecificPrimitivesCsvList(languageSpecificPrimitives, configurator);
applyOpenAPIGeneratorIgnoreListCsvList(openapiGeneratorIgnoreList, configurator);
applyReservedWordsMappingsKvpList(reservedWordsMappings, configurator);
applyServerVariablesKvpList(serverVariableOverrides, configurator);