From 0e621dcc29bb3ec79d394ddb9363a8e64a227ee2 Mon Sep 17 00:00:00 2001 From: Erik Seliger Date: Wed, 31 Jul 2019 21:16:49 +0200 Subject: [PATCH] feat(typescript-angular): add flag for using string enums (#3464) * feat(typescript): add flag for using string enums * fix: adjust templates * fix: repair logic * fix: remove sample * fix: add to v7 sample * fix: remove unneeded lines --- ...etstore-not-provided-in-root-with-npm.json | 5 +++-- docs/generators/typescript-angular.md | 1 + .../AbstractTypeScriptClientCodegen.java | 10 +++++---- .../TypeScriptAngularClientCodegen.java | 21 +++++++++++++++++++ .../typescript-angular/modelEnum.mustache | 13 +++++++++++- .../modelGenericEnums.mustache | 16 +++++++++++++- ...ypeScriptAngularClientOptionsProvider.java | 2 ++ .../TypeScriptAngularClientOptionsTest.java | 2 ++ .../default/model/order.ts | 1 + .../default/model/pet.ts | 1 + .../typescript-angular-v2/npm/model/order.ts | 1 + .../typescript-angular-v2/npm/model/pet.ts | 1 + .../with-interfaces/model/order.ts | 1 + .../with-interfaces/model/pet.ts | 1 + .../npm/model/order.ts | 1 + .../typescript-angular-v4.3/npm/model/pet.ts | 1 + .../typescript-angular-v4/npm/model/order.ts | 1 + .../typescript-angular-v4/npm/model/pet.ts | 1 + .../builds/default/model/order.ts | 1 + .../builds/default/model/pet.ts | 1 + .../builds/with-npm/model/order.ts | 1 + .../builds/with-npm/model/pet.ts | 1 + .../builds/default/model/order.ts | 1 + .../builds/default/model/pet.ts | 1 + .../builds/with-npm/model/order.ts | 1 + .../builds/with-npm/model/pet.ts | 1 + .../builds/default/model/order.ts | 1 + .../builds/default/model/pet.ts | 1 + .../builds/with-npm/model/order.ts | 17 +++++++-------- .../builds/with-npm/model/pet.ts | 17 +++++++-------- .../builds/default/model/order.ts | 1 + .../builds/default/model/pet.ts | 1 + .../builds/with-npm/model/order.ts | 1 + .../builds/with-npm/model/pet.ts | 1 + 34 files changed, 102 insertions(+), 26 deletions(-) diff --git a/bin/typescript-angular-v7-petstore-not-provided-in-root-with-npm.json b/bin/typescript-angular-v7-petstore-not-provided-in-root-with-npm.json index 535bffbd45e..9c939c67ae4 100644 --- a/bin/typescript-angular-v7-petstore-not-provided-in-root-with-npm.json +++ b/bin/typescript-angular-v7-petstore-not-provided-in-root-with-npm.json @@ -1,6 +1,7 @@ { "npmName": "@openapitools/typescript-angular-petstore", "npmVersion": "1.0.0", - "npmRepository" : "https://skimdb.npmjs.com/registry", - "snapshot" : false + "stringEnums": true, + "npmRepository": "https://skimdb.npmjs.com/registry", + "snapshot": false } diff --git a/docs/generators/typescript-angular.md b/docs/generators/typescript-angular.md index 0090d5472bc..c9b6786ea87 100644 --- a/docs/generators/typescript-angular.md +++ b/docs/generators/typescript-angular.md @@ -26,3 +26,4 @@ sidebar_label: typescript-angular |modelSuffix|The suffix of the generated model.| |null| |modelFileSuffix|The suffix of the file of the generated model (model<suffix>.ts).| |null| |fileNaming|Naming convention for the output files: 'camelCase', 'kebab-case'.| |camelCase| +|stringEnums|Generate string enums instead of objects for enum values.| |false| diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractTypeScriptClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractTypeScriptClientCodegen.java index 3646427b27d..b022f73c5f7 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractTypeScriptClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractTypeScriptClientCodegen.java @@ -55,6 +55,9 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp protected String npmName = null; protected String npmVersion = "1.0.0"; + protected String enumSuffix = "Enum"; + protected String classEnumSeparator = "."; + public AbstractTypeScriptClientCodegen() { super(); @@ -551,8 +554,7 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp @Override public String toEnumName(CodegenProperty property) { - String enumName = toModelName(property.name) + "Enum"; - + String enumName = toModelName(property.name) + enumSuffix; if (enumName.matches("\\d.*")) { // starts with number return "_" + enumName; } else { @@ -571,14 +573,14 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp // name enum with model name, e.g. StatusEnum => Pet.StatusEnum for (CodegenProperty var : cm.vars) { if (Boolean.TRUE.equals(var.isEnum)) { - var.datatypeWithEnum = var.datatypeWithEnum.replace(var.enumName, cm.classname + "." + var.enumName); + var.datatypeWithEnum = var.datatypeWithEnum.replace(var.enumName, cm.classname + classEnumSeparator + var.enumName); } } if (cm.parent != null) { for (CodegenProperty var : cm.allVars) { if (Boolean.TRUE.equals(var.isEnum)) { var.datatypeWithEnum = var.datatypeWithEnum - .replace(var.enumName, cm.classname + "." + var.enumName); + .replace(var.enumName, cm.classname + classEnumSeparator + var.enumName); } } } diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAngularClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAngularClientCodegen.java index 922628e2438..31c5091b88a 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAngularClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAngularClientCodegen.java @@ -49,6 +49,8 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode public static final String MODEL_SUFFIX = "modelSuffix"; public static final String MODEL_FILE_SUFFIX = "modelFileSuffix"; public static final String FILE_NAMING = "fileNaming"; + public static final String STRING_ENUMS = "stringEnums"; + public static final String STRING_ENUMS_DESC = "Generate string enums instead of objects for enum values."; protected String ngVersion = "7.0.0"; protected String npmRepository = null; @@ -57,6 +59,7 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode protected String modelSuffix = ""; protected String modelFileSuffix = ""; protected String fileNaming = "camelCase"; + protected Boolean stringEnums = false; private boolean taggedUnions = false; @@ -89,6 +92,7 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode this.cliOptions.add(new CliOption(MODEL_SUFFIX, "The suffix of the generated model.")); this.cliOptions.add(new CliOption(MODEL_FILE_SUFFIX, "The suffix of the file of the generated model (model.ts).")); this.cliOptions.add(new CliOption(FILE_NAMING, "Naming convention for the output files: 'camelCase', 'kebab-case'.").defaultValue(this.fileNaming)); + this.cliOptions.add(new CliOption(STRING_ENUMS, STRING_ENUMS_DESC).defaultValue(String.valueOf(this.stringEnums))); } @Override @@ -137,6 +141,15 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode addNpmPackageGeneration(ngVersion); } + if (additionalProperties.containsKey(STRING_ENUMS)) { + setStringEnums(Boolean.valueOf(additionalProperties.get(STRING_ENUMS).toString())); + additionalProperties.put("stringEnums", getStringEnums()); + if (getStringEnums()) { + enumSuffix = ""; + classEnumSeparator = ""; + } + } + if (additionalProperties.containsKey(WITH_INTERFACES)) { boolean withInterfaces = Boolean.parseBoolean(additionalProperties.get(WITH_INTERFACES).toString()); if (withInterfaces) { @@ -272,6 +285,14 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode return indexPackage.replace('.', File.separatorChar); } + public void setStringEnums(boolean value) { + stringEnums = value; + } + + public Boolean getStringEnums() { + return stringEnums; + } + @Override public boolean isDataTypeFile(final String dataType) { return dataType != null && dataType.equals("Blob"); diff --git a/modules/openapi-generator/src/main/resources/typescript-angular/modelEnum.mustache b/modules/openapi-generator/src/main/resources/typescript-angular/modelEnum.mustache index 7ad77ac62a2..4695a611e79 100644 --- a/modules/openapi-generator/src/main/resources/typescript-angular/modelEnum.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-angular/modelEnum.mustache @@ -1,3 +1,13 @@ +{{#stringEnums}} +export enum {{classname}} { +{{#allowableValues}} +{{#enumVars}} + {{name}} = {{{value}}}{{^-last}},{{/-last}} +{{/enumVars}} +{{/allowableValues}} +}; +{{/stringEnums}} +{{^stringEnums}} export type {{classname}} = {{#allowableValues}}{{#enumVars}}{{{value}}}{{^-last}} | {{/-last}}{{/enumVars}}{{/allowableValues}}; export const {{classname}} = { @@ -6,4 +16,5 @@ export const {{classname}} = { {{name}}: {{{value}}} as {{classname}}{{^-last}},{{/-last}} {{/enumVars}} {{/allowableValues}} -}; \ No newline at end of file +}; +{{/stringEnums}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/typescript-angular/modelGenericEnums.mustache b/modules/openapi-generator/src/main/resources/typescript-angular/modelGenericEnums.mustache index eb450b57fcc..a824e55ec53 100644 --- a/modules/openapi-generator/src/main/resources/typescript-angular/modelGenericEnums.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-angular/modelGenericEnums.mustache @@ -1,8 +1,20 @@ {{#hasEnums}} +{{^stringEnums}} export namespace {{classname}} { +{{/stringEnums}} {{#vars}} {{#isEnum}} +{{#stringEnums}} +export enum {{classname}}{{enumName}} { +{{#allowableValues}} +{{#enumVars}} + {{name}} = {{{value}}}{{^-last}},{{/-last}} +{{/enumVars}} +{{/allowableValues}} +}; +{{/stringEnums}} +{{^stringEnums}} export type {{enumName}} = {{#allowableValues}}{{#enumVars}}{{{value}}}{{^-last}} | {{/-last}}{{/enumVars}}{{/allowableValues}}; export const {{enumName}} = { {{#allowableValues}} @@ -11,6 +23,8 @@ export namespace {{classname}} { {{/enumVars}} {{/allowableValues}} }; +{{/stringEnums}} {{/isEnum}} {{/vars}} -}{{/hasEnums}} \ No newline at end of file +{{^stringEnums}}}{{/stringEnums}} +{{/hasEnums}} \ No newline at end of file diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/TypeScriptAngularClientOptionsProvider.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/TypeScriptAngularClientOptionsProvider.java index 6100c2d4692..d464a532a0e 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/TypeScriptAngularClientOptionsProvider.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/TypeScriptAngularClientOptionsProvider.java @@ -25,6 +25,7 @@ import java.util.Map; public class TypeScriptAngularClientOptionsProvider implements OptionsProvider { public static final String SUPPORTS_ES6_VALUE = "false"; + public static final String STRING_ENUMS_VALUE = "false"; public static final String SORT_PARAMS_VALUE = "false"; public static final String ENSURE_UNIQUE_PARAMS_VALUE = "true"; public static final String MODEL_PROPERTY_NAMING_VALUE = "camelCase"; @@ -52,6 +53,7 @@ public class TypeScriptAngularClientOptionsProvider implements OptionsProvider { .put(CodegenConstants.ENSURE_UNIQUE_PARAMS, ENSURE_UNIQUE_PARAMS_VALUE) .put(CodegenConstants.MODEL_PROPERTY_NAMING, MODEL_PROPERTY_NAMING_VALUE) .put(CodegenConstants.SUPPORTS_ES6, SUPPORTS_ES6_VALUE) + .put(TypeScriptAngularClientCodegen.STRING_ENUMS, STRING_ENUMS_VALUE) .put(TypeScriptAngularClientCodegen.NPM_NAME, NMP_NAME) .put(TypeScriptAngularClientCodegen.NPM_VERSION, NMP_VERSION) .put(TypeScriptAngularClientCodegen.SNAPSHOT, Boolean.FALSE.toString()) diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/typescriptangular/TypeScriptAngularClientOptionsTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/typescriptangular/TypeScriptAngularClientOptionsTest.java index 91f24924159..e7ab479a537 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/typescriptangular/TypeScriptAngularClientOptionsTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/typescriptangular/TypeScriptAngularClientOptionsTest.java @@ -48,6 +48,8 @@ public class TypeScriptAngularClientOptionsTest extends AbstractOptionsTest { times = 1; clientCodegen.setSupportsES6(Boolean.valueOf(TypeScriptAngularClientOptionsProvider.SUPPORTS_ES6_VALUE)); times = 1; + clientCodegen.setStringEnums(Boolean.valueOf(TypeScriptAngularClientOptionsProvider.STRING_ENUMS_VALUE)); + times = 1; clientCodegen.setPrependFormOrBodyParameters(Boolean.valueOf(TypeScriptAngularClientOptionsProvider.PREPEND_FORM_OR_BODY_PARAMETERS_VALUE)); times = 1; }}; diff --git a/samples/client/petstore/typescript-angular-v2/default/model/order.ts b/samples/client/petstore/typescript-angular-v2/default/model/order.ts index 5a3ccc36e72..c8d8a5e55c0 100644 --- a/samples/client/petstore/typescript-angular-v2/default/model/order.ts +++ b/samples/client/petstore/typescript-angular-v2/default/model/order.ts @@ -34,3 +34,4 @@ export namespace Order { }; } + diff --git a/samples/client/petstore/typescript-angular-v2/default/model/pet.ts b/samples/client/petstore/typescript-angular-v2/default/model/pet.ts index 09db26bf182..e0404395f91 100644 --- a/samples/client/petstore/typescript-angular-v2/default/model/pet.ts +++ b/samples/client/petstore/typescript-angular-v2/default/model/pet.ts @@ -36,3 +36,4 @@ export namespace Pet { }; } + diff --git a/samples/client/petstore/typescript-angular-v2/npm/model/order.ts b/samples/client/petstore/typescript-angular-v2/npm/model/order.ts index 5a3ccc36e72..c8d8a5e55c0 100644 --- a/samples/client/petstore/typescript-angular-v2/npm/model/order.ts +++ b/samples/client/petstore/typescript-angular-v2/npm/model/order.ts @@ -34,3 +34,4 @@ export namespace Order { }; } + diff --git a/samples/client/petstore/typescript-angular-v2/npm/model/pet.ts b/samples/client/petstore/typescript-angular-v2/npm/model/pet.ts index 09db26bf182..e0404395f91 100644 --- a/samples/client/petstore/typescript-angular-v2/npm/model/pet.ts +++ b/samples/client/petstore/typescript-angular-v2/npm/model/pet.ts @@ -36,3 +36,4 @@ export namespace Pet { }; } + diff --git a/samples/client/petstore/typescript-angular-v2/with-interfaces/model/order.ts b/samples/client/petstore/typescript-angular-v2/with-interfaces/model/order.ts index 5a3ccc36e72..c8d8a5e55c0 100644 --- a/samples/client/petstore/typescript-angular-v2/with-interfaces/model/order.ts +++ b/samples/client/petstore/typescript-angular-v2/with-interfaces/model/order.ts @@ -34,3 +34,4 @@ export namespace Order { }; } + diff --git a/samples/client/petstore/typescript-angular-v2/with-interfaces/model/pet.ts b/samples/client/petstore/typescript-angular-v2/with-interfaces/model/pet.ts index 09db26bf182..e0404395f91 100644 --- a/samples/client/petstore/typescript-angular-v2/with-interfaces/model/pet.ts +++ b/samples/client/petstore/typescript-angular-v2/with-interfaces/model/pet.ts @@ -36,3 +36,4 @@ export namespace Pet { }; } + diff --git a/samples/client/petstore/typescript-angular-v4.3/npm/model/order.ts b/samples/client/petstore/typescript-angular-v4.3/npm/model/order.ts index 5a3ccc36e72..c8d8a5e55c0 100644 --- a/samples/client/petstore/typescript-angular-v4.3/npm/model/order.ts +++ b/samples/client/petstore/typescript-angular-v4.3/npm/model/order.ts @@ -34,3 +34,4 @@ export namespace Order { }; } + diff --git a/samples/client/petstore/typescript-angular-v4.3/npm/model/pet.ts b/samples/client/petstore/typescript-angular-v4.3/npm/model/pet.ts index 09db26bf182..e0404395f91 100644 --- a/samples/client/petstore/typescript-angular-v4.3/npm/model/pet.ts +++ b/samples/client/petstore/typescript-angular-v4.3/npm/model/pet.ts @@ -36,3 +36,4 @@ export namespace Pet { }; } + diff --git a/samples/client/petstore/typescript-angular-v4/npm/model/order.ts b/samples/client/petstore/typescript-angular-v4/npm/model/order.ts index 5a3ccc36e72..c8d8a5e55c0 100644 --- a/samples/client/petstore/typescript-angular-v4/npm/model/order.ts +++ b/samples/client/petstore/typescript-angular-v4/npm/model/order.ts @@ -34,3 +34,4 @@ export namespace Order { }; } + diff --git a/samples/client/petstore/typescript-angular-v4/npm/model/pet.ts b/samples/client/petstore/typescript-angular-v4/npm/model/pet.ts index 09db26bf182..e0404395f91 100644 --- a/samples/client/petstore/typescript-angular-v4/npm/model/pet.ts +++ b/samples/client/petstore/typescript-angular-v4/npm/model/pet.ts @@ -36,3 +36,4 @@ export namespace Pet { }; } + diff --git a/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/default/model/order.ts b/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/default/model/order.ts index 5a3ccc36e72..c8d8a5e55c0 100644 --- a/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/default/model/order.ts +++ b/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/default/model/order.ts @@ -34,3 +34,4 @@ export namespace Order { }; } + diff --git a/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/default/model/pet.ts b/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/default/model/pet.ts index 09db26bf182..e0404395f91 100644 --- a/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/default/model/pet.ts +++ b/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/default/model/pet.ts @@ -36,3 +36,4 @@ export namespace Pet { }; } + diff --git a/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/with-npm/model/order.ts b/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/with-npm/model/order.ts index 5a3ccc36e72..c8d8a5e55c0 100644 --- a/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/with-npm/model/order.ts +++ b/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/with-npm/model/order.ts @@ -34,3 +34,4 @@ export namespace Order { }; } + diff --git a/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/with-npm/model/pet.ts b/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/with-npm/model/pet.ts index 09db26bf182..e0404395f91 100644 --- a/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/with-npm/model/pet.ts +++ b/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/with-npm/model/pet.ts @@ -36,3 +36,4 @@ export namespace Pet { }; } + diff --git a/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/default/model/order.ts b/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/default/model/order.ts index 5a3ccc36e72..c8d8a5e55c0 100644 --- a/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/default/model/order.ts +++ b/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/default/model/order.ts @@ -34,3 +34,4 @@ export namespace Order { }; } + diff --git a/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/default/model/pet.ts b/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/default/model/pet.ts index 09db26bf182..e0404395f91 100644 --- a/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/default/model/pet.ts +++ b/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/default/model/pet.ts @@ -36,3 +36,4 @@ export namespace Pet { }; } + diff --git a/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/with-npm/model/order.ts b/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/with-npm/model/order.ts index 5a3ccc36e72..c8d8a5e55c0 100644 --- a/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/with-npm/model/order.ts +++ b/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/with-npm/model/order.ts @@ -34,3 +34,4 @@ export namespace Order { }; } + diff --git a/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/with-npm/model/pet.ts b/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/with-npm/model/pet.ts index 09db26bf182..e0404395f91 100644 --- a/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/with-npm/model/pet.ts +++ b/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/with-npm/model/pet.ts @@ -36,3 +36,4 @@ export namespace Pet { }; } + diff --git a/samples/client/petstore/typescript-angular-v7-not-provided-in-root/builds/default/model/order.ts b/samples/client/petstore/typescript-angular-v7-not-provided-in-root/builds/default/model/order.ts index 5a3ccc36e72..c8d8a5e55c0 100644 --- a/samples/client/petstore/typescript-angular-v7-not-provided-in-root/builds/default/model/order.ts +++ b/samples/client/petstore/typescript-angular-v7-not-provided-in-root/builds/default/model/order.ts @@ -34,3 +34,4 @@ export namespace Order { }; } + diff --git a/samples/client/petstore/typescript-angular-v7-not-provided-in-root/builds/default/model/pet.ts b/samples/client/petstore/typescript-angular-v7-not-provided-in-root/builds/default/model/pet.ts index 09db26bf182..e0404395f91 100644 --- a/samples/client/petstore/typescript-angular-v7-not-provided-in-root/builds/default/model/pet.ts +++ b/samples/client/petstore/typescript-angular-v7-not-provided-in-root/builds/default/model/pet.ts @@ -36,3 +36,4 @@ export namespace Pet { }; } + diff --git a/samples/client/petstore/typescript-angular-v7-not-provided-in-root/builds/with-npm/model/order.ts b/samples/client/petstore/typescript-angular-v7-not-provided-in-root/builds/with-npm/model/order.ts index 5a3ccc36e72..1d7860172c6 100644 --- a/samples/client/petstore/typescript-angular-v7-not-provided-in-root/builds/with-npm/model/order.ts +++ b/samples/client/petstore/typescript-angular-v7-not-provided-in-root/builds/with-npm/model/order.ts @@ -22,15 +22,14 @@ export interface Order { /** * Order Status */ - status?: Order.StatusEnum; + status?: OrderStatus; complete?: boolean; } -export namespace Order { - export type StatusEnum = 'placed' | 'approved' | 'delivered'; - export const StatusEnum = { - Placed: 'placed' as StatusEnum, - Approved: 'approved' as StatusEnum, - Delivered: 'delivered' as StatusEnum - }; -} +export enum OrderStatus { + Placed = 'placed', + Approved = 'approved', + Delivered = 'delivered' +}; + + diff --git a/samples/client/petstore/typescript-angular-v7-not-provided-in-root/builds/with-npm/model/pet.ts b/samples/client/petstore/typescript-angular-v7-not-provided-in-root/builds/with-npm/model/pet.ts index 09db26bf182..12e3d9b7591 100644 --- a/samples/client/petstore/typescript-angular-v7-not-provided-in-root/builds/with-npm/model/pet.ts +++ b/samples/client/petstore/typescript-angular-v7-not-provided-in-root/builds/with-npm/model/pet.ts @@ -25,14 +25,13 @@ export interface Pet { /** * pet status in the store */ - status?: Pet.StatusEnum; -} -export namespace Pet { - export type StatusEnum = 'available' | 'pending' | 'sold'; - export const StatusEnum = { - Available: 'available' as StatusEnum, - Pending: 'pending' as StatusEnum, - Sold: 'sold' as StatusEnum - }; + status?: PetStatus; } +export enum PetStatus { + Available = 'available', + Pending = 'pending', + Sold = 'sold' +}; + + diff --git a/samples/client/petstore/typescript-angular-v7-provided-in-root/builds/default/model/order.ts b/samples/client/petstore/typescript-angular-v7-provided-in-root/builds/default/model/order.ts index 5a3ccc36e72..c8d8a5e55c0 100644 --- a/samples/client/petstore/typescript-angular-v7-provided-in-root/builds/default/model/order.ts +++ b/samples/client/petstore/typescript-angular-v7-provided-in-root/builds/default/model/order.ts @@ -34,3 +34,4 @@ export namespace Order { }; } + diff --git a/samples/client/petstore/typescript-angular-v7-provided-in-root/builds/default/model/pet.ts b/samples/client/petstore/typescript-angular-v7-provided-in-root/builds/default/model/pet.ts index 09db26bf182..e0404395f91 100644 --- a/samples/client/petstore/typescript-angular-v7-provided-in-root/builds/default/model/pet.ts +++ b/samples/client/petstore/typescript-angular-v7-provided-in-root/builds/default/model/pet.ts @@ -36,3 +36,4 @@ export namespace Pet { }; } + diff --git a/samples/client/petstore/typescript-angular-v7-provided-in-root/builds/with-npm/model/order.ts b/samples/client/petstore/typescript-angular-v7-provided-in-root/builds/with-npm/model/order.ts index 5a3ccc36e72..c8d8a5e55c0 100644 --- a/samples/client/petstore/typescript-angular-v7-provided-in-root/builds/with-npm/model/order.ts +++ b/samples/client/petstore/typescript-angular-v7-provided-in-root/builds/with-npm/model/order.ts @@ -34,3 +34,4 @@ export namespace Order { }; } + diff --git a/samples/client/petstore/typescript-angular-v7-provided-in-root/builds/with-npm/model/pet.ts b/samples/client/petstore/typescript-angular-v7-provided-in-root/builds/with-npm/model/pet.ts index 09db26bf182..e0404395f91 100644 --- a/samples/client/petstore/typescript-angular-v7-provided-in-root/builds/with-npm/model/pet.ts +++ b/samples/client/petstore/typescript-angular-v7-provided-in-root/builds/with-npm/model/pet.ts @@ -36,3 +36,4 @@ export namespace Pet { }; } +