From c8fab3f40a1b00db75d61716016ed0846de65c42 Mon Sep 17 00:00:00 2001 From: Kuzma <57258237+ksvirkou-hubspot@users.noreply.github.com> Date: Thu, 2 Mar 2023 00:16:01 +0300 Subject: [PATCH] [Typescript] Use for of instead of for in at ObjectSerializer (#14849) * [Typescript] Use for of instead of for in * fix for * regenerate samples --- .../typescript/model/ObjectSerializer.mustache | 12 ++++-------- .../with-unique-items/models/ObjectSerializer.ts | 12 ++++-------- .../builds/browser/models/ObjectSerializer.ts | 12 ++++-------- .../composed-schemas/models/ObjectSerializer.ts | 12 ++++-------- .../builds/default/models/ObjectSerializer.ts | 12 ++++-------- .../builds/deno/models/ObjectSerializer.ts | 12 ++++-------- .../builds/inversify/models/ObjectSerializer.ts | 12 ++++-------- .../builds/jquery/models/ObjectSerializer.ts | 12 ++++-------- .../builds/object_params/models/ObjectSerializer.ts | 12 ++++-------- 9 files changed, 36 insertions(+), 72 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/typescript/model/ObjectSerializer.mustache b/modules/openapi-generator/src/main/resources/typescript/model/ObjectSerializer.mustache index 4af2dc8a237..25367e89994 100644 --- a/modules/openapi-generator/src/main/resources/typescript/model/ObjectSerializer.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/model/ObjectSerializer.mustache @@ -101,8 +101,7 @@ export class ObjectSerializer { let subType: string = type.replace("Array<", ""); // Array => Type> subType = subType.substring(0, subType.length - 1); // Type> => Type let transformedData: any[] = []; - for (let index in data) { - let date = data[index]; + for (let date of data) { transformedData.push(ObjectSerializer.serialize(date, subType, format)); } return transformedData; @@ -131,8 +130,7 @@ export class ObjectSerializer { // get the map for the correct type. let attributeTypes = typeMap[type].getAttributeTypeMap(); let instance: {[index: string]: any} = {}; - for (let index in attributeTypes) { - let attributeType = attributeTypes[index]; + for (let attributeType of attributeTypes) { instance[attributeType.baseName] = ObjectSerializer.serialize(data[attributeType.name], attributeType.type, attributeType.format); } return instance; @@ -150,8 +148,7 @@ export class ObjectSerializer { let subType: string = type.replace("Array<", ""); // Array => Type> subType = subType.substring(0, subType.length - 1); // Type> => Type let transformedData: any[] = []; - for (let index in data) { - let date = data[index]; + for (let date of data) { transformedData.push(ObjectSerializer.deserialize(date, subType, format)); } return transformedData; @@ -167,8 +164,7 @@ export class ObjectSerializer { } let instance = new typeMap[type](); let attributeTypes = typeMap[type].getAttributeTypeMap(); - for (let index in attributeTypes) { - let attributeType = attributeTypes[index]; + for (let attributeType of attributeTypes) { let value = ObjectSerializer.deserialize(data[attributeType.baseName], attributeType.type, attributeType.format); if (value !== undefined) { instance[attributeType.name] = value; diff --git a/samples/client/others/typescript/builds/with-unique-items/models/ObjectSerializer.ts b/samples/client/others/typescript/builds/with-unique-items/models/ObjectSerializer.ts index b833844acc1..f10b5273214 100644 --- a/samples/client/others/typescript/builds/with-unique-items/models/ObjectSerializer.ts +++ b/samples/client/others/typescript/builds/with-unique-items/models/ObjectSerializer.ts @@ -73,8 +73,7 @@ export class ObjectSerializer { let subType: string = type.replace("Array<", ""); // Array => Type> subType = subType.substring(0, subType.length - 1); // Type> => Type let transformedData: any[] = []; - for (let index in data) { - let date = data[index]; + for (let date of data) { transformedData.push(ObjectSerializer.serialize(date, subType, format)); } return transformedData; @@ -103,8 +102,7 @@ export class ObjectSerializer { // get the map for the correct type. let attributeTypes = typeMap[type].getAttributeTypeMap(); let instance: {[index: string]: any} = {}; - for (let index in attributeTypes) { - let attributeType = attributeTypes[index]; + for (let attributeType of attributeTypes) { instance[attributeType.baseName] = ObjectSerializer.serialize(data[attributeType.name], attributeType.type, attributeType.format); } return instance; @@ -122,8 +120,7 @@ export class ObjectSerializer { let subType: string = type.replace("Array<", ""); // Array => Type> subType = subType.substring(0, subType.length - 1); // Type> => Type let transformedData: any[] = []; - for (let index in data) { - let date = data[index]; + for (let date of data) { transformedData.push(ObjectSerializer.deserialize(date, subType, format)); } return transformedData; @@ -139,8 +136,7 @@ export class ObjectSerializer { } let instance = new typeMap[type](); let attributeTypes = typeMap[type].getAttributeTypeMap(); - for (let index in attributeTypes) { - let attributeType = attributeTypes[index]; + for (let attributeType of attributeTypes) { let value = ObjectSerializer.deserialize(data[attributeType.baseName], attributeType.type, attributeType.format); if (value !== undefined) { instance[attributeType.name] = value; diff --git a/samples/openapi3/client/petstore/typescript/builds/browser/models/ObjectSerializer.ts b/samples/openapi3/client/petstore/typescript/builds/browser/models/ObjectSerializer.ts index a5f5708b12c..dfbb605553b 100644 --- a/samples/openapi3/client/petstore/typescript/builds/browser/models/ObjectSerializer.ts +++ b/samples/openapi3/client/petstore/typescript/builds/browser/models/ObjectSerializer.ts @@ -90,8 +90,7 @@ export class ObjectSerializer { let subType: string = type.replace("Array<", ""); // Array => Type> subType = subType.substring(0, subType.length - 1); // Type> => Type let transformedData: any[] = []; - for (let index in data) { - let date = data[index]; + for (let date of data) { transformedData.push(ObjectSerializer.serialize(date, subType, format)); } return transformedData; @@ -120,8 +119,7 @@ export class ObjectSerializer { // get the map for the correct type. let attributeTypes = typeMap[type].getAttributeTypeMap(); let instance: {[index: string]: any} = {}; - for (let index in attributeTypes) { - let attributeType = attributeTypes[index]; + for (let attributeType of attributeTypes) { instance[attributeType.baseName] = ObjectSerializer.serialize(data[attributeType.name], attributeType.type, attributeType.format); } return instance; @@ -139,8 +137,7 @@ export class ObjectSerializer { let subType: string = type.replace("Array<", ""); // Array => Type> subType = subType.substring(0, subType.length - 1); // Type> => Type let transformedData: any[] = []; - for (let index in data) { - let date = data[index]; + for (let date of data) { transformedData.push(ObjectSerializer.deserialize(date, subType, format)); } return transformedData; @@ -156,8 +153,7 @@ export class ObjectSerializer { } let instance = new typeMap[type](); let attributeTypes = typeMap[type].getAttributeTypeMap(); - for (let index in attributeTypes) { - let attributeType = attributeTypes[index]; + for (let attributeType of attributeTypes) { let value = ObjectSerializer.deserialize(data[attributeType.baseName], attributeType.type, attributeType.format); if (value !== undefined) { instance[attributeType.name] = value; diff --git a/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/ObjectSerializer.ts b/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/ObjectSerializer.ts index 6317becfd98..e726b1bbdc3 100644 --- a/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/ObjectSerializer.ts +++ b/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/ObjectSerializer.ts @@ -102,8 +102,7 @@ export class ObjectSerializer { let subType: string = type.replace("Array<", ""); // Array => Type> subType = subType.substring(0, subType.length - 1); // Type> => Type let transformedData: any[] = []; - for (let index in data) { - let date = data[index]; + for (let date of data) { transformedData.push(ObjectSerializer.serialize(date, subType, format)); } return transformedData; @@ -132,8 +131,7 @@ export class ObjectSerializer { // get the map for the correct type. let attributeTypes = typeMap[type].getAttributeTypeMap(); let instance: {[index: string]: any} = {}; - for (let index in attributeTypes) { - let attributeType = attributeTypes[index]; + for (let attributeType of attributeTypes) { instance[attributeType.baseName] = ObjectSerializer.serialize(data[attributeType.name], attributeType.type, attributeType.format); } return instance; @@ -151,8 +149,7 @@ export class ObjectSerializer { let subType: string = type.replace("Array<", ""); // Array => Type> subType = subType.substring(0, subType.length - 1); // Type> => Type let transformedData: any[] = []; - for (let index in data) { - let date = data[index]; + for (let date of data) { transformedData.push(ObjectSerializer.deserialize(date, subType, format)); } return transformedData; @@ -168,8 +165,7 @@ export class ObjectSerializer { } let instance = new typeMap[type](); let attributeTypes = typeMap[type].getAttributeTypeMap(); - for (let index in attributeTypes) { - let attributeType = attributeTypes[index]; + for (let attributeType of attributeTypes) { let value = ObjectSerializer.deserialize(data[attributeType.baseName], attributeType.type, attributeType.format); if (value !== undefined) { instance[attributeType.name] = value; diff --git a/samples/openapi3/client/petstore/typescript/builds/default/models/ObjectSerializer.ts b/samples/openapi3/client/petstore/typescript/builds/default/models/ObjectSerializer.ts index a5f5708b12c..dfbb605553b 100644 --- a/samples/openapi3/client/petstore/typescript/builds/default/models/ObjectSerializer.ts +++ b/samples/openapi3/client/petstore/typescript/builds/default/models/ObjectSerializer.ts @@ -90,8 +90,7 @@ export class ObjectSerializer { let subType: string = type.replace("Array<", ""); // Array => Type> subType = subType.substring(0, subType.length - 1); // Type> => Type let transformedData: any[] = []; - for (let index in data) { - let date = data[index]; + for (let date of data) { transformedData.push(ObjectSerializer.serialize(date, subType, format)); } return transformedData; @@ -120,8 +119,7 @@ export class ObjectSerializer { // get the map for the correct type. let attributeTypes = typeMap[type].getAttributeTypeMap(); let instance: {[index: string]: any} = {}; - for (let index in attributeTypes) { - let attributeType = attributeTypes[index]; + for (let attributeType of attributeTypes) { instance[attributeType.baseName] = ObjectSerializer.serialize(data[attributeType.name], attributeType.type, attributeType.format); } return instance; @@ -139,8 +137,7 @@ export class ObjectSerializer { let subType: string = type.replace("Array<", ""); // Array => Type> subType = subType.substring(0, subType.length - 1); // Type> => Type let transformedData: any[] = []; - for (let index in data) { - let date = data[index]; + for (let date of data) { transformedData.push(ObjectSerializer.deserialize(date, subType, format)); } return transformedData; @@ -156,8 +153,7 @@ export class ObjectSerializer { } let instance = new typeMap[type](); let attributeTypes = typeMap[type].getAttributeTypeMap(); - for (let index in attributeTypes) { - let attributeType = attributeTypes[index]; + for (let attributeType of attributeTypes) { let value = ObjectSerializer.deserialize(data[attributeType.baseName], attributeType.type, attributeType.format); if (value !== undefined) { instance[attributeType.name] = value; diff --git a/samples/openapi3/client/petstore/typescript/builds/deno/models/ObjectSerializer.ts b/samples/openapi3/client/petstore/typescript/builds/deno/models/ObjectSerializer.ts index a56a21255c2..0da0325edc8 100644 --- a/samples/openapi3/client/petstore/typescript/builds/deno/models/ObjectSerializer.ts +++ b/samples/openapi3/client/petstore/typescript/builds/deno/models/ObjectSerializer.ts @@ -90,8 +90,7 @@ export class ObjectSerializer { let subType: string = type.replace("Array<", ""); // Array => Type> subType = subType.substring(0, subType.length - 1); // Type> => Type let transformedData: any[] = []; - for (let index in data) { - let date = data[index]; + for (let date of data) { transformedData.push(ObjectSerializer.serialize(date, subType, format)); } return transformedData; @@ -120,8 +119,7 @@ export class ObjectSerializer { // get the map for the correct type. let attributeTypes = typeMap[type].getAttributeTypeMap(); let instance: {[index: string]: any} = {}; - for (let index in attributeTypes) { - let attributeType = attributeTypes[index]; + for (let attributeType of attributeTypes) { instance[attributeType.baseName] = ObjectSerializer.serialize(data[attributeType.name], attributeType.type, attributeType.format); } return instance; @@ -139,8 +137,7 @@ export class ObjectSerializer { let subType: string = type.replace("Array<", ""); // Array => Type> subType = subType.substring(0, subType.length - 1); // Type> => Type let transformedData: any[] = []; - for (let index in data) { - let date = data[index]; + for (let date of data) { transformedData.push(ObjectSerializer.deserialize(date, subType, format)); } return transformedData; @@ -156,8 +153,7 @@ export class ObjectSerializer { } let instance = new typeMap[type](); let attributeTypes = typeMap[type].getAttributeTypeMap(); - for (let index in attributeTypes) { - let attributeType = attributeTypes[index]; + for (let attributeType of attributeTypes) { let value = ObjectSerializer.deserialize(data[attributeType.baseName], attributeType.type, attributeType.format); if (value !== undefined) { instance[attributeType.name] = value; diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/models/ObjectSerializer.ts b/samples/openapi3/client/petstore/typescript/builds/inversify/models/ObjectSerializer.ts index a5f5708b12c..dfbb605553b 100644 --- a/samples/openapi3/client/petstore/typescript/builds/inversify/models/ObjectSerializer.ts +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/models/ObjectSerializer.ts @@ -90,8 +90,7 @@ export class ObjectSerializer { let subType: string = type.replace("Array<", ""); // Array => Type> subType = subType.substring(0, subType.length - 1); // Type> => Type let transformedData: any[] = []; - for (let index in data) { - let date = data[index]; + for (let date of data) { transformedData.push(ObjectSerializer.serialize(date, subType, format)); } return transformedData; @@ -120,8 +119,7 @@ export class ObjectSerializer { // get the map for the correct type. let attributeTypes = typeMap[type].getAttributeTypeMap(); let instance: {[index: string]: any} = {}; - for (let index in attributeTypes) { - let attributeType = attributeTypes[index]; + for (let attributeType of attributeTypes) { instance[attributeType.baseName] = ObjectSerializer.serialize(data[attributeType.name], attributeType.type, attributeType.format); } return instance; @@ -139,8 +137,7 @@ export class ObjectSerializer { let subType: string = type.replace("Array<", ""); // Array => Type> subType = subType.substring(0, subType.length - 1); // Type> => Type let transformedData: any[] = []; - for (let index in data) { - let date = data[index]; + for (let date of data) { transformedData.push(ObjectSerializer.deserialize(date, subType, format)); } return transformedData; @@ -156,8 +153,7 @@ export class ObjectSerializer { } let instance = new typeMap[type](); let attributeTypes = typeMap[type].getAttributeTypeMap(); - for (let index in attributeTypes) { - let attributeType = attributeTypes[index]; + for (let attributeType of attributeTypes) { let value = ObjectSerializer.deserialize(data[attributeType.baseName], attributeType.type, attributeType.format); if (value !== undefined) { instance[attributeType.name] = value; diff --git a/samples/openapi3/client/petstore/typescript/builds/jquery/models/ObjectSerializer.ts b/samples/openapi3/client/petstore/typescript/builds/jquery/models/ObjectSerializer.ts index a5f5708b12c..dfbb605553b 100644 --- a/samples/openapi3/client/petstore/typescript/builds/jquery/models/ObjectSerializer.ts +++ b/samples/openapi3/client/petstore/typescript/builds/jquery/models/ObjectSerializer.ts @@ -90,8 +90,7 @@ export class ObjectSerializer { let subType: string = type.replace("Array<", ""); // Array => Type> subType = subType.substring(0, subType.length - 1); // Type> => Type let transformedData: any[] = []; - for (let index in data) { - let date = data[index]; + for (let date of data) { transformedData.push(ObjectSerializer.serialize(date, subType, format)); } return transformedData; @@ -120,8 +119,7 @@ export class ObjectSerializer { // get the map for the correct type. let attributeTypes = typeMap[type].getAttributeTypeMap(); let instance: {[index: string]: any} = {}; - for (let index in attributeTypes) { - let attributeType = attributeTypes[index]; + for (let attributeType of attributeTypes) { instance[attributeType.baseName] = ObjectSerializer.serialize(data[attributeType.name], attributeType.type, attributeType.format); } return instance; @@ -139,8 +137,7 @@ export class ObjectSerializer { let subType: string = type.replace("Array<", ""); // Array => Type> subType = subType.substring(0, subType.length - 1); // Type> => Type let transformedData: any[] = []; - for (let index in data) { - let date = data[index]; + for (let date of data) { transformedData.push(ObjectSerializer.deserialize(date, subType, format)); } return transformedData; @@ -156,8 +153,7 @@ export class ObjectSerializer { } let instance = new typeMap[type](); let attributeTypes = typeMap[type].getAttributeTypeMap(); - for (let index in attributeTypes) { - let attributeType = attributeTypes[index]; + for (let attributeType of attributeTypes) { let value = ObjectSerializer.deserialize(data[attributeType.baseName], attributeType.type, attributeType.format); if (value !== undefined) { instance[attributeType.name] = value; diff --git a/samples/openapi3/client/petstore/typescript/builds/object_params/models/ObjectSerializer.ts b/samples/openapi3/client/petstore/typescript/builds/object_params/models/ObjectSerializer.ts index a5f5708b12c..dfbb605553b 100644 --- a/samples/openapi3/client/petstore/typescript/builds/object_params/models/ObjectSerializer.ts +++ b/samples/openapi3/client/petstore/typescript/builds/object_params/models/ObjectSerializer.ts @@ -90,8 +90,7 @@ export class ObjectSerializer { let subType: string = type.replace("Array<", ""); // Array => Type> subType = subType.substring(0, subType.length - 1); // Type> => Type let transformedData: any[] = []; - for (let index in data) { - let date = data[index]; + for (let date of data) { transformedData.push(ObjectSerializer.serialize(date, subType, format)); } return transformedData; @@ -120,8 +119,7 @@ export class ObjectSerializer { // get the map for the correct type. let attributeTypes = typeMap[type].getAttributeTypeMap(); let instance: {[index: string]: any} = {}; - for (let index in attributeTypes) { - let attributeType = attributeTypes[index]; + for (let attributeType of attributeTypes) { instance[attributeType.baseName] = ObjectSerializer.serialize(data[attributeType.name], attributeType.type, attributeType.format); } return instance; @@ -139,8 +137,7 @@ export class ObjectSerializer { let subType: string = type.replace("Array<", ""); // Array => Type> subType = subType.substring(0, subType.length - 1); // Type> => Type let transformedData: any[] = []; - for (let index in data) { - let date = data[index]; + for (let date of data) { transformedData.push(ObjectSerializer.deserialize(date, subType, format)); } return transformedData; @@ -156,8 +153,7 @@ export class ObjectSerializer { } let instance = new typeMap[type](); let attributeTypes = typeMap[type].getAttributeTypeMap(); - for (let index in attributeTypes) { - let attributeType = attributeTypes[index]; + for (let attributeType of attributeTypes) { let value = ObjectSerializer.deserialize(data[attributeType.baseName], attributeType.type, attributeType.format); if (value !== undefined) { instance[attributeType.name] = value;