diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptFetchClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptFetchClientCodegen.java index 8924e3b0b62f5dd55f24f5d637f145f8ce993b98..0d47cdcd7ac6209b219ed1dc13b0f563040b5874 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptFetchClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptFetchClientCodegen.java @@ -85,9 +85,6 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege this.addExtraReservedWords(); - typeMapping.put("date", "Date"); - typeMapping.put("DateTime", "Date"); - supportModelPropertyNaming(CodegenConstants.MODEL_PROPERTY_NAMING_TYPE.camelCase); 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(WITH_INTERFACES, "Setting this property to true will generate interfaces next to the default class implementations.", SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.FALSE.toString())); @@ -231,6 +228,8 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege if (!withoutRuntimeChecks) { this.modelTemplateFiles.put("models.mustache", ".ts"); + typeMapping.put("date", "Date"); + typeMapping.put("DateTime", "Date"); } if (additionalProperties.containsKey(SAGAS_AND_RECORDS)) { diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/fetch/TypeScriptFetchModelTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/fetch/TypeScriptFetchModelTest.java index 8b43b94a8ce976a5ed92159dacc0ee0a7a1b355a..9bc7c709487ae97f92387d3ca3f638fd8008416f 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/fetch/TypeScriptFetchModelTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/fetch/TypeScriptFetchModelTest.java @@ -61,6 +61,7 @@ public class TypeScriptFetchModelTest { .addRequiredItem("name"); final DefaultCodegen codegen = new TypeScriptFetchClientCodegen(); + codegen.processOpts(); OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", model); codegen.setOpenAPI(openAPI); final CodegenModel cm = codegen.fromModel("sample", model); diff --git a/samples/client/petstore/typescript-fetch/builds/without-runtime-checks/src/models/index.ts b/samples/client/petstore/typescript-fetch/builds/without-runtime-checks/src/models/index.ts index 8d8f621b1ba51ce1be0d31bb3b22566f388b1276..8eef2399cc2013d119f29bf9d992077c5e191926 100644 --- a/samples/client/petstore/typescript-fetch/builds/without-runtime-checks/src/models/index.ts +++ b/samples/client/petstore/typescript-fetch/builds/without-runtime-checks/src/models/index.ts @@ -70,10 +70,10 @@ export interface Order { quantity?: number; /** * - * @type {Date} + * @type {string} * @memberof Order */ - shipDate?: Date; + shipDate?: string; /** * Order Status * @type {string}