From f0d11d6e96c8f355f45348c60c55fcc2588d5606 Mon Sep 17 00:00:00 2001 From: Stephan Pelikan Date: Tue, 27 Aug 2019 14:11:43 +0200 Subject: [PATCH 1/4] #3646 - fix inheritence --- .../typescript-fetch/modelGeneric.mustache | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache b/modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache index 89d13244397a..a354b000af5d 100644 --- a/modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache @@ -9,6 +9,14 @@ import { } from './'; {{/hasImports}} +{{#discriminator}} +import { +{{#discriminator.mappedModels}} + {{modelName}}FromJSON +{{/discriminator.mappedModels}} +} from './'; + +{{/discriminator}} /** * {{{description}}} * @export @@ -28,9 +36,20 @@ export interface {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{ {{/vars}} } -export function {{classname}}FromJSON(json: any): {{classname}} { +export function {{classname}}FromJSON(json: any, ignoreDiscriminator?: boolean): {{classname}} { {{#hasVars}} + if ((json === undefined) || (json === null)) { + return json; + } + if (!ignoreDiscriminator) { +{{#discriminator.mappedModels}} + if (json['{{discriminator.propertyName}}'] === '{{modelName}}') { + return {{modelName}}FromJSON(json, true); + } +{{/discriminator.mappedModels}} + } return { + {{#parent}}...{{{parent}}}FromJSON(json, ignoreDiscriminator),{{/parent}} {{#additionalPropertiesType}} ...json, {{/additionalPropertiesType}} @@ -79,7 +98,11 @@ export function {{classname}}ToJSON(value?: {{classname}}): any { if (value === undefined) { return undefined; } + if (value == null) { + return null; + } return { + {{#parent}}...{{{parent}}}ToJSON(value),{{/parent}} {{#additionalPropertiesType}} ...value, {{/additionalPropertiesType}} From ff700f6c6431e6dde4fb3a9cfbeda370bc72be3d Mon Sep 17 00:00:00 2001 From: Stephan Pelikan Date: Tue, 27 Aug 2019 14:49:37 +0200 Subject: [PATCH 2/4] #3646: Fix imports --- .../resources/typescript-fetch/modelEnum.mustache | 4 ++++ .../typescript-fetch/modelGeneric.mustache | 15 +++++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) 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 f3ded52fdb59..0db1d9a5a805 100644 --- a/modules/openapi-generator/src/main/resources/typescript-fetch/modelEnum.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-fetch/modelEnum.mustache @@ -12,6 +12,10 @@ export enum {{classname}} { } export function {{classname}}FromJSON(json: any): {{classname}} { + return {{classname}}FromJSONTyped(json, false); +} + +export function {{classname}}FromJSONTyped(json: any, ignoreDiscriminator: boolean): {{classname}} { return json as {{classname}}; } diff --git a/modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache b/modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache index a354b000af5d..c7c383f1c453 100644 --- a/modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache @@ -4,6 +4,7 @@ import { {{#imports}} {{{.}}}, {{.}}FromJSON, + {{.}}FromJSONTyped, {{.}}ToJSON, {{/imports}} } from './'; @@ -12,7 +13,7 @@ import { {{#discriminator}} import { {{#discriminator.mappedModels}} - {{modelName}}FromJSON + {{modelName}}FromJSONTyped {{/discriminator.mappedModels}} } from './'; @@ -36,20 +37,26 @@ export interface {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{ {{/vars}} } -export function {{classname}}FromJSON(json: any, ignoreDiscriminator?: boolean): {{classname}} { +export function {{classname}}FromJSON(json: any): {{classname}} { + return {{classname}}FromJSONTyped(json, false); +} + +export function {{classname}}FromJSONTyped(json: any, ignoreDiscriminator: boolean): {{classname}} { {{#hasVars}} if ((json === undefined) || (json === null)) { return json; } +{{#discriminator}} if (!ignoreDiscriminator) { {{#discriminator.mappedModels}} if (json['{{discriminator.propertyName}}'] === '{{modelName}}') { - return {{modelName}}FromJSON(json, true); + return {{modelName}}FromJSONTyped(json, true); } {{/discriminator.mappedModels}} } +{{/discriminator}} return { - {{#parent}}...{{{parent}}}FromJSON(json, ignoreDiscriminator),{{/parent}} + {{#parent}}...{{{parent}}}FromJSONTyped(json, ignoreDiscriminator),{{/parent}} {{#additionalPropertiesType}} ...json, {{/additionalPropertiesType}} From 9c52a1199a573bfa34718c5a956a9a08b5da9e57 Mon Sep 17 00:00:00 2001 From: stephanpelikan Date: Tue, 27 Aug 2019 16:51:51 +0200 Subject: [PATCH 3/4] Update modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache Co-Authored-By: Esteban Gehring --- .../src/main/resources/typescript-fetch/modelGeneric.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache b/modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache index c7c383f1c453..0767831e14d5 100644 --- a/modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache @@ -105,7 +105,7 @@ export function {{classname}}ToJSON(value?: {{classname}}): any { if (value === undefined) { return undefined; } - if (value == null) { + if (value === null) { return null; } return { From a76e10a8703acccbc0cd9d1d33e8490be67a1b00 Mon Sep 17 00:00:00 2001 From: Esteban Gehring Date: Wed, 28 Aug 2019 09:28:23 +0200 Subject: [PATCH 4/4] generate typeescript-fetch samples --- .../builds/default/src/models/Category.ts | 12 ++++++++++++ .../builds/default/src/models/ModelApiResponse.ts | 12 ++++++++++++ .../builds/default/src/models/Order.ts | 12 ++++++++++++ .../builds/default/src/models/Pet.ts | 14 ++++++++++++++ .../builds/default/src/models/Tag.ts | 12 ++++++++++++ .../builds/default/src/models/User.ts | 12 ++++++++++++ .../builds/es6-target/src/models/Category.ts | 12 ++++++++++++ .../es6-target/src/models/ModelApiResponse.ts | 12 ++++++++++++ .../builds/es6-target/src/models/Order.ts | 12 ++++++++++++ .../builds/es6-target/src/models/Pet.ts | 14 ++++++++++++++ .../builds/es6-target/src/models/Tag.ts | 12 ++++++++++++ .../builds/es6-target/src/models/User.ts | 12 ++++++++++++ .../multiple-parameters/src/models/Category.ts | 12 ++++++++++++ .../src/models/ModelApiResponse.ts | 12 ++++++++++++ .../builds/multiple-parameters/src/models/Order.ts | 12 ++++++++++++ .../builds/multiple-parameters/src/models/Pet.ts | 14 ++++++++++++++ .../builds/multiple-parameters/src/models/Tag.ts | 12 ++++++++++++ .../builds/multiple-parameters/src/models/User.ts | 12 ++++++++++++ .../src/models/Category.ts | 12 ++++++++++++ .../src/models/ModelApiResponse.ts | 12 ++++++++++++ .../src/models/Order.ts | 12 ++++++++++++ .../prefix-parameter-interfaces/src/models/Pet.ts | 14 ++++++++++++++ .../prefix-parameter-interfaces/src/models/Tag.ts | 12 ++++++++++++ .../prefix-parameter-interfaces/src/models/User.ts | 12 ++++++++++++ .../builds/with-interfaces/src/models/Category.ts | 12 ++++++++++++ .../with-interfaces/src/models/ModelApiResponse.ts | 12 ++++++++++++ .../builds/with-interfaces/src/models/Order.ts | 12 ++++++++++++ .../builds/with-interfaces/src/models/Pet.ts | 14 ++++++++++++++ .../builds/with-interfaces/src/models/Tag.ts | 12 ++++++++++++ .../builds/with-interfaces/src/models/User.ts | 12 ++++++++++++ .../builds/with-npm-version/src/models/Category.ts | 12 ++++++++++++ .../src/models/ModelApiResponse.ts | 12 ++++++++++++ .../builds/with-npm-version/src/models/Order.ts | 12 ++++++++++++ .../builds/with-npm-version/src/models/Pet.ts | 14 ++++++++++++++ .../builds/with-npm-version/src/models/Tag.ts | 12 ++++++++++++ .../builds/with-npm-version/src/models/User.ts | 12 ++++++++++++ 36 files changed, 444 insertions(+) diff --git a/samples/client/petstore/typescript-fetch/builds/default/src/models/Category.ts b/samples/client/petstore/typescript-fetch/builds/default/src/models/Category.ts index f8809dccbea3..0541f013a256 100644 --- a/samples/client/petstore/typescript-fetch/builds/default/src/models/Category.ts +++ b/samples/client/petstore/typescript-fetch/builds/default/src/models/Category.ts @@ -33,7 +33,15 @@ export interface Category { } export function CategoryFromJSON(json: any): Category { + return CategoryFromJSONTyped(json, false); +} + +export function CategoryFromJSONTyped(json: any, ignoreDiscriminator: boolean): Category { + if ((json === undefined) || (json === null)) { + return json; + } return { + 'id': !exists(json, 'id') ? undefined : json['id'], 'name': !exists(json, 'name') ? undefined : json['name'], }; @@ -43,7 +51,11 @@ export function CategoryToJSON(value?: Category): any { if (value === undefined) { return undefined; } + if (value === null) { + return null; + } return { + 'id': value.id, 'name': value.name, }; diff --git a/samples/client/petstore/typescript-fetch/builds/default/src/models/ModelApiResponse.ts b/samples/client/petstore/typescript-fetch/builds/default/src/models/ModelApiResponse.ts index 8b8e2c45fecd..a9f1ef2fa241 100644 --- a/samples/client/petstore/typescript-fetch/builds/default/src/models/ModelApiResponse.ts +++ b/samples/client/petstore/typescript-fetch/builds/default/src/models/ModelApiResponse.ts @@ -39,7 +39,15 @@ export interface ModelApiResponse { } export function ModelApiResponseFromJSON(json: any): ModelApiResponse { + return ModelApiResponseFromJSONTyped(json, false); +} + +export function ModelApiResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): ModelApiResponse { + if ((json === undefined) || (json === null)) { + return json; + } return { + 'code': !exists(json, 'code') ? undefined : json['code'], 'type': !exists(json, 'type') ? undefined : json['type'], 'message': !exists(json, 'message') ? undefined : json['message'], @@ -50,7 +58,11 @@ export function ModelApiResponseToJSON(value?: ModelApiResponse): any { if (value === undefined) { return undefined; } + if (value === null) { + return null; + } return { + 'code': value.code, 'type': value.type, 'message': value.message, diff --git a/samples/client/petstore/typescript-fetch/builds/default/src/models/Order.ts b/samples/client/petstore/typescript-fetch/builds/default/src/models/Order.ts index 6ce0496794f6..b9d32f387afb 100644 --- a/samples/client/petstore/typescript-fetch/builds/default/src/models/Order.ts +++ b/samples/client/petstore/typescript-fetch/builds/default/src/models/Order.ts @@ -57,7 +57,15 @@ export interface Order { } export function OrderFromJSON(json: any): Order { + return OrderFromJSONTyped(json, false); +} + +export function OrderFromJSONTyped(json: any, ignoreDiscriminator: boolean): Order { + if ((json === undefined) || (json === null)) { + return json; + } return { + 'id': !exists(json, 'id') ? undefined : json['id'], 'petId': !exists(json, 'petId') ? undefined : json['petId'], 'quantity': !exists(json, 'quantity') ? undefined : json['quantity'], @@ -71,7 +79,11 @@ export function OrderToJSON(value?: Order): any { if (value === undefined) { return undefined; } + if (value === null) { + return null; + } return { + 'id': value.id, 'petId': value.petId, 'quantity': value.quantity, diff --git a/samples/client/petstore/typescript-fetch/builds/default/src/models/Pet.ts b/samples/client/petstore/typescript-fetch/builds/default/src/models/Pet.ts index 770f991b89d9..d0cf8f55c2c4 100644 --- a/samples/client/petstore/typescript-fetch/builds/default/src/models/Pet.ts +++ b/samples/client/petstore/typescript-fetch/builds/default/src/models/Pet.ts @@ -15,9 +15,11 @@ import { exists, mapValues } from '../runtime'; import { Category, CategoryFromJSON, + CategoryFromJSONTyped, CategoryToJSON, Tag, TagFromJSON, + TagFromJSONTyped, TagToJSON, } from './'; @@ -66,7 +68,15 @@ export interface Pet { } export function PetFromJSON(json: any): Pet { + return PetFromJSONTyped(json, false); +} + +export function PetFromJSONTyped(json: any, ignoreDiscriminator: boolean): Pet { + if ((json === undefined) || (json === null)) { + return json; + } return { + 'id': !exists(json, 'id') ? undefined : json['id'], 'category': !exists(json, 'category') ? undefined : CategoryFromJSON(json['category']), 'name': json['name'], @@ -80,7 +90,11 @@ export function PetToJSON(value?: Pet): any { if (value === undefined) { return undefined; } + if (value === null) { + return null; + } return { + 'id': value.id, 'category': CategoryToJSON(value.category), 'name': value.name, diff --git a/samples/client/petstore/typescript-fetch/builds/default/src/models/Tag.ts b/samples/client/petstore/typescript-fetch/builds/default/src/models/Tag.ts index 7c8098f6dc01..a095d07d0c05 100644 --- a/samples/client/petstore/typescript-fetch/builds/default/src/models/Tag.ts +++ b/samples/client/petstore/typescript-fetch/builds/default/src/models/Tag.ts @@ -33,7 +33,15 @@ export interface Tag { } export function TagFromJSON(json: any): Tag { + return TagFromJSONTyped(json, false); +} + +export function TagFromJSONTyped(json: any, ignoreDiscriminator: boolean): Tag { + if ((json === undefined) || (json === null)) { + return json; + } return { + 'id': !exists(json, 'id') ? undefined : json['id'], 'name': !exists(json, 'name') ? undefined : json['name'], }; @@ -43,7 +51,11 @@ export function TagToJSON(value?: Tag): any { if (value === undefined) { return undefined; } + if (value === null) { + return null; + } return { + 'id': value.id, 'name': value.name, }; diff --git a/samples/client/petstore/typescript-fetch/builds/default/src/models/User.ts b/samples/client/petstore/typescript-fetch/builds/default/src/models/User.ts index fd7430063f1c..0649d0e1229c 100644 --- a/samples/client/petstore/typescript-fetch/builds/default/src/models/User.ts +++ b/samples/client/petstore/typescript-fetch/builds/default/src/models/User.ts @@ -69,7 +69,15 @@ export interface User { } export function UserFromJSON(json: any): User { + return UserFromJSONTyped(json, false); +} + +export function UserFromJSONTyped(json: any, ignoreDiscriminator: boolean): User { + if ((json === undefined) || (json === null)) { + return json; + } return { + 'id': !exists(json, 'id') ? undefined : json['id'], 'username': !exists(json, 'username') ? undefined : json['username'], 'firstName': !exists(json, 'firstName') ? undefined : json['firstName'], @@ -85,7 +93,11 @@ export function UserToJSON(value?: User): any { if (value === undefined) { return undefined; } + if (value === null) { + return null; + } return { + 'id': value.id, 'username': value.username, 'firstName': value.firstName, diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/src/models/Category.ts b/samples/client/petstore/typescript-fetch/builds/es6-target/src/models/Category.ts index f8809dccbea3..0541f013a256 100644 --- a/samples/client/petstore/typescript-fetch/builds/es6-target/src/models/Category.ts +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/src/models/Category.ts @@ -33,7 +33,15 @@ export interface Category { } export function CategoryFromJSON(json: any): Category { + return CategoryFromJSONTyped(json, false); +} + +export function CategoryFromJSONTyped(json: any, ignoreDiscriminator: boolean): Category { + if ((json === undefined) || (json === null)) { + return json; + } return { + 'id': !exists(json, 'id') ? undefined : json['id'], 'name': !exists(json, 'name') ? undefined : json['name'], }; @@ -43,7 +51,11 @@ export function CategoryToJSON(value?: Category): any { if (value === undefined) { return undefined; } + if (value === null) { + return null; + } return { + 'id': value.id, 'name': value.name, }; diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/src/models/ModelApiResponse.ts b/samples/client/petstore/typescript-fetch/builds/es6-target/src/models/ModelApiResponse.ts index 8b8e2c45fecd..a9f1ef2fa241 100644 --- a/samples/client/petstore/typescript-fetch/builds/es6-target/src/models/ModelApiResponse.ts +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/src/models/ModelApiResponse.ts @@ -39,7 +39,15 @@ export interface ModelApiResponse { } export function ModelApiResponseFromJSON(json: any): ModelApiResponse { + return ModelApiResponseFromJSONTyped(json, false); +} + +export function ModelApiResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): ModelApiResponse { + if ((json === undefined) || (json === null)) { + return json; + } return { + 'code': !exists(json, 'code') ? undefined : json['code'], 'type': !exists(json, 'type') ? undefined : json['type'], 'message': !exists(json, 'message') ? undefined : json['message'], @@ -50,7 +58,11 @@ export function ModelApiResponseToJSON(value?: ModelApiResponse): any { if (value === undefined) { return undefined; } + if (value === null) { + return null; + } return { + 'code': value.code, 'type': value.type, 'message': value.message, diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/src/models/Order.ts b/samples/client/petstore/typescript-fetch/builds/es6-target/src/models/Order.ts index 6ce0496794f6..b9d32f387afb 100644 --- a/samples/client/petstore/typescript-fetch/builds/es6-target/src/models/Order.ts +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/src/models/Order.ts @@ -57,7 +57,15 @@ export interface Order { } export function OrderFromJSON(json: any): Order { + return OrderFromJSONTyped(json, false); +} + +export function OrderFromJSONTyped(json: any, ignoreDiscriminator: boolean): Order { + if ((json === undefined) || (json === null)) { + return json; + } return { + 'id': !exists(json, 'id') ? undefined : json['id'], 'petId': !exists(json, 'petId') ? undefined : json['petId'], 'quantity': !exists(json, 'quantity') ? undefined : json['quantity'], @@ -71,7 +79,11 @@ export function OrderToJSON(value?: Order): any { if (value === undefined) { return undefined; } + if (value === null) { + return null; + } return { + 'id': value.id, 'petId': value.petId, 'quantity': value.quantity, diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/src/models/Pet.ts b/samples/client/petstore/typescript-fetch/builds/es6-target/src/models/Pet.ts index 770f991b89d9..d0cf8f55c2c4 100644 --- a/samples/client/petstore/typescript-fetch/builds/es6-target/src/models/Pet.ts +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/src/models/Pet.ts @@ -15,9 +15,11 @@ import { exists, mapValues } from '../runtime'; import { Category, CategoryFromJSON, + CategoryFromJSONTyped, CategoryToJSON, Tag, TagFromJSON, + TagFromJSONTyped, TagToJSON, } from './'; @@ -66,7 +68,15 @@ export interface Pet { } export function PetFromJSON(json: any): Pet { + return PetFromJSONTyped(json, false); +} + +export function PetFromJSONTyped(json: any, ignoreDiscriminator: boolean): Pet { + if ((json === undefined) || (json === null)) { + return json; + } return { + 'id': !exists(json, 'id') ? undefined : json['id'], 'category': !exists(json, 'category') ? undefined : CategoryFromJSON(json['category']), 'name': json['name'], @@ -80,7 +90,11 @@ export function PetToJSON(value?: Pet): any { if (value === undefined) { return undefined; } + if (value === null) { + return null; + } return { + 'id': value.id, 'category': CategoryToJSON(value.category), 'name': value.name, diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/src/models/Tag.ts b/samples/client/petstore/typescript-fetch/builds/es6-target/src/models/Tag.ts index 7c8098f6dc01..a095d07d0c05 100644 --- a/samples/client/petstore/typescript-fetch/builds/es6-target/src/models/Tag.ts +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/src/models/Tag.ts @@ -33,7 +33,15 @@ export interface Tag { } export function TagFromJSON(json: any): Tag { + return TagFromJSONTyped(json, false); +} + +export function TagFromJSONTyped(json: any, ignoreDiscriminator: boolean): Tag { + if ((json === undefined) || (json === null)) { + return json; + } return { + 'id': !exists(json, 'id') ? undefined : json['id'], 'name': !exists(json, 'name') ? undefined : json['name'], }; @@ -43,7 +51,11 @@ export function TagToJSON(value?: Tag): any { if (value === undefined) { return undefined; } + if (value === null) { + return null; + } return { + 'id': value.id, 'name': value.name, }; diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/src/models/User.ts b/samples/client/petstore/typescript-fetch/builds/es6-target/src/models/User.ts index fd7430063f1c..0649d0e1229c 100644 --- a/samples/client/petstore/typescript-fetch/builds/es6-target/src/models/User.ts +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/src/models/User.ts @@ -69,7 +69,15 @@ export interface User { } export function UserFromJSON(json: any): User { + return UserFromJSONTyped(json, false); +} + +export function UserFromJSONTyped(json: any, ignoreDiscriminator: boolean): User { + if ((json === undefined) || (json === null)) { + return json; + } return { + 'id': !exists(json, 'id') ? undefined : json['id'], 'username': !exists(json, 'username') ? undefined : json['username'], 'firstName': !exists(json, 'firstName') ? undefined : json['firstName'], @@ -85,7 +93,11 @@ export function UserToJSON(value?: User): any { if (value === undefined) { return undefined; } + if (value === null) { + return null; + } return { + 'id': value.id, 'username': value.username, 'firstName': value.firstName, diff --git a/samples/client/petstore/typescript-fetch/builds/multiple-parameters/src/models/Category.ts b/samples/client/petstore/typescript-fetch/builds/multiple-parameters/src/models/Category.ts index f8809dccbea3..0541f013a256 100644 --- a/samples/client/petstore/typescript-fetch/builds/multiple-parameters/src/models/Category.ts +++ b/samples/client/petstore/typescript-fetch/builds/multiple-parameters/src/models/Category.ts @@ -33,7 +33,15 @@ export interface Category { } export function CategoryFromJSON(json: any): Category { + return CategoryFromJSONTyped(json, false); +} + +export function CategoryFromJSONTyped(json: any, ignoreDiscriminator: boolean): Category { + if ((json === undefined) || (json === null)) { + return json; + } return { + 'id': !exists(json, 'id') ? undefined : json['id'], 'name': !exists(json, 'name') ? undefined : json['name'], }; @@ -43,7 +51,11 @@ export function CategoryToJSON(value?: Category): any { if (value === undefined) { return undefined; } + if (value === null) { + return null; + } return { + 'id': value.id, 'name': value.name, }; diff --git a/samples/client/petstore/typescript-fetch/builds/multiple-parameters/src/models/ModelApiResponse.ts b/samples/client/petstore/typescript-fetch/builds/multiple-parameters/src/models/ModelApiResponse.ts index 8b8e2c45fecd..a9f1ef2fa241 100644 --- a/samples/client/petstore/typescript-fetch/builds/multiple-parameters/src/models/ModelApiResponse.ts +++ b/samples/client/petstore/typescript-fetch/builds/multiple-parameters/src/models/ModelApiResponse.ts @@ -39,7 +39,15 @@ export interface ModelApiResponse { } export function ModelApiResponseFromJSON(json: any): ModelApiResponse { + return ModelApiResponseFromJSONTyped(json, false); +} + +export function ModelApiResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): ModelApiResponse { + if ((json === undefined) || (json === null)) { + return json; + } return { + 'code': !exists(json, 'code') ? undefined : json['code'], 'type': !exists(json, 'type') ? undefined : json['type'], 'message': !exists(json, 'message') ? undefined : json['message'], @@ -50,7 +58,11 @@ export function ModelApiResponseToJSON(value?: ModelApiResponse): any { if (value === undefined) { return undefined; } + if (value === null) { + return null; + } return { + 'code': value.code, 'type': value.type, 'message': value.message, diff --git a/samples/client/petstore/typescript-fetch/builds/multiple-parameters/src/models/Order.ts b/samples/client/petstore/typescript-fetch/builds/multiple-parameters/src/models/Order.ts index 6ce0496794f6..b9d32f387afb 100644 --- a/samples/client/petstore/typescript-fetch/builds/multiple-parameters/src/models/Order.ts +++ b/samples/client/petstore/typescript-fetch/builds/multiple-parameters/src/models/Order.ts @@ -57,7 +57,15 @@ export interface Order { } export function OrderFromJSON(json: any): Order { + return OrderFromJSONTyped(json, false); +} + +export function OrderFromJSONTyped(json: any, ignoreDiscriminator: boolean): Order { + if ((json === undefined) || (json === null)) { + return json; + } return { + 'id': !exists(json, 'id') ? undefined : json['id'], 'petId': !exists(json, 'petId') ? undefined : json['petId'], 'quantity': !exists(json, 'quantity') ? undefined : json['quantity'], @@ -71,7 +79,11 @@ export function OrderToJSON(value?: Order): any { if (value === undefined) { return undefined; } + if (value === null) { + return null; + } return { + 'id': value.id, 'petId': value.petId, 'quantity': value.quantity, diff --git a/samples/client/petstore/typescript-fetch/builds/multiple-parameters/src/models/Pet.ts b/samples/client/petstore/typescript-fetch/builds/multiple-parameters/src/models/Pet.ts index 770f991b89d9..d0cf8f55c2c4 100644 --- a/samples/client/petstore/typescript-fetch/builds/multiple-parameters/src/models/Pet.ts +++ b/samples/client/petstore/typescript-fetch/builds/multiple-parameters/src/models/Pet.ts @@ -15,9 +15,11 @@ import { exists, mapValues } from '../runtime'; import { Category, CategoryFromJSON, + CategoryFromJSONTyped, CategoryToJSON, Tag, TagFromJSON, + TagFromJSONTyped, TagToJSON, } from './'; @@ -66,7 +68,15 @@ export interface Pet { } export function PetFromJSON(json: any): Pet { + return PetFromJSONTyped(json, false); +} + +export function PetFromJSONTyped(json: any, ignoreDiscriminator: boolean): Pet { + if ((json === undefined) || (json === null)) { + return json; + } return { + 'id': !exists(json, 'id') ? undefined : json['id'], 'category': !exists(json, 'category') ? undefined : CategoryFromJSON(json['category']), 'name': json['name'], @@ -80,7 +90,11 @@ export function PetToJSON(value?: Pet): any { if (value === undefined) { return undefined; } + if (value === null) { + return null; + } return { + 'id': value.id, 'category': CategoryToJSON(value.category), 'name': value.name, diff --git a/samples/client/petstore/typescript-fetch/builds/multiple-parameters/src/models/Tag.ts b/samples/client/petstore/typescript-fetch/builds/multiple-parameters/src/models/Tag.ts index 7c8098f6dc01..a095d07d0c05 100644 --- a/samples/client/petstore/typescript-fetch/builds/multiple-parameters/src/models/Tag.ts +++ b/samples/client/petstore/typescript-fetch/builds/multiple-parameters/src/models/Tag.ts @@ -33,7 +33,15 @@ export interface Tag { } export function TagFromJSON(json: any): Tag { + return TagFromJSONTyped(json, false); +} + +export function TagFromJSONTyped(json: any, ignoreDiscriminator: boolean): Tag { + if ((json === undefined) || (json === null)) { + return json; + } return { + 'id': !exists(json, 'id') ? undefined : json['id'], 'name': !exists(json, 'name') ? undefined : json['name'], }; @@ -43,7 +51,11 @@ export function TagToJSON(value?: Tag): any { if (value === undefined) { return undefined; } + if (value === null) { + return null; + } return { + 'id': value.id, 'name': value.name, }; diff --git a/samples/client/petstore/typescript-fetch/builds/multiple-parameters/src/models/User.ts b/samples/client/petstore/typescript-fetch/builds/multiple-parameters/src/models/User.ts index fd7430063f1c..0649d0e1229c 100644 --- a/samples/client/petstore/typescript-fetch/builds/multiple-parameters/src/models/User.ts +++ b/samples/client/petstore/typescript-fetch/builds/multiple-parameters/src/models/User.ts @@ -69,7 +69,15 @@ export interface User { } export function UserFromJSON(json: any): User { + return UserFromJSONTyped(json, false); +} + +export function UserFromJSONTyped(json: any, ignoreDiscriminator: boolean): User { + if ((json === undefined) || (json === null)) { + return json; + } return { + 'id': !exists(json, 'id') ? undefined : json['id'], 'username': !exists(json, 'username') ? undefined : json['username'], 'firstName': !exists(json, 'firstName') ? undefined : json['firstName'], @@ -85,7 +93,11 @@ export function UserToJSON(value?: User): any { if (value === undefined) { return undefined; } + if (value === null) { + return null; + } return { + 'id': value.id, 'username': value.username, 'firstName': value.firstName, diff --git a/samples/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces/src/models/Category.ts b/samples/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces/src/models/Category.ts index f8809dccbea3..0541f013a256 100644 --- a/samples/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces/src/models/Category.ts +++ b/samples/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces/src/models/Category.ts @@ -33,7 +33,15 @@ export interface Category { } export function CategoryFromJSON(json: any): Category { + return CategoryFromJSONTyped(json, false); +} + +export function CategoryFromJSONTyped(json: any, ignoreDiscriminator: boolean): Category { + if ((json === undefined) || (json === null)) { + return json; + } return { + 'id': !exists(json, 'id') ? undefined : json['id'], 'name': !exists(json, 'name') ? undefined : json['name'], }; @@ -43,7 +51,11 @@ export function CategoryToJSON(value?: Category): any { if (value === undefined) { return undefined; } + if (value === null) { + return null; + } return { + 'id': value.id, 'name': value.name, }; diff --git a/samples/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces/src/models/ModelApiResponse.ts b/samples/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces/src/models/ModelApiResponse.ts index 8b8e2c45fecd..a9f1ef2fa241 100644 --- a/samples/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces/src/models/ModelApiResponse.ts +++ b/samples/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces/src/models/ModelApiResponse.ts @@ -39,7 +39,15 @@ export interface ModelApiResponse { } export function ModelApiResponseFromJSON(json: any): ModelApiResponse { + return ModelApiResponseFromJSONTyped(json, false); +} + +export function ModelApiResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): ModelApiResponse { + if ((json === undefined) || (json === null)) { + return json; + } return { + 'code': !exists(json, 'code') ? undefined : json['code'], 'type': !exists(json, 'type') ? undefined : json['type'], 'message': !exists(json, 'message') ? undefined : json['message'], @@ -50,7 +58,11 @@ export function ModelApiResponseToJSON(value?: ModelApiResponse): any { if (value === undefined) { return undefined; } + if (value === null) { + return null; + } return { + 'code': value.code, 'type': value.type, 'message': value.message, diff --git a/samples/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces/src/models/Order.ts b/samples/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces/src/models/Order.ts index 6ce0496794f6..b9d32f387afb 100644 --- a/samples/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces/src/models/Order.ts +++ b/samples/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces/src/models/Order.ts @@ -57,7 +57,15 @@ export interface Order { } export function OrderFromJSON(json: any): Order { + return OrderFromJSONTyped(json, false); +} + +export function OrderFromJSONTyped(json: any, ignoreDiscriminator: boolean): Order { + if ((json === undefined) || (json === null)) { + return json; + } return { + 'id': !exists(json, 'id') ? undefined : json['id'], 'petId': !exists(json, 'petId') ? undefined : json['petId'], 'quantity': !exists(json, 'quantity') ? undefined : json['quantity'], @@ -71,7 +79,11 @@ export function OrderToJSON(value?: Order): any { if (value === undefined) { return undefined; } + if (value === null) { + return null; + } return { + 'id': value.id, 'petId': value.petId, 'quantity': value.quantity, diff --git a/samples/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces/src/models/Pet.ts b/samples/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces/src/models/Pet.ts index 770f991b89d9..d0cf8f55c2c4 100644 --- a/samples/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces/src/models/Pet.ts +++ b/samples/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces/src/models/Pet.ts @@ -15,9 +15,11 @@ import { exists, mapValues } from '../runtime'; import { Category, CategoryFromJSON, + CategoryFromJSONTyped, CategoryToJSON, Tag, TagFromJSON, + TagFromJSONTyped, TagToJSON, } from './'; @@ -66,7 +68,15 @@ export interface Pet { } export function PetFromJSON(json: any): Pet { + return PetFromJSONTyped(json, false); +} + +export function PetFromJSONTyped(json: any, ignoreDiscriminator: boolean): Pet { + if ((json === undefined) || (json === null)) { + return json; + } return { + 'id': !exists(json, 'id') ? undefined : json['id'], 'category': !exists(json, 'category') ? undefined : CategoryFromJSON(json['category']), 'name': json['name'], @@ -80,7 +90,11 @@ export function PetToJSON(value?: Pet): any { if (value === undefined) { return undefined; } + if (value === null) { + return null; + } return { + 'id': value.id, 'category': CategoryToJSON(value.category), 'name': value.name, diff --git a/samples/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces/src/models/Tag.ts b/samples/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces/src/models/Tag.ts index 7c8098f6dc01..a095d07d0c05 100644 --- a/samples/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces/src/models/Tag.ts +++ b/samples/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces/src/models/Tag.ts @@ -33,7 +33,15 @@ export interface Tag { } export function TagFromJSON(json: any): Tag { + return TagFromJSONTyped(json, false); +} + +export function TagFromJSONTyped(json: any, ignoreDiscriminator: boolean): Tag { + if ((json === undefined) || (json === null)) { + return json; + } return { + 'id': !exists(json, 'id') ? undefined : json['id'], 'name': !exists(json, 'name') ? undefined : json['name'], }; @@ -43,7 +51,11 @@ export function TagToJSON(value?: Tag): any { if (value === undefined) { return undefined; } + if (value === null) { + return null; + } return { + 'id': value.id, 'name': value.name, }; diff --git a/samples/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces/src/models/User.ts b/samples/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces/src/models/User.ts index fd7430063f1c..0649d0e1229c 100644 --- a/samples/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces/src/models/User.ts +++ b/samples/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces/src/models/User.ts @@ -69,7 +69,15 @@ export interface User { } export function UserFromJSON(json: any): User { + return UserFromJSONTyped(json, false); +} + +export function UserFromJSONTyped(json: any, ignoreDiscriminator: boolean): User { + if ((json === undefined) || (json === null)) { + return json; + } return { + 'id': !exists(json, 'id') ? undefined : json['id'], 'username': !exists(json, 'username') ? undefined : json['username'], 'firstName': !exists(json, 'firstName') ? undefined : json['firstName'], @@ -85,7 +93,11 @@ export function UserToJSON(value?: User): any { if (value === undefined) { return undefined; } + if (value === null) { + return null; + } return { + 'id': value.id, 'username': value.username, 'firstName': value.firstName, diff --git a/samples/client/petstore/typescript-fetch/builds/with-interfaces/src/models/Category.ts b/samples/client/petstore/typescript-fetch/builds/with-interfaces/src/models/Category.ts index f8809dccbea3..0541f013a256 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-interfaces/src/models/Category.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-interfaces/src/models/Category.ts @@ -33,7 +33,15 @@ export interface Category { } export function CategoryFromJSON(json: any): Category { + return CategoryFromJSONTyped(json, false); +} + +export function CategoryFromJSONTyped(json: any, ignoreDiscriminator: boolean): Category { + if ((json === undefined) || (json === null)) { + return json; + } return { + 'id': !exists(json, 'id') ? undefined : json['id'], 'name': !exists(json, 'name') ? undefined : json['name'], }; @@ -43,7 +51,11 @@ export function CategoryToJSON(value?: Category): any { if (value === undefined) { return undefined; } + if (value === null) { + return null; + } return { + 'id': value.id, 'name': value.name, }; diff --git a/samples/client/petstore/typescript-fetch/builds/with-interfaces/src/models/ModelApiResponse.ts b/samples/client/petstore/typescript-fetch/builds/with-interfaces/src/models/ModelApiResponse.ts index 8b8e2c45fecd..a9f1ef2fa241 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-interfaces/src/models/ModelApiResponse.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-interfaces/src/models/ModelApiResponse.ts @@ -39,7 +39,15 @@ export interface ModelApiResponse { } export function ModelApiResponseFromJSON(json: any): ModelApiResponse { + return ModelApiResponseFromJSONTyped(json, false); +} + +export function ModelApiResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): ModelApiResponse { + if ((json === undefined) || (json === null)) { + return json; + } return { + 'code': !exists(json, 'code') ? undefined : json['code'], 'type': !exists(json, 'type') ? undefined : json['type'], 'message': !exists(json, 'message') ? undefined : json['message'], @@ -50,7 +58,11 @@ export function ModelApiResponseToJSON(value?: ModelApiResponse): any { if (value === undefined) { return undefined; } + if (value === null) { + return null; + } return { + 'code': value.code, 'type': value.type, 'message': value.message, diff --git a/samples/client/petstore/typescript-fetch/builds/with-interfaces/src/models/Order.ts b/samples/client/petstore/typescript-fetch/builds/with-interfaces/src/models/Order.ts index 6ce0496794f6..b9d32f387afb 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-interfaces/src/models/Order.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-interfaces/src/models/Order.ts @@ -57,7 +57,15 @@ export interface Order { } export function OrderFromJSON(json: any): Order { + return OrderFromJSONTyped(json, false); +} + +export function OrderFromJSONTyped(json: any, ignoreDiscriminator: boolean): Order { + if ((json === undefined) || (json === null)) { + return json; + } return { + 'id': !exists(json, 'id') ? undefined : json['id'], 'petId': !exists(json, 'petId') ? undefined : json['petId'], 'quantity': !exists(json, 'quantity') ? undefined : json['quantity'], @@ -71,7 +79,11 @@ export function OrderToJSON(value?: Order): any { if (value === undefined) { return undefined; } + if (value === null) { + return null; + } return { + 'id': value.id, 'petId': value.petId, 'quantity': value.quantity, diff --git a/samples/client/petstore/typescript-fetch/builds/with-interfaces/src/models/Pet.ts b/samples/client/petstore/typescript-fetch/builds/with-interfaces/src/models/Pet.ts index 770f991b89d9..d0cf8f55c2c4 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-interfaces/src/models/Pet.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-interfaces/src/models/Pet.ts @@ -15,9 +15,11 @@ import { exists, mapValues } from '../runtime'; import { Category, CategoryFromJSON, + CategoryFromJSONTyped, CategoryToJSON, Tag, TagFromJSON, + TagFromJSONTyped, TagToJSON, } from './'; @@ -66,7 +68,15 @@ export interface Pet { } export function PetFromJSON(json: any): Pet { + return PetFromJSONTyped(json, false); +} + +export function PetFromJSONTyped(json: any, ignoreDiscriminator: boolean): Pet { + if ((json === undefined) || (json === null)) { + return json; + } return { + 'id': !exists(json, 'id') ? undefined : json['id'], 'category': !exists(json, 'category') ? undefined : CategoryFromJSON(json['category']), 'name': json['name'], @@ -80,7 +90,11 @@ export function PetToJSON(value?: Pet): any { if (value === undefined) { return undefined; } + if (value === null) { + return null; + } return { + 'id': value.id, 'category': CategoryToJSON(value.category), 'name': value.name, diff --git a/samples/client/petstore/typescript-fetch/builds/with-interfaces/src/models/Tag.ts b/samples/client/petstore/typescript-fetch/builds/with-interfaces/src/models/Tag.ts index 7c8098f6dc01..a095d07d0c05 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-interfaces/src/models/Tag.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-interfaces/src/models/Tag.ts @@ -33,7 +33,15 @@ export interface Tag { } export function TagFromJSON(json: any): Tag { + return TagFromJSONTyped(json, false); +} + +export function TagFromJSONTyped(json: any, ignoreDiscriminator: boolean): Tag { + if ((json === undefined) || (json === null)) { + return json; + } return { + 'id': !exists(json, 'id') ? undefined : json['id'], 'name': !exists(json, 'name') ? undefined : json['name'], }; @@ -43,7 +51,11 @@ export function TagToJSON(value?: Tag): any { if (value === undefined) { return undefined; } + if (value === null) { + return null; + } return { + 'id': value.id, 'name': value.name, }; diff --git a/samples/client/petstore/typescript-fetch/builds/with-interfaces/src/models/User.ts b/samples/client/petstore/typescript-fetch/builds/with-interfaces/src/models/User.ts index fd7430063f1c..0649d0e1229c 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-interfaces/src/models/User.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-interfaces/src/models/User.ts @@ -69,7 +69,15 @@ export interface User { } export function UserFromJSON(json: any): User { + return UserFromJSONTyped(json, false); +} + +export function UserFromJSONTyped(json: any, ignoreDiscriminator: boolean): User { + if ((json === undefined) || (json === null)) { + return json; + } return { + 'id': !exists(json, 'id') ? undefined : json['id'], 'username': !exists(json, 'username') ? undefined : json['username'], 'firstName': !exists(json, 'firstName') ? undefined : json['firstName'], @@ -85,7 +93,11 @@ export function UserToJSON(value?: User): any { if (value === undefined) { return undefined; } + if (value === null) { + return null; + } return { + 'id': value.id, 'username': value.username, 'firstName': value.firstName, diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/src/models/Category.ts b/samples/client/petstore/typescript-fetch/builds/with-npm-version/src/models/Category.ts index f8809dccbea3..0541f013a256 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-npm-version/src/models/Category.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/src/models/Category.ts @@ -33,7 +33,15 @@ export interface Category { } export function CategoryFromJSON(json: any): Category { + return CategoryFromJSONTyped(json, false); +} + +export function CategoryFromJSONTyped(json: any, ignoreDiscriminator: boolean): Category { + if ((json === undefined) || (json === null)) { + return json; + } return { + 'id': !exists(json, 'id') ? undefined : json['id'], 'name': !exists(json, 'name') ? undefined : json['name'], }; @@ -43,7 +51,11 @@ export function CategoryToJSON(value?: Category): any { if (value === undefined) { return undefined; } + if (value === null) { + return null; + } return { + 'id': value.id, 'name': value.name, }; diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/src/models/ModelApiResponse.ts b/samples/client/petstore/typescript-fetch/builds/with-npm-version/src/models/ModelApiResponse.ts index 8b8e2c45fecd..a9f1ef2fa241 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-npm-version/src/models/ModelApiResponse.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/src/models/ModelApiResponse.ts @@ -39,7 +39,15 @@ export interface ModelApiResponse { } export function ModelApiResponseFromJSON(json: any): ModelApiResponse { + return ModelApiResponseFromJSONTyped(json, false); +} + +export function ModelApiResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): ModelApiResponse { + if ((json === undefined) || (json === null)) { + return json; + } return { + 'code': !exists(json, 'code') ? undefined : json['code'], 'type': !exists(json, 'type') ? undefined : json['type'], 'message': !exists(json, 'message') ? undefined : json['message'], @@ -50,7 +58,11 @@ export function ModelApiResponseToJSON(value?: ModelApiResponse): any { if (value === undefined) { return undefined; } + if (value === null) { + return null; + } return { + 'code': value.code, 'type': value.type, 'message': value.message, diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/src/models/Order.ts b/samples/client/petstore/typescript-fetch/builds/with-npm-version/src/models/Order.ts index 6ce0496794f6..b9d32f387afb 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-npm-version/src/models/Order.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/src/models/Order.ts @@ -57,7 +57,15 @@ export interface Order { } export function OrderFromJSON(json: any): Order { + return OrderFromJSONTyped(json, false); +} + +export function OrderFromJSONTyped(json: any, ignoreDiscriminator: boolean): Order { + if ((json === undefined) || (json === null)) { + return json; + } return { + 'id': !exists(json, 'id') ? undefined : json['id'], 'petId': !exists(json, 'petId') ? undefined : json['petId'], 'quantity': !exists(json, 'quantity') ? undefined : json['quantity'], @@ -71,7 +79,11 @@ export function OrderToJSON(value?: Order): any { if (value === undefined) { return undefined; } + if (value === null) { + return null; + } return { + 'id': value.id, 'petId': value.petId, 'quantity': value.quantity, diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/src/models/Pet.ts b/samples/client/petstore/typescript-fetch/builds/with-npm-version/src/models/Pet.ts index 770f991b89d9..d0cf8f55c2c4 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-npm-version/src/models/Pet.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/src/models/Pet.ts @@ -15,9 +15,11 @@ import { exists, mapValues } from '../runtime'; import { Category, CategoryFromJSON, + CategoryFromJSONTyped, CategoryToJSON, Tag, TagFromJSON, + TagFromJSONTyped, TagToJSON, } from './'; @@ -66,7 +68,15 @@ export interface Pet { } export function PetFromJSON(json: any): Pet { + return PetFromJSONTyped(json, false); +} + +export function PetFromJSONTyped(json: any, ignoreDiscriminator: boolean): Pet { + if ((json === undefined) || (json === null)) { + return json; + } return { + 'id': !exists(json, 'id') ? undefined : json['id'], 'category': !exists(json, 'category') ? undefined : CategoryFromJSON(json['category']), 'name': json['name'], @@ -80,7 +90,11 @@ export function PetToJSON(value?: Pet): any { if (value === undefined) { return undefined; } + if (value === null) { + return null; + } return { + 'id': value.id, 'category': CategoryToJSON(value.category), 'name': value.name, diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/src/models/Tag.ts b/samples/client/petstore/typescript-fetch/builds/with-npm-version/src/models/Tag.ts index 7c8098f6dc01..a095d07d0c05 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-npm-version/src/models/Tag.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/src/models/Tag.ts @@ -33,7 +33,15 @@ export interface Tag { } export function TagFromJSON(json: any): Tag { + return TagFromJSONTyped(json, false); +} + +export function TagFromJSONTyped(json: any, ignoreDiscriminator: boolean): Tag { + if ((json === undefined) || (json === null)) { + return json; + } return { + 'id': !exists(json, 'id') ? undefined : json['id'], 'name': !exists(json, 'name') ? undefined : json['name'], }; @@ -43,7 +51,11 @@ export function TagToJSON(value?: Tag): any { if (value === undefined) { return undefined; } + if (value === null) { + return null; + } return { + 'id': value.id, 'name': value.name, }; diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/src/models/User.ts b/samples/client/petstore/typescript-fetch/builds/with-npm-version/src/models/User.ts index fd7430063f1c..0649d0e1229c 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-npm-version/src/models/User.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/src/models/User.ts @@ -69,7 +69,15 @@ export interface User { } export function UserFromJSON(json: any): User { + return UserFromJSONTyped(json, false); +} + +export function UserFromJSONTyped(json: any, ignoreDiscriminator: boolean): User { + if ((json === undefined) || (json === null)) { + return json; + } return { + 'id': !exists(json, 'id') ? undefined : json['id'], 'username': !exists(json, 'username') ? undefined : json['username'], 'firstName': !exists(json, 'firstName') ? undefined : json['firstName'], @@ -85,7 +93,11 @@ export function UserToJSON(value?: User): any { if (value === undefined) { return undefined; } + if (value === null) { + return null; + } return { + 'id': value.id, 'username': value.username, 'firstName': value.firstName,