diff --git a/modules/openapi-generator/src/main/resources/typescript-fetch/modelEnum.mustache b/modules/openapi-generator/src/main/resources/typescript-fetch/modelEnum.mustache index 79c0ee1d59..312b6320e0 100644 --- a/modules/openapi-generator/src/main/resources/typescript-fetch/modelEnum.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-fetch/modelEnum.mustache @@ -1,7 +1,14 @@ {{>modelEnumInterfaces}} export function instanceOf{{classname}}(value: any): boolean { - return Object.values({{classname}}).includes(value); + for (const key in {{classname}}) { + if (Object.prototype.hasOwnProperty.call({{classname}}, key)) { + if ({{classname}}[key] === value) { + return true; + } + } + } + return false; } export function {{classname}}FromJSON(json: any): {{classname}} { diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/EnumClass.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/EnumClass.ts index 2642db8089..d83d77aa5f 100644 --- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/EnumClass.ts +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/EnumClass.ts @@ -26,7 +26,14 @@ export type EnumClass = typeof EnumClass[keyof typeof EnumClass]; export function instanceOfEnumClass(value: any): boolean { - return Object.values(EnumClass).includes(value); + for (const key in EnumClass) { + if (Object.prototype.hasOwnProperty.call(EnumClass, key)) { + if (EnumClass[key] === value) { + return true; + } + } + } + return false; } export function EnumClassFromJSON(json: any): EnumClass { diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/OuterEnum.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/OuterEnum.ts index 1e1bb96977..a35b756181 100644 --- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/OuterEnum.ts +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/OuterEnum.ts @@ -26,7 +26,14 @@ export type OuterEnum = typeof OuterEnum[keyof typeof OuterEnum]; export function instanceOfOuterEnum(value: any): boolean { - return Object.values(OuterEnum).includes(value); + for (const key in OuterEnum) { + if (Object.prototype.hasOwnProperty.call(OuterEnum, key)) { + if (OuterEnum[key] === value) { + return true; + } + } + } + return false; } export function OuterEnumFromJSON(json: any): OuterEnum { diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/OuterEnumDefaultValue.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/OuterEnumDefaultValue.ts index 93a84658c1..08c50c71d6 100644 --- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/OuterEnumDefaultValue.ts +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/OuterEnumDefaultValue.ts @@ -26,7 +26,14 @@ export type OuterEnumDefaultValue = typeof OuterEnumDefaultValue[keyof typeof Ou export function instanceOfOuterEnumDefaultValue(value: any): boolean { - return Object.values(OuterEnumDefaultValue).includes(value); + for (const key in OuterEnumDefaultValue) { + if (Object.prototype.hasOwnProperty.call(OuterEnumDefaultValue, key)) { + if (OuterEnumDefaultValue[key] === value) { + return true; + } + } + } + return false; } export function OuterEnumDefaultValueFromJSON(json: any): OuterEnumDefaultValue { diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/OuterEnumInteger.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/OuterEnumInteger.ts index 9ca8643211..4c017a1ceb 100644 --- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/OuterEnumInteger.ts +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/OuterEnumInteger.ts @@ -26,7 +26,14 @@ export type OuterEnumInteger = typeof OuterEnumInteger[keyof typeof OuterEnumInt export function instanceOfOuterEnumInteger(value: any): boolean { - return Object.values(OuterEnumInteger).includes(value); + for (const key in OuterEnumInteger) { + if (Object.prototype.hasOwnProperty.call(OuterEnumInteger, key)) { + if (OuterEnumInteger[key] === value) { + return true; + } + } + } + return false; } export function OuterEnumIntegerFromJSON(json: any): OuterEnumInteger { diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/OuterEnumIntegerDefaultValue.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/OuterEnumIntegerDefaultValue.ts index 7daa71a99e..8e16b56eed 100644 --- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/OuterEnumIntegerDefaultValue.ts +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/OuterEnumIntegerDefaultValue.ts @@ -26,7 +26,14 @@ export type OuterEnumIntegerDefaultValue = typeof OuterEnumIntegerDefaultValue[k export function instanceOfOuterEnumIntegerDefaultValue(value: any): boolean { - return Object.values(OuterEnumIntegerDefaultValue).includes(value); + for (const key in OuterEnumIntegerDefaultValue) { + if (Object.prototype.hasOwnProperty.call(OuterEnumIntegerDefaultValue, key)) { + if (OuterEnumIntegerDefaultValue[key] === value) { + return true; + } + } + } + return false; } export function OuterEnumIntegerDefaultValueFromJSON(json: any): OuterEnumIntegerDefaultValue { diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/SingleRefType.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/SingleRefType.ts index 60d49d6f22..7dbee0a8e9 100644 --- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/SingleRefType.ts +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/SingleRefType.ts @@ -25,7 +25,14 @@ export type SingleRefType = typeof SingleRefType[keyof typeof SingleRefType]; export function instanceOfSingleRefType(value: any): boolean { - return Object.values(SingleRefType).includes(value); + for (const key in SingleRefType) { + if (Object.prototype.hasOwnProperty.call(SingleRefType, key)) { + if (SingleRefType[key] === value) { + return true; + } + } + } + return false; } export function SingleRefTypeFromJSON(json: any): SingleRefType { diff --git a/samples/client/petstore/typescript-fetch/builds/enum/models/NumberEnum.ts b/samples/client/petstore/typescript-fetch/builds/enum/models/NumberEnum.ts index a884536c2c..a0c1b58a29 100644 --- a/samples/client/petstore/typescript-fetch/builds/enum/models/NumberEnum.ts +++ b/samples/client/petstore/typescript-fetch/builds/enum/models/NumberEnum.ts @@ -26,7 +26,14 @@ export type NumberEnum = typeof NumberEnum[keyof typeof NumberEnum]; export function instanceOfNumberEnum(value: any): boolean { - return Object.values(NumberEnum).includes(value); + for (const key in NumberEnum) { + if (Object.prototype.hasOwnProperty.call(NumberEnum, key)) { + if (NumberEnum[key] === value) { + return true; + } + } + } + return false; } export function NumberEnumFromJSON(json: any): NumberEnum { diff --git a/samples/client/petstore/typescript-fetch/builds/enum/models/StringEnum.ts b/samples/client/petstore/typescript-fetch/builds/enum/models/StringEnum.ts index 503619ddd8..c59850ed4b 100644 --- a/samples/client/petstore/typescript-fetch/builds/enum/models/StringEnum.ts +++ b/samples/client/petstore/typescript-fetch/builds/enum/models/StringEnum.ts @@ -26,7 +26,14 @@ export type StringEnum = typeof StringEnum[keyof typeof StringEnum]; export function instanceOfStringEnum(value: any): boolean { - return Object.values(StringEnum).includes(value); + for (const key in StringEnum) { + if (Object.prototype.hasOwnProperty.call(StringEnum, key)) { + if (StringEnum[key] === value) { + return true; + } + } + } + return false; } export function StringEnumFromJSON(json: any): StringEnum { diff --git a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/BehaviorType.ts b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/BehaviorType.ts index b2ce4c035d..481793ab0b 100644 --- a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/BehaviorType.ts +++ b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/BehaviorType.ts @@ -26,7 +26,14 @@ export type BehaviorType = typeof BehaviorType[keyof typeof BehaviorType]; export function instanceOfBehaviorType(value: any): boolean { - return Object.values(BehaviorType).includes(value); + for (const key in BehaviorType) { + if (Object.prototype.hasOwnProperty.call(BehaviorType, key)) { + if (BehaviorType[key] === value) { + return true; + } + } + } + return false; } export function BehaviorTypeFromJSON(json: any): BehaviorType { diff --git a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/DeploymentRequestStatus.ts b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/DeploymentRequestStatus.ts index ee1f52f20a..f04bfb6e45 100644 --- a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/DeploymentRequestStatus.ts +++ b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/DeploymentRequestStatus.ts @@ -35,7 +35,14 @@ export type DeploymentRequestStatus = typeof DeploymentRequestStatus[keyof typeo export function instanceOfDeploymentRequestStatus(value: any): boolean { - return Object.values(DeploymentRequestStatus).includes(value); + for (const key in DeploymentRequestStatus) { + if (Object.prototype.hasOwnProperty.call(DeploymentRequestStatus, key)) { + if (DeploymentRequestStatus[key] === value) { + return true; + } + } + } + return false; } export function DeploymentRequestStatusFromJSON(json: any): DeploymentRequestStatus { diff --git a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/ErrorCode.ts b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/ErrorCode.ts index a562973d26..13fe193a73 100644 --- a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/ErrorCode.ts +++ b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/ErrorCode.ts @@ -41,7 +41,14 @@ export type ErrorCode = typeof ErrorCode[keyof typeof ErrorCode]; export function instanceOfErrorCode(value: any): boolean { - return Object.values(ErrorCode).includes(value); + for (const key in ErrorCode) { + if (Object.prototype.hasOwnProperty.call(ErrorCode, key)) { + if (ErrorCode[key] === value) { + return true; + } + } + } + return false; } export function ErrorCodeFromJSON(json: any): ErrorCode { diff --git a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/PetPartType.ts b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/PetPartType.ts index bf2426212c..1aa5863611 100644 --- a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/PetPartType.ts +++ b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/PetPartType.ts @@ -26,7 +26,14 @@ export type PetPartType = typeof PetPartType[keyof typeof PetPartType]; export function instanceOfPetPartType(value: any): boolean { - return Object.values(PetPartType).includes(value); + for (const key in PetPartType) { + if (Object.prototype.hasOwnProperty.call(PetPartType, key)) { + if (PetPartType[key] === value) { + return true; + } + } + } + return false; } export function PetPartTypeFromJSON(json: any): PetPartType { diff --git a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/WarningCode.ts b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/WarningCode.ts index 8906f49dd9..4554cb6dff 100644 --- a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/WarningCode.ts +++ b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/WarningCode.ts @@ -26,7 +26,14 @@ export type WarningCode = typeof WarningCode[keyof typeof WarningCode]; export function instanceOfWarningCode(value: any): boolean { - return Object.values(WarningCode).includes(value); + for (const key in WarningCode) { + if (Object.prototype.hasOwnProperty.call(WarningCode, key)) { + if (WarningCode[key] === value) { + return true; + } + } + } + return false; } export function WarningCodeFromJSON(json: any): WarningCode { diff --git a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/EnumClass.ts b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/EnumClass.ts index 2642db8089..d83d77aa5f 100644 --- a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/EnumClass.ts +++ b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/EnumClass.ts @@ -26,7 +26,14 @@ export type EnumClass = typeof EnumClass[keyof typeof EnumClass]; export function instanceOfEnumClass(value: any): boolean { - return Object.values(EnumClass).includes(value); + for (const key in EnumClass) { + if (Object.prototype.hasOwnProperty.call(EnumClass, key)) { + if (EnumClass[key] === value) { + return true; + } + } + } + return false; } export function EnumClassFromJSON(json: any): EnumClass { diff --git a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/OuterEnum.ts b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/OuterEnum.ts index 1e1bb96977..a35b756181 100644 --- a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/OuterEnum.ts +++ b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/OuterEnum.ts @@ -26,7 +26,14 @@ export type OuterEnum = typeof OuterEnum[keyof typeof OuterEnum]; export function instanceOfOuterEnum(value: any): boolean { - return Object.values(OuterEnum).includes(value); + for (const key in OuterEnum) { + if (Object.prototype.hasOwnProperty.call(OuterEnum, key)) { + if (OuterEnum[key] === value) { + return true; + } + } + } + return false; } export function OuterEnumFromJSON(json: any): OuterEnum { diff --git a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/OuterEnumDefaultValue.ts b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/OuterEnumDefaultValue.ts index 93a84658c1..08c50c71d6 100644 --- a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/OuterEnumDefaultValue.ts +++ b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/OuterEnumDefaultValue.ts @@ -26,7 +26,14 @@ export type OuterEnumDefaultValue = typeof OuterEnumDefaultValue[keyof typeof Ou export function instanceOfOuterEnumDefaultValue(value: any): boolean { - return Object.values(OuterEnumDefaultValue).includes(value); + for (const key in OuterEnumDefaultValue) { + if (Object.prototype.hasOwnProperty.call(OuterEnumDefaultValue, key)) { + if (OuterEnumDefaultValue[key] === value) { + return true; + } + } + } + return false; } export function OuterEnumDefaultValueFromJSON(json: any): OuterEnumDefaultValue { diff --git a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/OuterEnumInteger.ts b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/OuterEnumInteger.ts index 9ca8643211..4c017a1ceb 100644 --- a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/OuterEnumInteger.ts +++ b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/OuterEnumInteger.ts @@ -26,7 +26,14 @@ export type OuterEnumInteger = typeof OuterEnumInteger[keyof typeof OuterEnumInt export function instanceOfOuterEnumInteger(value: any): boolean { - return Object.values(OuterEnumInteger).includes(value); + for (const key in OuterEnumInteger) { + if (Object.prototype.hasOwnProperty.call(OuterEnumInteger, key)) { + if (OuterEnumInteger[key] === value) { + return true; + } + } + } + return false; } export function OuterEnumIntegerFromJSON(json: any): OuterEnumInteger { diff --git a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/OuterEnumIntegerDefaultValue.ts b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/OuterEnumIntegerDefaultValue.ts index 7daa71a99e..8e16b56eed 100644 --- a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/OuterEnumIntegerDefaultValue.ts +++ b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/OuterEnumIntegerDefaultValue.ts @@ -26,7 +26,14 @@ export type OuterEnumIntegerDefaultValue = typeof OuterEnumIntegerDefaultValue[k export function instanceOfOuterEnumIntegerDefaultValue(value: any): boolean { - return Object.values(OuterEnumIntegerDefaultValue).includes(value); + for (const key in OuterEnumIntegerDefaultValue) { + if (Object.prototype.hasOwnProperty.call(OuterEnumIntegerDefaultValue, key)) { + if (OuterEnumIntegerDefaultValue[key] === value) { + return true; + } + } + } + return false; } export function OuterEnumIntegerDefaultValueFromJSON(json: any): OuterEnumIntegerDefaultValue { diff --git a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/SingleRefType.ts b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/SingleRefType.ts index 60d49d6f22..7dbee0a8e9 100644 --- a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/SingleRefType.ts +++ b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/SingleRefType.ts @@ -25,7 +25,14 @@ export type SingleRefType = typeof SingleRefType[keyof typeof SingleRefType]; export function instanceOfSingleRefType(value: any): boolean { - return Object.values(SingleRefType).includes(value); + for (const key in SingleRefType) { + if (Object.prototype.hasOwnProperty.call(SingleRefType, key)) { + if (SingleRefType[key] === value) { + return true; + } + } + } + return false; } export function SingleRefTypeFromJSON(json: any): SingleRefType { diff --git a/samples/client/petstore/typescript-fetch/builds/with-string-enums/models/NumberEnum.ts b/samples/client/petstore/typescript-fetch/builds/with-string-enums/models/NumberEnum.ts index e65639e50e..5b3ea298b9 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-string-enums/models/NumberEnum.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-string-enums/models/NumberEnum.ts @@ -25,7 +25,14 @@ export enum NumberEnum { export function instanceOfNumberEnum(value: any): boolean { - return Object.values(NumberEnum).includes(value); + for (const key in NumberEnum) { + if (Object.prototype.hasOwnProperty.call(NumberEnum, key)) { + if (NumberEnum[key] === value) { + return true; + } + } + } + return false; } export function NumberEnumFromJSON(json: any): NumberEnum { diff --git a/samples/client/petstore/typescript-fetch/builds/with-string-enums/models/StringEnum.ts b/samples/client/petstore/typescript-fetch/builds/with-string-enums/models/StringEnum.ts index d8720fe1fe..21f232a76a 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-string-enums/models/StringEnum.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-string-enums/models/StringEnum.ts @@ -25,7 +25,14 @@ export enum StringEnum { export function instanceOfStringEnum(value: any): boolean { - return Object.values(StringEnum).includes(value); + for (const key in StringEnum) { + if (Object.prototype.hasOwnProperty.call(StringEnum, key)) { + if (StringEnum[key] === value) { + return true; + } + } + } + return false; } export function StringEnumFromJSON(json: any): StringEnum {