Skip to content

Commit acf8592

Browse files
authored
[typescript] Remove incomplete support of Date type (#5314)
* Remove DateTime mapping from concrete TypeScript generators that do not have full support for Date deserialization * Fix model unit tests * Regenerate samples
1 parent 32b9b39 commit acf8592

41 files changed

Lines changed: 45 additions & 58 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAngularClientCodegen.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,6 @@ public TypeScriptAngularClientCodegen() {
8686
apiPackage = "api";
8787
modelPackage = "model";
8888

89-
typeMapping.put("DateTime", "Date");
90-
9189
this.cliOptions.add(new CliOption(NPM_REPOSITORY,
9290
"Use this property to set an url your private npmRepo in the package.json"));
9391
this.cliOptions.add(CliOption.newBoolean(WITH_INTERFACES,

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAngularJsClientCodegen.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ public TypeScriptAngularJsClientCodegen() {
3434
apiPackage = "api";
3535
modelPackage = "model";
3636

37-
typeMapping.put("DateTime", "Date");
38-
3937
removeOption(NPM_NAME);
4038
removeOption(NPM_VERSION);
4139
removeOption(SNAPSHOT);

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAureliaClientCodegen.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ public TypeScriptAureliaClientCodegen() {
3636

3737
outputFolder = "generated-code/typescript-aurelia";
3838
embeddedTemplateDir = templateDir = "typescript-aurelia";
39-
40-
typeMapping.put("DateTime", "Date");
4139
}
4240

4341
@Override

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAxiosClientCodegen.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ public TypeScriptAxiosClientCodegen() {
5555
outputFolder = "generated-code/typescript-axios";
5656
embeddedTemplateDir = templateDir = "typescript-axios";
5757

58-
typeMapping.put("DateTime", "Date");
59-
6058
this.cliOptions.add(new CliOption(NPM_REPOSITORY, "Use this property to set an url of your private npmRepo in the package.json"));
6159
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()));
6260
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()));

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptInversifyClientCodegen.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,6 @@ public TypeScriptInversifyClientCodegen() {
5858
apiPackage = "api";
5959
modelPackage = "model";
6060

61-
typeMapping.put("DateTime", "Date");
62-
6361
this.reservedWords.add("map");
6462

6563
this.cliOptions.add(new CliOption(NPM_REPOSITORY,

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptJqueryClientCodegen.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@ public TypeScriptJqueryClientCodegen() {
5353
outputFolder = "generated-code/typescript-jquery";
5454
embeddedTemplateDir = templateDir = "typescript-jquery";
5555

56-
typeMapping.put("DateTime", "Date");
57-
5856
this.cliOptions.add(new CliOption(NPM_REPOSITORY, "Use this property to set an url your private npmRepo in the package.json"));
5957
this.cliOptions.add(new CliOption(JQUERY_ALREADY_IMPORTED,
6058
"When using this in legacy app using mix of typescript and javascript, this will only declare jquery and not import it",

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptRxjsClientCodegen.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ public TypeScriptRxjsClientCodegen() {
5858

5959
languageSpecificPrimitives.add("Blob");
6060
typeMapping.put("file", "Blob");
61-
typeMapping.put("DateTime", "Date");
6261

6362
this.cliOptions.add(new CliOption(NPM_REPOSITORY, "Use this property to set an url your private npmRepo in the package.json"));
6463
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()));

modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/typescriptangular/TypeScriptAngularModelTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ public void simpleModelTest() {
7676
final CodegenProperty property3 = cm.vars.get(2);
7777
Assert.assertEquals(property3.baseName, "createdAt");
7878
Assert.assertEquals(property3.complexType, null);
79-
Assert.assertEquals(property3.dataType, "Date");
79+
Assert.assertEquals(property3.dataType, "string");
8080
Assert.assertEquals(property3.name, "createdAt");
81-
Assert.assertEquals(property3.baseType, "Date");
81+
Assert.assertEquals(property3.baseType, "string");
8282
Assert.assertEquals(property3.defaultValue, "undefined");
8383
Assert.assertTrue(property3.hasMore);
8484
Assert.assertFalse(property3.required);

modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/typescriptangularjs/TypeScriptAngularJsModelTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public void simpleModelTest() {
7575
final CodegenProperty property3 = cm.vars.get(2);
7676
Assert.assertEquals(property3.baseName, "createdAt");
7777
Assert.assertEquals(property3.complexType, null);
78-
Assert.assertEquals(property3.dataType, "Date");
78+
Assert.assertEquals(property3.dataType, "string");
7979
Assert.assertEquals(property3.name, "createdAt");
8080
Assert.assertEquals(property3.defaultValue, "undefined");
8181
Assert.assertTrue(property3.hasMore);

samples/client/petstore/typescript-angular-v2/default/model/order.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export interface Order {
1818
id?: number;
1919
petId?: number;
2020
quantity?: number;
21-
shipDate?: Date;
21+
shipDate?: string;
2222
/**
2323
* Order Status
2424
*/

0 commit comments

Comments
 (0)