diff --git a/docs/generators/typescript-axios.md b/docs/generators/typescript-axios.md index e09512c25d..1623947770 100644 --- a/docs/generators/typescript-axios.md +++ b/docs/generators/typescript-axios.md @@ -15,8 +15,8 @@ sidebar_label: typescript-axios |supportsES6|Generate code that conforms to ES6.| |false| |npmName|The name under which you want to publish generated npm package| |null| |npmVersion|The version of your npm package| |null| -|npmRepository|Use this property to set an url your private npmRepo in the package.json| |null| +|npmRepository|Use this property to set an url of your private npmRepo in the package.json| |null| |snapshot|When setting this property to true the version will be suffixed with -SNAPSHOT.yyyyMMddHHmm| |false| |withInterfaces|Setting this property to true will generate interfaces next to the default class implementations.| |false| |withSeparateModelsAndApi|Put the model and api in separate folders and in separate classes| |false| -|withoutPrefixEnums|Dont prefix enum names with class names| |false| +|withoutPrefixEnums|Don't prefix enum names with class names| |false| diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAxiosClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAxiosClientCodegen.java index 08d965c65f..2360aab7d1 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAxiosClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAxiosClientCodegen.java @@ -59,11 +59,11 @@ public class TypeScriptAxiosClientCodegen extends AbstractTypeScriptClientCodege this.cliOptions.add(new CliOption(NPM_NAME, "The name under which you want to publish generated npm package")); this.cliOptions.add(new CliOption(NPM_VERSION, "The version of your npm package")); - this.cliOptions.add(new CliOption(NPM_REPOSITORY, "Use this property to set an url your private npmRepo in the package.json")); + this.cliOptions.add(new CliOption(NPM_REPOSITORY, "Use this property to set an url of your private npmRepo in the package.json")); this.cliOptions.add(new CliOption(SNAPSHOT, "When setting this property to true the version will be suffixed with -SNAPSHOT.yyyyMMddHHmm", SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.FALSE.toString())); this.cliOptions.add(new CliOption(WITH_INTERFACES, "Setting this property to true will generate interfaces next to the default class implementations.", SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.FALSE.toString())); this.cliOptions.add(new CliOption(SEPARATE_MODELS_AND_API, "Put the model and api in separate folders and in separate classes", SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.FALSE.toString())); - this.cliOptions.add(new CliOption(WITHOUT_PREFIX_ENUMS, "Dont prefix enum names with class names", SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.FALSE.toString())); + this.cliOptions.add(new CliOption(WITHOUT_PREFIX_ENUMS, "Don't prefix enum names with class names", SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.FALSE.toString())); } @Override @@ -135,22 +135,22 @@ public class TypeScriptAxiosClientCodegen extends AbstractTypeScriptClientCodege supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh")); supportingFiles.add(new SupportingFile("gitignore", "", ".gitignore")); - boolean separateModelsAndApi = (boolean)additionalProperties.getOrDefault(SEPARATE_MODELS_AND_API, false); - - if (separateModelsAndApi) { - modelTemplateFiles.put("model.mustache", ".ts"); - apiTemplateFiles.put("apiInner.mustache", ".ts"); - supportingFiles.add(new SupportingFile("modelIndex.mustache", tsModelPackage, "index.ts")); + if (additionalProperties.containsKey(SEPARATE_MODELS_AND_API)) { + boolean separateModelsAndApi = Boolean.parseBoolean(additionalProperties.get(SEPARATE_MODELS_AND_API).toString()); + if (separateModelsAndApi) { + if (StringUtils.isAnyBlank(modelPackage, apiPackage)) { + throw new RuntimeException("apiPackage and modelPackage must be defined"); + } + modelTemplateFiles.put("model.mustache", ".ts"); + apiTemplateFiles.put("apiInner.mustache", ".ts"); + supportingFiles.add(new SupportingFile("modelIndex.mustache", tsModelPackage, "index.ts")); + } } if (additionalProperties.containsKey(NPM_NAME)) { addNpmPackageGeneration(); } - boolean emptyModelOrApi = separateModelsAndApi && StringUtils.isAnyBlank(modelPackage, apiPackage); - if (emptyModelOrApi) { - throw new RuntimeException("apiPackage and modelPackage must be defined"); - } } @Override @@ -180,7 +180,10 @@ public class TypeScriptAxiosClientCodegen extends AbstractTypeScriptClientCodege public Map postProcessModels(Map objs) { List models = (List) postProcessModelsEnum(objs).get("models"); - boolean withoutPrefixEnums = (boolean)additionalProperties.getOrDefault(WITHOUT_PREFIX_ENUMS, false); + boolean withoutPrefixEnums = false; + if (additionalProperties.containsKey(WITHOUT_PREFIX_ENUMS)) { + withoutPrefixEnums = Boolean.parseBoolean(additionalProperties.get(WITHOUT_PREFIX_ENUMS).toString()); + } for (Object _mo : models) { Map mo = (Map) _mo;