diff --git a/modules/openapi-generator/src/main/resources/typescript-fetch/apis.mustache b/modules/openapi-generator/src/main/resources/typescript-fetch/apis.mustache index 8daa73e2783a..f2cfe345f1f6 100644 --- a/modules/openapi-generator/src/main/resources/typescript-fetch/apis.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-fetch/apis.mustache @@ -24,7 +24,7 @@ import { {{#allParams.0}} export interface {{#prefixParameterInterfaces}}{{classname}}{{/prefixParameterInterfaces}}{{operationIdCamelCase}}Request { {{#allParams}} - {{paramName}}{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{#isNullable}} | null{{/isNullable}}{{/isEnum}}; + {{paramName}}{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{#isNullable}}{{#required}} | null{{/required}}{{/isNullable}}{{/isEnum}}; {{/allParams}} } @@ -70,7 +70,7 @@ export interface {{classname}}Interface { {{/isDeprecated}} */ {{^useSingleRequestParameter}} - {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{#isNullable}} | null{{/isNullable}}{{/isEnum}}, {{/allParams}}initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<{{{returnType}}}{{^returnType}}void{{/returnType}}>; + {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{#isNullable}}{{#required}} | null{{/required}}{{/isNullable}}{{/isEnum}}, {{/allParams}}initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<{{{returnType}}}{{^returnType}}void{{/returnType}}>; {{/useSingleRequestParameter}} {{#useSingleRequestParameter}} {{nickname}}({{#allParams.0}}requestParameters: {{#prefixParameterInterfaces}}{{classname}}{{/prefixParameterInterfaces}}{{operationIdCamelCase}}Request, {{/allParams.0}}initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<{{{returnType}}}{{^returnType}}void{{/returnType}}>; @@ -107,8 +107,11 @@ export class {{classname}} extends runtime.BaseAPI { async {{nickname}}Raw({{#allParams.0}}requestParameters: {{#prefixParameterInterfaces}}{{classname}}{{/prefixParameterInterfaces}}{{operationIdCamelCase}}Request, {{/allParams.0}}initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { {{#allParams}} {{#required}} - if (requestParameters.{{paramName}} === null || requestParameters.{{paramName}} === undefined) { - throw new runtime.RequiredError('{{paramName}}','Required parameter requestParameters.{{paramName}} was null or undefined when calling {{nickname}}.'); + if (!runtime.exists(requestParameters, '{{paramName}}')) { + throw new runtime.RequiredError( + '{{paramName}}', + 'Required parameter "{{paramName}}" was null or undefined when calling {{nickname}}().' + ); } {{/required}} @@ -117,27 +120,27 @@ export class {{classname}} extends runtime.BaseAPI { {{#queryParams}} {{#isArray}} - if (requestParameters.{{paramName}}) { + if (runtime.exists(requestParameters, '{{paramName}}')) { {{#isCollectionFormatMulti}} - queryParameters['{{baseName}}'] = requestParameters.{{paramName}}; + queryParameters['{{baseName}}'] = requestParameters['{{paramName}}']; {{/isCollectionFormatMulti}} {{^isCollectionFormatMulti}} - queryParameters['{{baseName}}'] = {{#uniqueItems}}Array.from({{/uniqueItems}}requestParameters.{{paramName}}{{#uniqueItems}}){{/uniqueItems}}.join(runtime.COLLECTION_FORMATS["{{collectionFormat}}"]); + queryParameters['{{baseName}}'] = {{#uniqueItems}}Array.from({{/uniqueItems}}requestParameters['{{paramName}}']{{#uniqueItems}}){{/uniqueItems}}!.join(runtime.COLLECTION_FORMATS["{{collectionFormat}}"]); {{/isCollectionFormatMulti}} } {{/isArray}} {{^isArray}} - if (requestParameters.{{paramName}} !== undefined) { + if (runtime.exists(requestParameters, '{{paramName}}')) { {{#isDateTimeType}} - queryParameters['{{baseName}}'] = (requestParameters.{{paramName}} as any).toISOString(); + queryParameters['{{baseName}}'] = (requestParameters['{{paramName}}'] as any).toISOString(); {{/isDateTimeType}} {{^isDateTimeType}} {{#isDateType}} - queryParameters['{{baseName}}'] = (requestParameters.{{paramName}} as any).toISOString().substring(0,10); + queryParameters['{{baseName}}'] = (requestParameters['{{paramName}}'] as any).toISOString().substring(0,10); {{/isDateType}} {{^isDateType}} - queryParameters['{{baseName}}'] = requestParameters.{{paramName}}; + queryParameters['{{baseName}}'] = requestParameters['{{paramName}}']; {{/isDateType}} {{/isDateTimeType}} } @@ -158,14 +161,14 @@ export class {{classname}} extends runtime.BaseAPI { {{/bodyParam}} {{#headerParams}} {{#isArray}} - if (requestParameters.{{paramName}}) { - headerParameters['{{baseName}}'] = {{#uniqueItems}}Array.from({{/uniqueItems}}requestParameters.{{paramName}}{{#uniqueItems}}){{/uniqueItems}}.join(runtime.COLLECTION_FORMATS["{{collectionFormat}}"]); + if (runtime.exists(requestParameters, '{{paramName}}')) { + headerParameters['{{baseName}}'] = {{#uniqueItems}}Array.from({{/uniqueItems}}requestParameters['{{paramName}}']{{#uniqueItems}}){{/uniqueItems}}!.join(runtime.COLLECTION_FORMATS["{{collectionFormat}}"]); } {{/isArray}} {{^isArray}} - if (requestParameters.{{paramName}} !== undefined && requestParameters.{{paramName}} !== null) { - headerParameters['{{baseName}}'] = String(requestParameters.{{paramName}}); + if (runtime.exists(requestParameters, '{{paramName}}')) { + headerParameters['{{baseName}}'] = String(requestParameters['{{paramName}}']); } {{/isArray}} @@ -235,28 +238,28 @@ export class {{classname}} extends runtime.BaseAPI { {{#formParams}} {{#isArray}} - if (requestParameters.{{paramName}}) { + if (runtime.exists(requestParameters, '{{paramName}}')) { {{#isCollectionFormatMulti}} - requestParameters.{{paramName}}.forEach((element) => { + requestParameters['{{paramName}}'].forEach((element) => { formParams.append('{{baseName}}', element as any); }) {{/isCollectionFormatMulti}} {{^isCollectionFormatMulti}} - formParams.append('{{baseName}}', {{#uniqueItems}}Array.from({{/uniqueItems}}requestParameters.{{paramName}}{{#uniqueItems}}){{/uniqueItems}}.join(runtime.COLLECTION_FORMATS["{{collectionFormat}}"])); + formParams.append('{{baseName}}', {{#uniqueItems}}Array.from({{/uniqueItems}}requestParameters['{{paramName}}']{{#uniqueItems}}){{/uniqueItems}}!.join(runtime.COLLECTION_FORMATS["{{collectionFormat}}"])); {{/isCollectionFormatMulti}} } {{/isArray}} {{^isArray}} - if (requestParameters.{{paramName}} !== undefined) { + if (runtime.exists(requestParameters, '{{paramName}}')) { {{#isPrimitiveType}} - formParams.append('{{baseName}}', requestParameters.{{paramName}} as any); + formParams.append('{{baseName}}', requestParameters['{{paramName}}'] as any); {{/isPrimitiveType}} {{^isPrimitiveType}} {{^withoutRuntimeChecks}} - formParams.append('{{baseName}}', new Blob([JSON.stringify({{{dataType}}}ToJSON(requestParameters.{{paramName}}))], { type: "application/json", })); + formParams.append('{{baseName}}', new Blob([JSON.stringify({{{dataType}}}ToJSON(requestParameters['{{paramName}}']))], { type: "application/json", })); {{/withoutRuntimeChecks}}{{#withoutRuntimeChecks}} - formParams.append('{{baseName}}', new Blob([JSON.stringify(requestParameters.{{paramName}})], { type: "application/json", })); + formParams.append('{{baseName}}', new Blob([JSON.stringify(requestParameters['{{paramName}}'])], { type: "application/json", })); {{/withoutRuntimeChecks}} {{/isPrimitiveType}} } @@ -265,7 +268,7 @@ export class {{classname}} extends runtime.BaseAPI { {{/formParams}} {{/hasFormParams}} const response = await this.request({ - path: `{{{path}}}`{{#pathParams}}.replace(`{${"{{baseName}}"}}`, encodeURIComponent(String(requestParameters.{{paramName}}))){{/pathParams}}, + path: `{{{path}}}`{{#pathParams}}.replace(`{${"{{baseName}}"}}`, encodeURIComponent(String(requestParameters['{{paramName}}']))){{/pathParams}}, method: '{{httpMethod}}', headers: headerParameters, query: queryParameters, @@ -273,23 +276,23 @@ export class {{classname}} extends runtime.BaseAPI { {{#bodyParam}} {{#isContainer}} {{^withoutRuntimeChecks}} - body: requestParameters.{{paramName}}{{#isArray}}{{#items}}{{^isPrimitiveType}}.map({{datatype}}ToJSON){{/isPrimitiveType}}{{/items}}{{/isArray}}, + body: requestParameters['{{paramName}}']{{#isArray}}{{#items}}{{^isPrimitiveType}}!.map({{datatype}}ToJSON){{/isPrimitiveType}}{{/items}}{{/isArray}}, {{/withoutRuntimeChecks}} {{#withoutRuntimeChecks}} - body: requestParameters.{{paramName}}, + body: requestParameters['{{paramName}}'], {{/withoutRuntimeChecks}} {{/isContainer}} {{^isContainer}} {{^isPrimitiveType}} {{^withoutRuntimeChecks}} - body: {{dataType}}ToJSON(requestParameters.{{paramName}}), + body: {{dataType}}ToJSON(requestParameters['{{paramName}}']), {{/withoutRuntimeChecks}} {{#withoutRuntimeChecks}} - body: requestParameters.{{paramName}}, + body: requestParameters['{{paramName}}'], {{/withoutRuntimeChecks}} {{/isPrimitiveType}} {{#isPrimitiveType}} - body: requestParameters.{{paramName}} as any, + body: requestParameters['{{paramName}}'] as any, {{/isPrimitiveType}} {{/isContainer}} {{/bodyParam}} @@ -351,7 +354,7 @@ export class {{classname}} extends runtime.BaseAPI { {{/isDeprecated}} */ {{^useSingleRequestParameter}} - async {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{#isNullable}} | null{{/isNullable}}{{/isEnum}}, {{/allParams}}initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<{{{returnType}}}{{#returnType}}{{#isResponseOptional}} | null | undefined {{/isResponseOptional}}{{/returnType}}{{^returnType}}void{{/returnType}}> { + async {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{#isNullable}}{{#required}} | null{{/required}}{{/isNullable}}{{/isEnum}}, {{/allParams}}initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<{{{returnType}}}{{#returnType}}{{#isResponseOptional}} | null | undefined {{/isResponseOptional}}{{/returnType}}{{^returnType}}void{{/returnType}}> { {{#returnType}} const response = await this.{{nickname}}Raw({{#allParams.0}}{ {{#allParams}}{{paramName}}: {{paramName}}{{^-last}}, {{/-last}}{{/allParams}} }, {{/allParams.0}}initOverrides); {{#isResponseOptional}} 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 6aca92401c78..df0df852beb9 100644 --- a/modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache @@ -24,14 +24,12 @@ import { * Check if a given object implements the {{classname}} interface. */ export function instanceOf{{classname}}(value: object): boolean { - let isInstance = true; {{#vars}} {{#required}} - isInstance = isInstance && "{{name}}" in value; + if (!('{{name}}' in value)) return false; {{/required}} {{/vars}} - - return isInstance; + return true; } export function {{classname}}FromJSON(json: any): {{classname}} { @@ -40,7 +38,7 @@ export function {{classname}}FromJSON(json: any): {{classname}} { export function {{classname}}FromJSONTyped(json: any, ignoreDiscriminator: boolean): {{classname}} { {{#hasVars}} - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } {{#discriminator}} @@ -60,10 +58,10 @@ export function {{classname}}FromJSONTyped(json: any, ignoreDiscriminator: boole {{#vars}} {{#isPrimitiveType}} {{#isDateType}} - '{{name}}': {{^required}}!exists(json, '{{baseName}}') ? undefined : {{/required}}({{#isNullable}}json['{{baseName}}'] === null ? null : {{/isNullable}}new Date(json['{{baseName}}'])), + '{{name}}': {{^required}}!exists(json, '{{baseName}}') ? undefined : {{/required}}({{#required}}{{#isNullable}}!exists(json, '{{baseName}}') ? null : {{/isNullable}}{{/required}}new Date(json['{{baseName}}'])), {{/isDateType}} {{#isDateTimeType}} - '{{name}}': {{^required}}!exists(json, '{{baseName}}') ? undefined : {{/required}}({{#isNullable}}json['{{baseName}}'] === null ? null : {{/isNullable}}new Date(json['{{baseName}}'])), + '{{name}}': {{^required}}!exists(json, '{{baseName}}') ? undefined : {{/required}}({{#required}}{{#isNullable}}!exists(json, '{{baseName}}') ? null : {{/isNullable}}{{/required}}new Date(json['{{baseName}}'])), {{/isDateTimeType}} {{^isDateType}} {{^isDateTimeType}} @@ -74,14 +72,14 @@ export function {{classname}}FromJSONTyped(json: any, ignoreDiscriminator: boole {{^isPrimitiveType}} {{#isArray}} {{#uniqueItems}} - '{{name}}': {{^required}}!exists(json, '{{baseName}}') ? undefined : {{/required}}({{#isNullable}}json['{{baseName}}'] === null ? null : {{/isNullable}}new Set((json['{{baseName}}'] as Array).map({{#items}}{{datatype}}{{/items}}FromJSON))), + '{{name}}': {{^required}}!exists(json, '{{baseName}}') ? undefined : {{/required}}{{#required}}({{#isNullable}}!exists(json, '{{baseName}}') ? null : {{/isNullable}}{{/required}}new Set((json['{{baseName}}'] as Array).map({{#items}}{{datatype}}{{/items}}FromJSON))), {{/uniqueItems}} {{^uniqueItems}} - '{{name}}': {{^required}}!exists(json, '{{baseName}}') ? undefined : {{/required}}({{#isNullable}}json['{{baseName}}'] === null ? null : {{/isNullable}}(json['{{baseName}}'] as Array).map({{#items}}{{datatype}}{{/items}}FromJSON)), + '{{name}}': {{^required}}!exists(json, '{{baseName}}') ? undefined : {{/required}}({{#required}}{{#isNullable}}!exists(json, '{{baseName}}') ? null : {{/isNullable}}{{/required}}(json['{{baseName}}'] as Array).map({{#items}}{{datatype}}{{/items}}FromJSON)), {{/uniqueItems}} {{/isArray}} {{#isMap}} - '{{name}}': {{^required}}!exists(json, '{{baseName}}') ? undefined : {{/required}}({{#isNullable}}json['{{baseName}}'] === null ? null : {{/isNullable}}mapValues(json['{{baseName}}'], {{#items}}{{datatype}}{{/items}}FromJSON)), + '{{name}}': {{^required}}!exists(json, '{{baseName}}') ? undefined : {{/required}}({{#required}}{{#isNullable}}!exists(json, '{{baseName}}') ? null : {{/isNullable}}{{/required}}mapValues(json['{{baseName}}'], {{#items}}{{datatype}}{{/items}}FromJSON)), {{/isMap}} {{^isArray}} {{^isMap}} @@ -119,18 +117,18 @@ export function {{classname}}ToJSON(value?: {{classname}} | null): any { {{^isReadOnly}} {{#isPrimitiveType}} {{#isDateType}} - '{{baseName}}': {{^required}}value.{{name}} === undefined ? undefined : {{/required}}({{#isNullable}}value.{{name}} === null ? null : {{/isNullable}}value.{{name}}.toISOString().substring(0,10)), + '{{baseName}}': {{^required}}!exists(value, '{{name}}') ? undefined : {{/required}}({{#required}}{{#isNullable}}!exists(value, '{{name}}') ? null : {{/isNullable}}{{/required}}(value['{{name}}']{{#isNullable}} as any{{/isNullable}}).toISOString().substring(0,10)), {{/isDateType}} {{#isDateTimeType}} - '{{baseName}}': {{^required}}value.{{name}} === undefined ? undefined : {{/required}}({{#isNullable}}value.{{name}} === null ? null : {{/isNullable}}value.{{name}}.toISOString()), + '{{baseName}}': {{^required}}!exists(value, '{{name}}') ? undefined : {{/required}}({{#required}}{{#isNullable}}!exists(value, '{{name}}') ? null : {{/isNullable}}{{/required}}(value['{{name}}']{{#isNullable}} as any{{/isNullable}}).toISOString()), {{/isDateTimeType}} {{#isArray}} - '{{baseName}}': {{#uniqueItems}}{{^required}}value.{{name}} === undefined ? undefined : {{/required}}{{#isNullable}}value.{{name}} === null ? null : {{/isNullable}}Array.from(value.{{name}} as Set){{/uniqueItems}}{{^uniqueItems}}value.{{name}}{{/uniqueItems}}, + '{{baseName}}': {{#uniqueItems}}{{^required}}!exists(value, '{{name}}') ? undefined : {{/required}}{{#required}}{{#isNullable}}!exists(value, '{{name}}') ? null : {{/isNullable}}{{/required}}Array.from(value['{{name}}'] as Set){{/uniqueItems}}{{^uniqueItems}}value['{{name}}']{{/uniqueItems}}, {{/isArray}} {{^isDateType}} {{^isDateTimeType}} {{^isArray}} - '{{baseName}}': value.{{name}}, + '{{baseName}}': value['{{name}}'], {{/isArray}} {{/isDateTimeType}} {{/isDateType}} @@ -138,22 +136,22 @@ export function {{classname}}ToJSON(value?: {{classname}} | null): any { {{^isPrimitiveType}} {{#isArray}} {{#uniqueItems}} - '{{baseName}}': {{^required}}value.{{name}} === undefined ? undefined : {{/required}}({{#isNullable}}value.{{name}} === null ? null : {{/isNullable}}Array.from(value.{{name}} as Set).map({{#items}}{{datatype}}{{/items}}ToJSON)), + '{{baseName}}': {{^required}}!exists(value, '{{name}}') ? undefined : {{/required}}({{#required}}{{#isNullable}}!exists(value, '{{name}}') ? null : {{/isNullable}}{{/required}}Array.from(value['{{name}}'] as Set).map({{#items}}{{datatype}}{{/items}}ToJSON)), {{/uniqueItems}} {{^uniqueItems}} - '{{baseName}}': {{^required}}value.{{name}} === undefined ? undefined : {{/required}}({{#isNullable}}value.{{name}} === null ? null : {{/isNullable}}(value.{{name}} as Array).map({{#items}}{{datatype}}{{/items}}ToJSON)), + '{{baseName}}': {{^required}}!exists(value, '{{name}}') ? undefined : {{/required}}({{#required}}{{#isNullable}}!exists(value, '{{name}}') ? null : {{/isNullable}}{{/required}}(value['{{name}}'] as Array).map({{#items}}{{datatype}}{{/items}}ToJSON)), {{/uniqueItems}} {{/isArray}} {{#isMap}} - '{{baseName}}': {{^required}}value.{{name}} === undefined ? undefined : {{/required}}({{#isNullable}}value.{{name}} === null ? null : {{/isNullable}}mapValues(value.{{name}}, {{#items}}{{datatype}}{{/items}}ToJSON)), + '{{baseName}}': {{^required}}!exists(value, '{{name}}') ? undefined : {{/required}}({{#required}}{{#isNullable}}!exists(value, '{{name}}') ? null : {{/isNullable}}{{/required}}mapValues(value['{{name}}'], {{#items}}{{datatype}}{{/items}}ToJSON)), {{/isMap}} {{^isArray}} {{^isMap}} {{^isFreeFormObject}} - '{{baseName}}': {{datatype}}ToJSON(value.{{name}}), + '{{baseName}}': {{datatype}}ToJSON(value['{{name}}']), {{/isFreeFormObject}} {{#isFreeFormObject}} - '{{baseName}}': value.{{name}}, + '{{baseName}}': value['{{name}}'], {{/isFreeFormObject}} {{/isMap}} {{/isArray}} diff --git a/modules/openapi-generator/src/main/resources/typescript-fetch/modelGenericInterfaces.mustache b/modules/openapi-generator/src/main/resources/typescript-fetch/modelGenericInterfaces.mustache index 68e5747598a9..4b8bfa06a1bc 100644 --- a/modules/openapi-generator/src/main/resources/typescript-fetch/modelGenericInterfaces.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-fetch/modelGenericInterfaces.mustache @@ -16,7 +16,7 @@ export interface {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{ * @deprecated {{/deprecated}} */ - {{#isReadOnly}}readonly {{/isReadOnly}}{{name}}{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{#isNullable}} | null{{/isNullable}}{{/isEnum}}{{^isEnum}}{{{datatype}}}{{#isNullable}} | null{{/isNullable}}{{/isEnum}}; + {{#isReadOnly}}readonly {{/isReadOnly}}{{name}}{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{#isNullable}}{{#required}} | null{{/required}}{{/isNullable}}{{/isEnum}}{{^isEnum}}{{{datatype}}}{{#isNullable}}{{#required}} | null{{/required}}{{/isNullable}}{{/isEnum}}; {{/vars}} }{{#hasEnums}} diff --git a/modules/openapi-generator/src/main/resources/typescript-fetch/modelOneOf.mustache b/modules/openapi-generator/src/main/resources/typescript-fetch/modelOneOf.mustache index e369f5b9d12c..9e6b5d497956 100644 --- a/modules/openapi-generator/src/main/resources/typescript-fetch/modelOneOf.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-fetch/modelOneOf.mustache @@ -17,7 +17,7 @@ export function {{classname}}FromJSON(json: any): {{classname}} { } export function {{classname}}FromJSONTyped(json: any, ignoreDiscriminator: boolean): {{classname}} { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } {{#discriminator}} diff --git a/modules/openapi-generator/src/main/resources/typescript-fetch/recordGeneric.mustache b/modules/openapi-generator/src/main/resources/typescript-fetch/recordGeneric.mustache index 8909906d6745..819a29e44ee8 100644 --- a/modules/openapi-generator/src/main/resources/typescript-fetch/recordGeneric.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-fetch/recordGeneric.mustache @@ -98,23 +98,23 @@ class {{classname}}RecordUtils extends ApiRecordUtils<{{classname}}, {{classname {{#isUniqueId}} {{#isArray}} {{#items.isArray}} - {{^required}}if (apiObject.{{name}}) { {{/required}}(apiObject as any).{{name}} = apiObject.{{name}}.map(item => item.map(item2 => item2?.toString()));{{^required}} } {{/required}} + {{^required}}if (apiObject['{{name}}']) { {{/required}}(apiObject as any)['{{name}}'] = apiObject['{{name}}'].map(item => item.map(item2 => item2?.toString()));{{^required}} } {{/required}} {{/items.isArray}} {{^items.isArray}} - {{^required}}if (apiObject.{{name}}) { {{/required}}(apiObject as any).{{name}} = apiObject.{{name}}.map(item => item?.toString());{{^required}} } {{/required}} + {{^required}}if (apiObject['{{name}}']) { {{/required}}(apiObject as any)['{{name}}'] = apiObject['{{name}}'].map(item => item?.toString());{{^required}} } {{/required}} {{/items.isArray}} {{/isArray}} {{^isArray}} - {{^required}}if (apiObject.{{name}}) { {{/required}}(apiObject as any).{{name}} = apiObject.{{name}}.toString();{{^required}} } {{/required}} + {{^required}}if (apiObject['{{name}}']) { {{/required}}(apiObject as any)['{{name}}'] = apiObject['{{name}}'].toString();{{^required}} } {{/required}} {{/isArray}} {{/isUniqueId}} {{^keepAsJSObject}} {{#isModel}} - {{^required}}if (apiObject.{{name}}) { {{/required}}{{#lambda.camelcase}}{{{dataTypeAlternate}}}{{/lambda.camelcase}}Utils.normalize(apiObject.{{name}});{{^required}} } {{/required}} + {{^required}}if (apiObject['{{name}}']) { {{/required}}{{#lambda.camelcase}}{{{dataTypeAlternate}}}{{/lambda.camelcase}}Utils.normalize(apiObject['{{name}}']);{{^required}} } {{/required}} {{/isModel}} {{#isArray}} {{#items.isModel}} - {{^required}}if (apiObject.{{name}}) { {{/required}}{{#lambda.camelcase}}{{items.dataType}}{{/lambda.camelcase}}RecordUtils.normalizeArray(apiObject.{{name}});{{^required}} } {{/required}} + {{^required}}if (apiObject['{{name}}']) { {{/required}}{{#lambda.camelcase}}{{items.dataType}}{{/lambda.camelcase}}RecordUtils.normalizeArray(apiObject['{{name}}']);{{^required}} } {{/required}} {{/items.isModel}} {{/isArray}} {{/keepAsJSObject}} @@ -172,14 +172,14 @@ class {{classname}}RecordUtils extends ApiRecordUtils<{{classname}}, {{classname {{#isEntity}} {{^keepAsJSObject}} // @ts-ignore - {{name}}: {{^required}}entity.{{name}} ? {{/required}}yield call({{#lambda.camelcase}}{{{dataTypeAlternate}}}{{/lambda.camelcase}}Utils.toInlined, entity.{{name}}){{^required}} : null{{/required}}, + {{name}}: {{^required}}entity['{{name}}'] ? {{/required}}yield call({{#lambda.camelcase}}{{{dataTypeAlternate}}}{{/lambda.camelcase}}Utils.toInlined, entity['{{name}}']){{^required}} : null{{/required}}, {{/keepAsJSObject}} {{/isEntity}} {{#isArray}} {{#items.isEntity}} {{^keepAsJSObject}} // @ts-ignore - {{name}}: {{^required}}entity.{{name}} ? {{/required}}yield call({{#lambda.camelcase}}{{items.dataType}}{{/lambda.camelcase}}RecordUtils.toInlinedArray, entity.{{name}}){{^required}} : null{{/required}}, + {{name}}: {{^required}}entity['{{name}}'] ? {{/required}}yield call({{#lambda.camelcase}}{{items.dataType}}{{/lambda.camelcase}}RecordUtils.toInlinedArray, entity['{{name}}']){{^required}} : null{{/required}}, {{/keepAsJSObject}} {{/items.isEntity}} {{/isArray}} @@ -212,23 +212,23 @@ class {{classname}}RecordUtils extends ApiRecordUtils<{{classname}}, {{classname {{#isUniqueId}} {{#isArray}} {{#items.isArray}} - {{^required}}if (record.{{name}}) { {{/required}}apiObject.{{name}} = {{#isArray}}record.{{name}}.map(item => item.toArray().map(item2 => (item2 ? parseFloat(item2) : null) as number)).toArray(){{/isArray}};{{^required}} } {{/required}} + {{^required}}if (record['{{name}}']) { {{/required}}apiObject['{{name}}'] = {{#isArray}}record['{{name}}'].map(item => item.toArray().map(item2 => (item2 ? parseFloat(item2) : null) as number)).toArray(){{/isArray}};{{^required}} } {{/required}} {{/items.isArray}} {{^items.isArray}} - {{^required}}if (record.{{name}}) { {{/required}}apiObject.{{name}} = {{#isArray}}record.{{name}}.map(item => (item ? parseFloat(item) : null) as number).toArray(){{/isArray}};{{^required}} } {{/required}} + {{^required}}if (record['{{name}}']) { {{/required}}apiObject['{{name}}'] = {{#isArray}}record['{{name}}'].map(item => (item ? parseFloat(item) : null) as number).toArray(){{/isArray}};{{^required}} } {{/required}} {{/items.isArray}} {{/isArray}} {{^isArray}} - {{^required}}if (record.{{name}}) { {{/required}}apiObject.{{name}} = {{^isArray}}parseFloat(record.{{name}}){{/isArray}};{{^required}} } {{/required}} + {{^required}}if (record['{{name}}']) { {{/required}}apiObject['{{name}}'] = {{^isArray}}parseFloat(record['{{name}}']){{/isArray}};{{^required}} } {{/required}} {{/isArray}} {{/isUniqueId}} {{^keepAsJSObject}} {{#isModel}} - {{^required}}if (record.{{name}}) { {{/required}}apiObject.{{name}} = {{#lambda.camelcase}}{{{dataTypeAlternate}}}{{/lambda.camelcase}}Utils.toApi(record.{{name}});{{^required}} } {{/required}} + {{^required}}if (record['{{name}}']) { {{/required}}apiObject['{{name}}'] = {{#lambda.camelcase}}{{{dataTypeAlternate}}}{{/lambda.camelcase}}Utils.toApi(record['{{name}}']);{{^required}} } {{/required}} {{/isModel}} {{#isArray}} {{#items.isModel}} - {{^required}}if (record.{{name}}) { {{/required}}apiObject.{{name}} = {{#lambda.camelcase}}{{items.dataType}}{{/lambda.camelcase}}RecordUtils.toApiArray(record.{{name}});{{^required}} } {{/required}} + {{^required}}if (record['{{name}}']) { {{/required}}apiObject['{{name}}'] = {{#lambda.camelcase}}{{items.dataType}}{{/lambda.camelcase}}RecordUtils.toApiArray(record['{{name}}']);{{^required}} } {{/required}} {{/items.isModel}} {{/isArray}} {{/keepAsJSObject}} diff --git a/modules/openapi-generator/src/main/resources/typescript-fetch/runtime.mustache b/modules/openapi-generator/src/main/resources/typescript-fetch/runtime.mustache index 519050237520..0db3b0ac14eb 100644 --- a/modules/openapi-generator/src/main/resources/typescript-fetch/runtime.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-fetch/runtime.mustache @@ -300,9 +300,9 @@ export interface RequestOpts { } {{^withoutRuntimeChecks}} -export function exists(json: any, key: string) { +export function exists(json: any, key: string): boolean { const value = json[key]; - return value !== null && value !== undefined; + return value !== undefined && value !== null; } {{/withoutRuntimeChecks}} diff --git a/modules/openapi-generator/src/main/resources/typescript-fetch/sagas.mustache b/modules/openapi-generator/src/main/resources/typescript-fetch/sagas.mustache index 5f0b4a8e4512..304324cbd5a8 100644 --- a/modules/openapi-generator/src/main/resources/typescript-fetch/sagas.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-fetch/sagas.mustache @@ -105,7 +105,7 @@ export function *{{nickname}}SagaImp(_action_: Action{{/returnType}} = yield apiCall(Api.{{#lambda.camelcase}}{{classname}}{{/lambda.camelcase}}, Api.{{#lambda.camelcase}}{{classname}}{{/lambda.camelcase}}.{{nickname}}, + const response{{#returnType}}: Required<{{{returnType}}}>{{/returnType}} = yield apiCall(Api.{{#lambda.camelcase}}{{classname}}{{/lambda.camelcase}}, Api.{{#lambda.camelcase}}{{classname}}{{/lambda.camelcase}}['{{nickname}}'], {{#allParams.0}} {{#allParams}} {{#isUniqueId}} diff --git a/samples/client/petstore/typescript-fetch/builds/allOf-nullable/apis/DefaultApi.ts b/samples/client/petstore/typescript-fetch/builds/allOf-nullable/apis/DefaultApi.ts index c682b272ac58..fd8a011fc7cd 100644 --- a/samples/client/petstore/typescript-fetch/builds/allOf-nullable/apis/DefaultApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/allOf-nullable/apis/DefaultApi.ts @@ -34,8 +34,11 @@ export class DefaultApi extends runtime.BaseAPI { /** */ async listRaw(requestParameters: ListRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.personId === null || requestParameters.personId === undefined) { - throw new runtime.RequiredError('personId','Required parameter requestParameters.personId was null or undefined when calling list.'); + if (!runtime.exists(requestParameters, 'personId')) { + throw new runtime.RequiredError( + 'personId', + 'Required parameter "personId" was null or undefined when calling list().' + ); } const queryParameters: any = {}; @@ -43,7 +46,7 @@ export class DefaultApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; const response = await this.request({ - path: `/person/display/{personId}`.replace(`{${"personId"}}`, encodeURIComponent(String(requestParameters.personId))), + path: `/person/display/{personId}`.replace(`{${"personId"}}`, encodeURIComponent(String(requestParameters['personId']))), method: 'GET', headers: headerParameters, query: queryParameters, diff --git a/samples/client/petstore/typescript-fetch/builds/allOf-nullable/models/Club.ts b/samples/client/petstore/typescript-fetch/builds/allOf-nullable/models/Club.ts index 99826741f46f..513f4f1ea976 100644 --- a/samples/client/petstore/typescript-fetch/builds/allOf-nullable/models/Club.ts +++ b/samples/client/petstore/typescript-fetch/builds/allOf-nullable/models/Club.ts @@ -31,16 +31,14 @@ export interface Club { * @type {Owner} * @memberof Club */ - owner?: Owner | null; + owner?: Owner; } /** * Check if a given object implements the Club interface. */ export function instanceOfClub(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function ClubFromJSON(json: any): Club { @@ -48,7 +46,7 @@ export function ClubFromJSON(json: any): Club { } export function ClubFromJSONTyped(json: any, ignoreDiscriminator: boolean): Club { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -66,7 +64,7 @@ export function ClubToJSON(value?: Club | null): any { } return { - 'owner': OwnerToJSON(value.owner), + 'owner': OwnerToJSON(value['owner']), }; } diff --git a/samples/client/petstore/typescript-fetch/builds/allOf-nullable/models/Owner.ts b/samples/client/petstore/typescript-fetch/builds/allOf-nullable/models/Owner.ts index 70542125af99..da532a1c5503 100644 --- a/samples/client/petstore/typescript-fetch/builds/allOf-nullable/models/Owner.ts +++ b/samples/client/petstore/typescript-fetch/builds/allOf-nullable/models/Owner.ts @@ -31,9 +31,7 @@ export interface Owner { * Check if a given object implements the Owner interface. */ export function instanceOfOwner(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function OwnerFromJSON(json: any): Owner { @@ -41,7 +39,7 @@ export function OwnerFromJSON(json: any): Owner { } export function OwnerFromJSONTyped(json: any, ignoreDiscriminator: boolean): Owner { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -59,7 +57,7 @@ export function OwnerToJSON(value?: Owner | null): any { } return { - 'name': value.name, + 'name': value['name'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/allOf-nullable/runtime.ts b/samples/client/petstore/typescript-fetch/builds/allOf-nullable/runtime.ts index 0261d445a96c..3daec13bee5b 100644 --- a/samples/client/petstore/typescript-fetch/builds/allOf-nullable/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/allOf-nullable/runtime.ts @@ -310,9 +310,9 @@ export interface RequestOpts { body?: HTTPBody; } -export function exists(json: any, key: string) { +export function exists(json: any, key: string): boolean { const value = json[key]; - return value !== null && value !== undefined; + return value !== undefined && value !== null; } export function querystring(params: HTTPQuery, prefix: string = ''): string { diff --git a/samples/client/petstore/typescript-fetch/builds/allOf-readonly/apis/DefaultApi.ts b/samples/client/petstore/typescript-fetch/builds/allOf-readonly/apis/DefaultApi.ts index c682b272ac58..fd8a011fc7cd 100644 --- a/samples/client/petstore/typescript-fetch/builds/allOf-readonly/apis/DefaultApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/allOf-readonly/apis/DefaultApi.ts @@ -34,8 +34,11 @@ export class DefaultApi extends runtime.BaseAPI { /** */ async listRaw(requestParameters: ListRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.personId === null || requestParameters.personId === undefined) { - throw new runtime.RequiredError('personId','Required parameter requestParameters.personId was null or undefined when calling list.'); + if (!runtime.exists(requestParameters, 'personId')) { + throw new runtime.RequiredError( + 'personId', + 'Required parameter "personId" was null or undefined when calling list().' + ); } const queryParameters: any = {}; @@ -43,7 +46,7 @@ export class DefaultApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; const response = await this.request({ - path: `/person/display/{personId}`.replace(`{${"personId"}}`, encodeURIComponent(String(requestParameters.personId))), + path: `/person/display/{personId}`.replace(`{${"personId"}}`, encodeURIComponent(String(requestParameters['personId']))), method: 'GET', headers: headerParameters, query: queryParameters, diff --git a/samples/client/petstore/typescript-fetch/builds/allOf-readonly/models/Club.ts b/samples/client/petstore/typescript-fetch/builds/allOf-readonly/models/Club.ts index d2e709009000..8ae80041ec65 100644 --- a/samples/client/petstore/typescript-fetch/builds/allOf-readonly/models/Club.ts +++ b/samples/client/petstore/typescript-fetch/builds/allOf-readonly/models/Club.ts @@ -38,9 +38,7 @@ export interface Club { * Check if a given object implements the Club interface. */ export function instanceOfClub(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function ClubFromJSON(json: any): Club { @@ -48,7 +46,7 @@ export function ClubFromJSON(json: any): Club { } export function ClubFromJSONTyped(json: any, ignoreDiscriminator: boolean): Club { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { diff --git a/samples/client/petstore/typescript-fetch/builds/allOf-readonly/models/Owner.ts b/samples/client/petstore/typescript-fetch/builds/allOf-readonly/models/Owner.ts index 70542125af99..da532a1c5503 100644 --- a/samples/client/petstore/typescript-fetch/builds/allOf-readonly/models/Owner.ts +++ b/samples/client/petstore/typescript-fetch/builds/allOf-readonly/models/Owner.ts @@ -31,9 +31,7 @@ export interface Owner { * Check if a given object implements the Owner interface. */ export function instanceOfOwner(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function OwnerFromJSON(json: any): Owner { @@ -41,7 +39,7 @@ export function OwnerFromJSON(json: any): Owner { } export function OwnerFromJSONTyped(json: any, ignoreDiscriminator: boolean): Owner { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -59,7 +57,7 @@ export function OwnerToJSON(value?: Owner | null): any { } return { - 'name': value.name, + 'name': value['name'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/allOf-readonly/runtime.ts b/samples/client/petstore/typescript-fetch/builds/allOf-readonly/runtime.ts index 0261d445a96c..3daec13bee5b 100644 --- a/samples/client/petstore/typescript-fetch/builds/allOf-readonly/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/allOf-readonly/runtime.ts @@ -310,9 +310,9 @@ export interface RequestOpts { body?: HTTPBody; } -export function exists(json: any, key: string) { +export function exists(json: any, key: string): boolean { const value = json[key]; - return value !== null && value !== undefined; + return value !== undefined && value !== null; } export function querystring(params: HTTPQuery, prefix: string = ''): string { diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/apis/AnotherFakeApi.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/apis/AnotherFakeApi.ts index 4248cc6d062e..cec7e569d020 100644 --- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/apis/AnotherFakeApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/apis/AnotherFakeApi.ts @@ -36,8 +36,11 @@ export class AnotherFakeApi extends runtime.BaseAPI { * To test special tags */ async _123testSpecialTagsRaw(requestParameters: 123testSpecialTagsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.client === null || requestParameters.client === undefined) { - throw new runtime.RequiredError('client','Required parameter requestParameters.client was null or undefined when calling _123testSpecialTags.'); + if (!runtime.exists(requestParameters, 'client')) { + throw new runtime.RequiredError( + 'client', + 'Required parameter "client" was null or undefined when calling _123testSpecialTags().' + ); } const queryParameters: any = {}; @@ -51,7 +54,7 @@ export class AnotherFakeApi extends runtime.BaseAPI { method: 'PATCH', headers: headerParameters, query: queryParameters, - body: ClientToJSON(requestParameters.client), + body: ClientToJSON(requestParameters['client']), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => ClientFromJSON(jsonValue)); diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/apis/FakeApi.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/apis/FakeApi.ts index 7d5dc1d02760..12110a8f6a5b 100644 --- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/apis/FakeApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/apis/FakeApi.ts @@ -229,22 +229,25 @@ export class FakeApi extends runtime.BaseAPI { * test http signature authentication */ async fakeHttpSignatureTestRaw(requestParameters: FakeHttpSignatureTestRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.pet === null || requestParameters.pet === undefined) { - throw new runtime.RequiredError('pet','Required parameter requestParameters.pet was null or undefined when calling fakeHttpSignatureTest.'); + if (!runtime.exists(requestParameters, 'pet')) { + throw new runtime.RequiredError( + 'pet', + 'Required parameter "pet" was null or undefined when calling fakeHttpSignatureTest().' + ); } const queryParameters: any = {}; - if (requestParameters.query1 !== undefined) { - queryParameters['query_1'] = requestParameters.query1; + if (runtime.exists(requestParameters, 'query1')) { + queryParameters['query_1'] = requestParameters['query1']; } const headerParameters: runtime.HTTPHeaders = {}; headerParameters['Content-Type'] = 'application/json'; - if (requestParameters.header1 !== undefined && requestParameters.header1 !== null) { - headerParameters['header_1'] = String(requestParameters.header1); + if (runtime.exists(requestParameters, 'header1')) { + headerParameters['header_1'] = String(requestParameters['header1']); } const response = await this.request({ @@ -252,7 +255,7 @@ export class FakeApi extends runtime.BaseAPI { method: 'GET', headers: headerParameters, query: queryParameters, - body: PetToJSON(requestParameters.pet), + body: PetToJSON(requestParameters['pet']), }, initOverrides); return new runtime.VoidApiResponse(response); @@ -280,7 +283,7 @@ export class FakeApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, - body: requestParameters.body as any, + body: requestParameters['body'] as any, }, initOverrides); if (this.isJsonMime(response.headers.get('content-type'))) { @@ -313,7 +316,7 @@ export class FakeApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, - body: OuterCompositeToJSON(requestParameters.outerComposite), + body: OuterCompositeToJSON(requestParameters['outerComposite']), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => OuterCompositeFromJSON(jsonValue)); @@ -342,7 +345,7 @@ export class FakeApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, - body: requestParameters.body as any, + body: requestParameters['body'] as any, }, initOverrides); if (this.isJsonMime(response.headers.get('content-type'))) { @@ -375,7 +378,7 @@ export class FakeApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, - body: requestParameters.body as any, + body: requestParameters['body'] as any, }, initOverrides); if (this.isJsonMime(response.headers.get('content-type'))) { @@ -397,8 +400,11 @@ export class FakeApi extends runtime.BaseAPI { * Test serialization of enum (int) properties with examples */ async fakePropertyEnumIntegerSerializeRaw(requestParameters: FakePropertyEnumIntegerSerializeRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.outerObjectWithEnumProperty === null || requestParameters.outerObjectWithEnumProperty === undefined) { - throw new runtime.RequiredError('outerObjectWithEnumProperty','Required parameter requestParameters.outerObjectWithEnumProperty was null or undefined when calling fakePropertyEnumIntegerSerialize.'); + if (!runtime.exists(requestParameters, 'outerObjectWithEnumProperty')) { + throw new runtime.RequiredError( + 'outerObjectWithEnumProperty', + 'Required parameter "outerObjectWithEnumProperty" was null or undefined when calling fakePropertyEnumIntegerSerialize().' + ); } const queryParameters: any = {}; @@ -412,7 +418,7 @@ export class FakeApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, - body: OuterObjectWithEnumPropertyToJSON(requestParameters.outerObjectWithEnumProperty), + body: OuterObjectWithEnumPropertyToJSON(requestParameters['outerObjectWithEnumProperty']), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => OuterObjectWithEnumPropertyFromJSON(jsonValue)); @@ -431,8 +437,11 @@ export class FakeApi extends runtime.BaseAPI { * test referenced additionalProperties */ async testAdditionalPropertiesReferenceRaw(requestParameters: TestAdditionalPropertiesReferenceRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.requestBody === null || requestParameters.requestBody === undefined) { - throw new runtime.RequiredError('requestBody','Required parameter requestParameters.requestBody was null or undefined when calling testAdditionalPropertiesReference.'); + if (!runtime.exists(requestParameters, 'requestBody')) { + throw new runtime.RequiredError( + 'requestBody', + 'Required parameter "requestBody" was null or undefined when calling testAdditionalPropertiesReference().' + ); } const queryParameters: any = {}; @@ -446,7 +455,7 @@ export class FakeApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, - body: requestParameters.requestBody, + body: requestParameters['requestBody'], }, initOverrides); return new runtime.VoidApiResponse(response); @@ -464,8 +473,11 @@ export class FakeApi extends runtime.BaseAPI { * For this test, the body has to be a binary file. */ async testBodyWithBinaryRaw(requestParameters: TestBodyWithBinaryRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.body === null || requestParameters.body === undefined) { - throw new runtime.RequiredError('body','Required parameter requestParameters.body was null or undefined when calling testBodyWithBinary.'); + if (!runtime.exists(requestParameters, 'body')) { + throw new runtime.RequiredError( + 'body', + 'Required parameter "body" was null or undefined when calling testBodyWithBinary().' + ); } const queryParameters: any = {}; @@ -479,7 +491,7 @@ export class FakeApi extends runtime.BaseAPI { method: 'PUT', headers: headerParameters, query: queryParameters, - body: requestParameters.body as any, + body: requestParameters['body'] as any, }, initOverrides); return new runtime.VoidApiResponse(response); @@ -496,8 +508,11 @@ export class FakeApi extends runtime.BaseAPI { * For this test, the body for this request must reference a schema named `File`. */ async testBodyWithFileSchemaRaw(requestParameters: TestBodyWithFileSchemaRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.fileSchemaTestClass === null || requestParameters.fileSchemaTestClass === undefined) { - throw new runtime.RequiredError('fileSchemaTestClass','Required parameter requestParameters.fileSchemaTestClass was null or undefined when calling testBodyWithFileSchema.'); + if (!runtime.exists(requestParameters, 'fileSchemaTestClass')) { + throw new runtime.RequiredError( + 'fileSchemaTestClass', + 'Required parameter "fileSchemaTestClass" was null or undefined when calling testBodyWithFileSchema().' + ); } const queryParameters: any = {}; @@ -511,7 +526,7 @@ export class FakeApi extends runtime.BaseAPI { method: 'PUT', headers: headerParameters, query: queryParameters, - body: FileSchemaTestClassToJSON(requestParameters.fileSchemaTestClass), + body: FileSchemaTestClassToJSON(requestParameters['fileSchemaTestClass']), }, initOverrides); return new runtime.VoidApiResponse(response); @@ -527,18 +542,24 @@ export class FakeApi extends runtime.BaseAPI { /** */ async testBodyWithQueryParamsRaw(requestParameters: TestBodyWithQueryParamsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.query === null || requestParameters.query === undefined) { - throw new runtime.RequiredError('query','Required parameter requestParameters.query was null or undefined when calling testBodyWithQueryParams.'); + if (!runtime.exists(requestParameters, 'query')) { + throw new runtime.RequiredError( + 'query', + 'Required parameter "query" was null or undefined when calling testBodyWithQueryParams().' + ); } - if (requestParameters.user === null || requestParameters.user === undefined) { - throw new runtime.RequiredError('user','Required parameter requestParameters.user was null or undefined when calling testBodyWithQueryParams.'); + if (!runtime.exists(requestParameters, 'user')) { + throw new runtime.RequiredError( + 'user', + 'Required parameter "user" was null or undefined when calling testBodyWithQueryParams().' + ); } const queryParameters: any = {}; - if (requestParameters.query !== undefined) { - queryParameters['query'] = requestParameters.query; + if (runtime.exists(requestParameters, 'query')) { + queryParameters['query'] = requestParameters['query']; } const headerParameters: runtime.HTTPHeaders = {}; @@ -550,7 +571,7 @@ export class FakeApi extends runtime.BaseAPI { method: 'PUT', headers: headerParameters, query: queryParameters, - body: UserToJSON(requestParameters.user), + body: UserToJSON(requestParameters['user']), }, initOverrides); return new runtime.VoidApiResponse(response); @@ -567,8 +588,11 @@ export class FakeApi extends runtime.BaseAPI { * To test \"client\" model */ async testClientModelRaw(requestParameters: TestClientModelRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.client === null || requestParameters.client === undefined) { - throw new runtime.RequiredError('client','Required parameter requestParameters.client was null or undefined when calling testClientModel.'); + if (!runtime.exists(requestParameters, 'client')) { + throw new runtime.RequiredError( + 'client', + 'Required parameter "client" was null or undefined when calling testClientModel().' + ); } const queryParameters: any = {}; @@ -582,7 +606,7 @@ export class FakeApi extends runtime.BaseAPI { method: 'PATCH', headers: headerParameters, query: queryParameters, - body: ClientToJSON(requestParameters.client), + body: ClientToJSON(requestParameters['client']), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => ClientFromJSON(jsonValue)); @@ -602,20 +626,32 @@ export class FakeApi extends runtime.BaseAPI { * Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 */ async testEndpointParametersRaw(requestParameters: TestEndpointParametersRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.number === null || requestParameters.number === undefined) { - throw new runtime.RequiredError('number','Required parameter requestParameters.number was null or undefined when calling testEndpointParameters.'); + if (!runtime.exists(requestParameters, 'number')) { + throw new runtime.RequiredError( + 'number', + 'Required parameter "number" was null or undefined when calling testEndpointParameters().' + ); } - if (requestParameters._double === null || requestParameters._double === undefined) { - throw new runtime.RequiredError('_double','Required parameter requestParameters._double was null or undefined when calling testEndpointParameters.'); + if (!runtime.exists(requestParameters, '_double')) { + throw new runtime.RequiredError( + '_double', + 'Required parameter "_double" was null or undefined when calling testEndpointParameters().' + ); } - if (requestParameters.patternWithoutDelimiter === null || requestParameters.patternWithoutDelimiter === undefined) { - throw new runtime.RequiredError('patternWithoutDelimiter','Required parameter requestParameters.patternWithoutDelimiter was null or undefined when calling testEndpointParameters.'); + if (!runtime.exists(requestParameters, 'patternWithoutDelimiter')) { + throw new runtime.RequiredError( + 'patternWithoutDelimiter', + 'Required parameter "patternWithoutDelimiter" was null or undefined when calling testEndpointParameters().' + ); } - if (requestParameters._byte === null || requestParameters._byte === undefined) { - throw new runtime.RequiredError('_byte','Required parameter requestParameters._byte was null or undefined when calling testEndpointParameters.'); + if (!runtime.exists(requestParameters, '_byte')) { + throw new runtime.RequiredError( + '_byte', + 'Required parameter "_byte" was null or undefined when calling testEndpointParameters().' + ); } const queryParameters: any = {}; @@ -641,60 +677,60 @@ export class FakeApi extends runtime.BaseAPI { formParams = new URLSearchParams(); } - if (requestParameters.integer !== undefined) { - formParams.append('integer', requestParameters.integer as any); + if (runtime.exists(requestParameters, 'integer')) { + formParams.append('integer', requestParameters['integer'] as any); } - if (requestParameters.int32 !== undefined) { - formParams.append('int32', requestParameters.int32 as any); + if (runtime.exists(requestParameters, 'int32')) { + formParams.append('int32', requestParameters['int32'] as any); } - if (requestParameters.int64 !== undefined) { - formParams.append('int64', requestParameters.int64 as any); + if (runtime.exists(requestParameters, 'int64')) { + formParams.append('int64', requestParameters['int64'] as any); } - if (requestParameters.number !== undefined) { - formParams.append('number', requestParameters.number as any); + if (runtime.exists(requestParameters, 'number')) { + formParams.append('number', requestParameters['number'] as any); } - if (requestParameters._float !== undefined) { - formParams.append('float', requestParameters._float as any); + if (runtime.exists(requestParameters, '_float')) { + formParams.append('float', requestParameters['_float'] as any); } - if (requestParameters._double !== undefined) { - formParams.append('double', requestParameters._double as any); + if (runtime.exists(requestParameters, '_double')) { + formParams.append('double', requestParameters['_double'] as any); } - if (requestParameters.string !== undefined) { - formParams.append('string', requestParameters.string as any); + if (runtime.exists(requestParameters, 'string')) { + formParams.append('string', requestParameters['string'] as any); } - if (requestParameters.patternWithoutDelimiter !== undefined) { - formParams.append('pattern_without_delimiter', requestParameters.patternWithoutDelimiter as any); + if (runtime.exists(requestParameters, 'patternWithoutDelimiter')) { + formParams.append('pattern_without_delimiter', requestParameters['patternWithoutDelimiter'] as any); } - if (requestParameters._byte !== undefined) { - formParams.append('byte', requestParameters._byte as any); + if (runtime.exists(requestParameters, '_byte')) { + formParams.append('byte', requestParameters['_byte'] as any); } - if (requestParameters.binary !== undefined) { - formParams.append('binary', requestParameters.binary as any); + if (runtime.exists(requestParameters, 'binary')) { + formParams.append('binary', requestParameters['binary'] as any); } - if (requestParameters.date !== undefined) { - formParams.append('date', requestParameters.date as any); + if (runtime.exists(requestParameters, 'date')) { + formParams.append('date', requestParameters['date'] as any); } - if (requestParameters.dateTime !== undefined) { - formParams.append('dateTime', requestParameters.dateTime as any); + if (runtime.exists(requestParameters, 'dateTime')) { + formParams.append('dateTime', requestParameters['dateTime'] as any); } - if (requestParameters.password !== undefined) { - formParams.append('password', requestParameters.password as any); + if (runtime.exists(requestParameters, 'password')) { + formParams.append('password', requestParameters['password'] as any); } - if (requestParameters.callback !== undefined) { - formParams.append('callback', requestParameters.callback as any); + if (runtime.exists(requestParameters, 'callback')) { + formParams.append('callback', requestParameters['callback'] as any); } const response = await this.request({ @@ -723,34 +759,34 @@ export class FakeApi extends runtime.BaseAPI { async testEnumParametersRaw(requestParameters: TestEnumParametersRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { const queryParameters: any = {}; - if (requestParameters.enumQueryStringArray) { - queryParameters['enum_query_string_array'] = requestParameters.enumQueryStringArray; + if (runtime.exists(requestParameters, 'enumQueryStringArray')) { + queryParameters['enum_query_string_array'] = requestParameters['enumQueryStringArray']; } - if (requestParameters.enumQueryString !== undefined) { - queryParameters['enum_query_string'] = requestParameters.enumQueryString; + if (runtime.exists(requestParameters, 'enumQueryString')) { + queryParameters['enum_query_string'] = requestParameters['enumQueryString']; } - if (requestParameters.enumQueryInteger !== undefined) { - queryParameters['enum_query_integer'] = requestParameters.enumQueryInteger; + if (runtime.exists(requestParameters, 'enumQueryInteger')) { + queryParameters['enum_query_integer'] = requestParameters['enumQueryInteger']; } - if (requestParameters.enumQueryDouble !== undefined) { - queryParameters['enum_query_double'] = requestParameters.enumQueryDouble; + if (runtime.exists(requestParameters, 'enumQueryDouble')) { + queryParameters['enum_query_double'] = requestParameters['enumQueryDouble']; } - if (requestParameters.enumQueryModelArray) { - queryParameters['enum_query_model_array'] = requestParameters.enumQueryModelArray; + if (runtime.exists(requestParameters, 'enumQueryModelArray')) { + queryParameters['enum_query_model_array'] = requestParameters['enumQueryModelArray']; } const headerParameters: runtime.HTTPHeaders = {}; - if (requestParameters.enumHeaderStringArray) { - headerParameters['enum_header_string_array'] = requestParameters.enumHeaderStringArray.join(runtime.COLLECTION_FORMATS["csv"]); + if (runtime.exists(requestParameters, 'enumHeaderStringArray')) { + headerParameters['enum_header_string_array'] = requestParameters['enumHeaderStringArray']!.join(runtime.COLLECTION_FORMATS["csv"]); } - if (requestParameters.enumHeaderString !== undefined && requestParameters.enumHeaderString !== null) { - headerParameters['enum_header_string'] = String(requestParameters.enumHeaderString); + if (runtime.exists(requestParameters, 'enumHeaderString')) { + headerParameters['enum_header_string'] = String(requestParameters['enumHeaderString']); } const consumes: runtime.Consume[] = [ @@ -767,12 +803,12 @@ export class FakeApi extends runtime.BaseAPI { formParams = new URLSearchParams(); } - if (requestParameters.enumFormStringArray) { - formParams.append('enum_form_string_array', requestParameters.enumFormStringArray.join(runtime.COLLECTION_FORMATS["csv"])); + if (runtime.exists(requestParameters, 'enumFormStringArray')) { + formParams.append('enum_form_string_array', requestParameters['enumFormStringArray']!.join(runtime.COLLECTION_FORMATS["csv"])); } - if (requestParameters.enumFormString !== undefined) { - formParams.append('enum_form_string', requestParameters.enumFormString as any); + if (runtime.exists(requestParameters, 'enumFormString')) { + formParams.append('enum_form_string', requestParameters['enumFormString'] as any); } const response = await this.request({ @@ -799,44 +835,53 @@ export class FakeApi extends runtime.BaseAPI { * Fake endpoint to test group parameters (optional) */ async testGroupParametersRaw(requestParameters: TestGroupParametersRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.requiredStringGroup === null || requestParameters.requiredStringGroup === undefined) { - throw new runtime.RequiredError('requiredStringGroup','Required parameter requestParameters.requiredStringGroup was null or undefined when calling testGroupParameters.'); + if (!runtime.exists(requestParameters, 'requiredStringGroup')) { + throw new runtime.RequiredError( + 'requiredStringGroup', + 'Required parameter "requiredStringGroup" was null or undefined when calling testGroupParameters().' + ); } - if (requestParameters.requiredBooleanGroup === null || requestParameters.requiredBooleanGroup === undefined) { - throw new runtime.RequiredError('requiredBooleanGroup','Required parameter requestParameters.requiredBooleanGroup was null or undefined when calling testGroupParameters.'); + if (!runtime.exists(requestParameters, 'requiredBooleanGroup')) { + throw new runtime.RequiredError( + 'requiredBooleanGroup', + 'Required parameter "requiredBooleanGroup" was null or undefined when calling testGroupParameters().' + ); } - if (requestParameters.requiredInt64Group === null || requestParameters.requiredInt64Group === undefined) { - throw new runtime.RequiredError('requiredInt64Group','Required parameter requestParameters.requiredInt64Group was null or undefined when calling testGroupParameters.'); + if (!runtime.exists(requestParameters, 'requiredInt64Group')) { + throw new runtime.RequiredError( + 'requiredInt64Group', + 'Required parameter "requiredInt64Group" was null or undefined when calling testGroupParameters().' + ); } const queryParameters: any = {}; - if (requestParameters.requiredStringGroup !== undefined) { - queryParameters['required_string_group'] = requestParameters.requiredStringGroup; + if (runtime.exists(requestParameters, 'requiredStringGroup')) { + queryParameters['required_string_group'] = requestParameters['requiredStringGroup']; } - if (requestParameters.requiredInt64Group !== undefined) { - queryParameters['required_int64_group'] = requestParameters.requiredInt64Group; + if (runtime.exists(requestParameters, 'requiredInt64Group')) { + queryParameters['required_int64_group'] = requestParameters['requiredInt64Group']; } - if (requestParameters.stringGroup !== undefined) { - queryParameters['string_group'] = requestParameters.stringGroup; + if (runtime.exists(requestParameters, 'stringGroup')) { + queryParameters['string_group'] = requestParameters['stringGroup']; } - if (requestParameters.int64Group !== undefined) { - queryParameters['int64_group'] = requestParameters.int64Group; + if (runtime.exists(requestParameters, 'int64Group')) { + queryParameters['int64_group'] = requestParameters['int64Group']; } const headerParameters: runtime.HTTPHeaders = {}; - if (requestParameters.requiredBooleanGroup !== undefined && requestParameters.requiredBooleanGroup !== null) { - headerParameters['required_boolean_group'] = String(requestParameters.requiredBooleanGroup); + if (runtime.exists(requestParameters, 'requiredBooleanGroup')) { + headerParameters['required_boolean_group'] = String(requestParameters['requiredBooleanGroup']); } - if (requestParameters.booleanGroup !== undefined && requestParameters.booleanGroup !== null) { - headerParameters['boolean_group'] = String(requestParameters.booleanGroup); + if (runtime.exists(requestParameters, 'booleanGroup')) { + headerParameters['boolean_group'] = String(requestParameters['booleanGroup']); } if (this.configuration && this.configuration.accessToken) { @@ -870,8 +915,11 @@ export class FakeApi extends runtime.BaseAPI { * test inline additionalProperties */ async testInlineAdditionalPropertiesRaw(requestParameters: TestInlineAdditionalPropertiesRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.requestBody === null || requestParameters.requestBody === undefined) { - throw new runtime.RequiredError('requestBody','Required parameter requestParameters.requestBody was null or undefined when calling testInlineAdditionalProperties.'); + if (!runtime.exists(requestParameters, 'requestBody')) { + throw new runtime.RequiredError( + 'requestBody', + 'Required parameter "requestBody" was null or undefined when calling testInlineAdditionalProperties().' + ); } const queryParameters: any = {}; @@ -885,7 +933,7 @@ export class FakeApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, - body: requestParameters.requestBody, + body: requestParameters['requestBody'], }, initOverrides); return new runtime.VoidApiResponse(response); @@ -904,8 +952,11 @@ export class FakeApi extends runtime.BaseAPI { * test inline free-form additionalProperties */ async testInlineFreeformAdditionalPropertiesRaw(requestParameters: TestInlineFreeformAdditionalPropertiesOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.testInlineFreeformAdditionalPropertiesRequest === null || requestParameters.testInlineFreeformAdditionalPropertiesRequest === undefined) { - throw new runtime.RequiredError('testInlineFreeformAdditionalPropertiesRequest','Required parameter requestParameters.testInlineFreeformAdditionalPropertiesRequest was null or undefined when calling testInlineFreeformAdditionalProperties.'); + if (!runtime.exists(requestParameters, 'testInlineFreeformAdditionalPropertiesRequest')) { + throw new runtime.RequiredError( + 'testInlineFreeformAdditionalPropertiesRequest', + 'Required parameter "testInlineFreeformAdditionalPropertiesRequest" was null or undefined when calling testInlineFreeformAdditionalProperties().' + ); } const queryParameters: any = {}; @@ -919,7 +970,7 @@ export class FakeApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, - body: TestInlineFreeformAdditionalPropertiesRequestToJSON(requestParameters.testInlineFreeformAdditionalPropertiesRequest), + body: TestInlineFreeformAdditionalPropertiesRequestToJSON(requestParameters['testInlineFreeformAdditionalPropertiesRequest']), }, initOverrides); return new runtime.VoidApiResponse(response); @@ -938,12 +989,18 @@ export class FakeApi extends runtime.BaseAPI { * test json serialization of form data */ async testJsonFormDataRaw(requestParameters: TestJsonFormDataRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.param === null || requestParameters.param === undefined) { - throw new runtime.RequiredError('param','Required parameter requestParameters.param was null or undefined when calling testJsonFormData.'); + if (!runtime.exists(requestParameters, 'param')) { + throw new runtime.RequiredError( + 'param', + 'Required parameter "param" was null or undefined when calling testJsonFormData().' + ); } - if (requestParameters.param2 === null || requestParameters.param2 === undefined) { - throw new runtime.RequiredError('param2','Required parameter requestParameters.param2 was null or undefined when calling testJsonFormData.'); + if (!runtime.exists(requestParameters, 'param2')) { + throw new runtime.RequiredError( + 'param2', + 'Required parameter "param2" was null or undefined when calling testJsonFormData().' + ); } const queryParameters: any = {}; @@ -964,12 +1021,12 @@ export class FakeApi extends runtime.BaseAPI { formParams = new URLSearchParams(); } - if (requestParameters.param !== undefined) { - formParams.append('param', requestParameters.param as any); + if (runtime.exists(requestParameters, 'param')) { + formParams.append('param', requestParameters['param'] as any); } - if (requestParameters.param2 !== undefined) { - formParams.append('param2', requestParameters.param2 as any); + if (runtime.exists(requestParameters, 'param2')) { + formParams.append('param2', requestParameters['param2'] as any); } const response = await this.request({ @@ -996,8 +1053,11 @@ export class FakeApi extends runtime.BaseAPI { * test nullable parent property */ async testNullableRaw(requestParameters: TestNullableRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.childWithNullable === null || requestParameters.childWithNullable === undefined) { - throw new runtime.RequiredError('childWithNullable','Required parameter requestParameters.childWithNullable was null or undefined when calling testNullable.'); + if (!runtime.exists(requestParameters, 'childWithNullable')) { + throw new runtime.RequiredError( + 'childWithNullable', + 'Required parameter "childWithNullable" was null or undefined when calling testNullable().' + ); } const queryParameters: any = {}; @@ -1011,7 +1071,7 @@ export class FakeApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, - body: ChildWithNullableToJSON(requestParameters.childWithNullable), + body: ChildWithNullableToJSON(requestParameters['childWithNullable']), }, initOverrides); return new runtime.VoidApiResponse(response); @@ -1029,58 +1089,76 @@ export class FakeApi extends runtime.BaseAPI { * To test the collection format in query parameters */ async testQueryParameterCollectionFormatRaw(requestParameters: TestQueryParameterCollectionFormatRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.pipe === null || requestParameters.pipe === undefined) { - throw new runtime.RequiredError('pipe','Required parameter requestParameters.pipe was null or undefined when calling testQueryParameterCollectionFormat.'); + if (!runtime.exists(requestParameters, 'pipe')) { + throw new runtime.RequiredError( + 'pipe', + 'Required parameter "pipe" was null or undefined when calling testQueryParameterCollectionFormat().' + ); } - if (requestParameters.ioutil === null || requestParameters.ioutil === undefined) { - throw new runtime.RequiredError('ioutil','Required parameter requestParameters.ioutil was null or undefined when calling testQueryParameterCollectionFormat.'); + if (!runtime.exists(requestParameters, 'ioutil')) { + throw new runtime.RequiredError( + 'ioutil', + 'Required parameter "ioutil" was null or undefined when calling testQueryParameterCollectionFormat().' + ); } - if (requestParameters.http === null || requestParameters.http === undefined) { - throw new runtime.RequiredError('http','Required parameter requestParameters.http was null or undefined when calling testQueryParameterCollectionFormat.'); + if (!runtime.exists(requestParameters, 'http')) { + throw new runtime.RequiredError( + 'http', + 'Required parameter "http" was null or undefined when calling testQueryParameterCollectionFormat().' + ); } - if (requestParameters.url === null || requestParameters.url === undefined) { - throw new runtime.RequiredError('url','Required parameter requestParameters.url was null or undefined when calling testQueryParameterCollectionFormat.'); + if (!runtime.exists(requestParameters, 'url')) { + throw new runtime.RequiredError( + 'url', + 'Required parameter "url" was null or undefined when calling testQueryParameterCollectionFormat().' + ); } - if (requestParameters.context === null || requestParameters.context === undefined) { - throw new runtime.RequiredError('context','Required parameter requestParameters.context was null or undefined when calling testQueryParameterCollectionFormat.'); + if (!runtime.exists(requestParameters, 'context')) { + throw new runtime.RequiredError( + 'context', + 'Required parameter "context" was null or undefined when calling testQueryParameterCollectionFormat().' + ); } - if (requestParameters.allowEmpty === null || requestParameters.allowEmpty === undefined) { - throw new runtime.RequiredError('allowEmpty','Required parameter requestParameters.allowEmpty was null or undefined when calling testQueryParameterCollectionFormat.'); + if (!runtime.exists(requestParameters, 'allowEmpty')) { + throw new runtime.RequiredError( + 'allowEmpty', + 'Required parameter "allowEmpty" was null or undefined when calling testQueryParameterCollectionFormat().' + ); } const queryParameters: any = {}; - if (requestParameters.pipe) { - queryParameters['pipe'] = requestParameters.pipe.join(runtime.COLLECTION_FORMATS["pipes"]); + if (runtime.exists(requestParameters, 'pipe')) { + queryParameters['pipe'] = requestParameters['pipe']!.join(runtime.COLLECTION_FORMATS["pipes"]); } - if (requestParameters.ioutil) { - queryParameters['ioutil'] = requestParameters.ioutil.join(runtime.COLLECTION_FORMATS["csv"]); + if (runtime.exists(requestParameters, 'ioutil')) { + queryParameters['ioutil'] = requestParameters['ioutil']!.join(runtime.COLLECTION_FORMATS["csv"]); } - if (requestParameters.http) { - queryParameters['http'] = requestParameters.http.join(runtime.COLLECTION_FORMATS["ssv"]); + if (runtime.exists(requestParameters, 'http')) { + queryParameters['http'] = requestParameters['http']!.join(runtime.COLLECTION_FORMATS["ssv"]); } - if (requestParameters.url) { - queryParameters['url'] = requestParameters.url.join(runtime.COLLECTION_FORMATS["csv"]); + if (runtime.exists(requestParameters, 'url')) { + queryParameters['url'] = requestParameters['url']!.join(runtime.COLLECTION_FORMATS["csv"]); } - if (requestParameters.context) { - queryParameters['context'] = requestParameters.context; + if (runtime.exists(requestParameters, 'context')) { + queryParameters['context'] = requestParameters['context']; } - if (requestParameters.language !== undefined) { - queryParameters['language'] = requestParameters.language; + if (runtime.exists(requestParameters, 'language')) { + queryParameters['language'] = requestParameters['language']; } - if (requestParameters.allowEmpty !== undefined) { - queryParameters['allowEmpty'] = requestParameters.allowEmpty; + if (runtime.exists(requestParameters, 'allowEmpty')) { + queryParameters['allowEmpty'] = requestParameters['allowEmpty']; } const headerParameters: runtime.HTTPHeaders = {}; @@ -1107,8 +1185,11 @@ export class FakeApi extends runtime.BaseAPI { * test referenced string map */ async testStringMapReferenceRaw(requestParameters: TestStringMapReferenceRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.requestBody === null || requestParameters.requestBody === undefined) { - throw new runtime.RequiredError('requestBody','Required parameter requestParameters.requestBody was null or undefined when calling testStringMapReference.'); + if (!runtime.exists(requestParameters, 'requestBody')) { + throw new runtime.RequiredError( + 'requestBody', + 'Required parameter "requestBody" was null or undefined when calling testStringMapReference().' + ); } const queryParameters: any = {}; @@ -1122,7 +1203,7 @@ export class FakeApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, - body: requestParameters.requestBody, + body: requestParameters['requestBody'], }, initOverrides); return new runtime.VoidApiResponse(response); diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/apis/FakeClassnameTags123Api.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/apis/FakeClassnameTags123Api.ts index e6f3fd1f0b96..ce9f567a5324 100644 --- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/apis/FakeClassnameTags123Api.ts +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/apis/FakeClassnameTags123Api.ts @@ -36,8 +36,11 @@ export class FakeClassnameTags123Api extends runtime.BaseAPI { * To test class name in snake case */ async testClassnameRaw(requestParameters: TestClassnameRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.client === null || requestParameters.client === undefined) { - throw new runtime.RequiredError('client','Required parameter requestParameters.client was null or undefined when calling testClassname.'); + if (!runtime.exists(requestParameters, 'client')) { + throw new runtime.RequiredError( + 'client', + 'Required parameter "client" was null or undefined when calling testClassname().' + ); } const queryParameters: any = {}; @@ -55,7 +58,7 @@ export class FakeClassnameTags123Api extends runtime.BaseAPI { method: 'PATCH', headers: headerParameters, query: queryParameters, - body: ClientToJSON(requestParameters.client), + body: ClientToJSON(requestParameters['client']), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => ClientFromJSON(jsonValue)); diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/apis/PetApi.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/apis/PetApi.ts index 354aac42bbf8..389f7d7077f3 100644 --- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/apis/PetApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/apis/PetApi.ts @@ -78,8 +78,11 @@ export class PetApi extends runtime.BaseAPI { * Add a new pet to the store */ async addPetRaw(requestParameters: AddPetRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.pet === null || requestParameters.pet === undefined) { - throw new runtime.RequiredError('pet','Required parameter requestParameters.pet was null or undefined when calling addPet.'); + if (!runtime.exists(requestParameters, 'pet')) { + throw new runtime.RequiredError( + 'pet', + 'Required parameter "pet" was null or undefined when calling addPet().' + ); } const queryParameters: any = {}; @@ -98,7 +101,7 @@ export class PetApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, - body: PetToJSON(requestParameters.pet), + body: PetToJSON(requestParameters['pet']), }, initOverrides); return new runtime.VoidApiResponse(response); @@ -117,16 +120,19 @@ export class PetApi extends runtime.BaseAPI { * Deletes a pet */ async deletePetRaw(requestParameters: DeletePetRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.petId === null || requestParameters.petId === undefined) { - throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling deletePet.'); + if (!runtime.exists(requestParameters, 'petId')) { + throw new runtime.RequiredError( + 'petId', + 'Required parameter "petId" was null or undefined when calling deletePet().' + ); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; - if (requestParameters.apiKey !== undefined && requestParameters.apiKey !== null) { - headerParameters['api_key'] = String(requestParameters.apiKey); + if (runtime.exists(requestParameters, 'apiKey')) { + headerParameters['api_key'] = String(requestParameters['apiKey']); } if (this.configuration && this.configuration.accessToken) { @@ -135,7 +141,7 @@ export class PetApi extends runtime.BaseAPI { } const response = await this.request({ - path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), + path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters['petId']))), method: 'DELETE', headers: headerParameters, query: queryParameters, @@ -157,14 +163,17 @@ export class PetApi extends runtime.BaseAPI { * Finds Pets by status */ async findPetsByStatusRaw(requestParameters: FindPetsByStatusRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>> { - if (requestParameters.status === null || requestParameters.status === undefined) { - throw new runtime.RequiredError('status','Required parameter requestParameters.status was null or undefined when calling findPetsByStatus.'); + if (!runtime.exists(requestParameters, 'status')) { + throw new runtime.RequiredError( + 'status', + 'Required parameter "status" was null or undefined when calling findPetsByStatus().' + ); } const queryParameters: any = {}; - if (requestParameters.status) { - queryParameters['status'] = requestParameters.status.join(runtime.COLLECTION_FORMATS["csv"]); + if (runtime.exists(requestParameters, 'status')) { + queryParameters['status'] = requestParameters['status']!.join(runtime.COLLECTION_FORMATS["csv"]); } const headerParameters: runtime.HTTPHeaders = {}; @@ -199,14 +208,17 @@ export class PetApi extends runtime.BaseAPI { * @deprecated */ async findPetsByTagsRaw(requestParameters: FindPetsByTagsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>> { - if (requestParameters.tags === null || requestParameters.tags === undefined) { - throw new runtime.RequiredError('tags','Required parameter requestParameters.tags was null or undefined when calling findPetsByTags.'); + if (!runtime.exists(requestParameters, 'tags')) { + throw new runtime.RequiredError( + 'tags', + 'Required parameter "tags" was null or undefined when calling findPetsByTags().' + ); } const queryParameters: any = {}; - if (requestParameters.tags) { - queryParameters['tags'] = Array.from(requestParameters.tags).join(runtime.COLLECTION_FORMATS["csv"]); + if (runtime.exists(requestParameters, 'tags')) { + queryParameters['tags'] = Array.from(requestParameters['tags'])!.join(runtime.COLLECTION_FORMATS["csv"]); } const headerParameters: runtime.HTTPHeaders = {}; @@ -241,8 +253,11 @@ export class PetApi extends runtime.BaseAPI { * Find pet by ID */ async getPetByIdRaw(requestParameters: GetPetByIdRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.petId === null || requestParameters.petId === undefined) { - throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling getPetById.'); + if (!runtime.exists(requestParameters, 'petId')) { + throw new runtime.RequiredError( + 'petId', + 'Required parameter "petId" was null or undefined when calling getPetById().' + ); } const queryParameters: any = {}; @@ -254,7 +269,7 @@ export class PetApi extends runtime.BaseAPI { } const response = await this.request({ - path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), + path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters['petId']))), method: 'GET', headers: headerParameters, query: queryParameters, @@ -277,8 +292,11 @@ export class PetApi extends runtime.BaseAPI { * Update an existing pet */ async updatePetRaw(requestParameters: UpdatePetRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.pet === null || requestParameters.pet === undefined) { - throw new runtime.RequiredError('pet','Required parameter requestParameters.pet was null or undefined when calling updatePet.'); + if (!runtime.exists(requestParameters, 'pet')) { + throw new runtime.RequiredError( + 'pet', + 'Required parameter "pet" was null or undefined when calling updatePet().' + ); } const queryParameters: any = {}; @@ -297,7 +315,7 @@ export class PetApi extends runtime.BaseAPI { method: 'PUT', headers: headerParameters, query: queryParameters, - body: PetToJSON(requestParameters.pet), + body: PetToJSON(requestParameters['pet']), }, initOverrides); return new runtime.VoidApiResponse(response); @@ -316,8 +334,11 @@ export class PetApi extends runtime.BaseAPI { * Updates a pet in the store with form data */ async updatePetWithFormRaw(requestParameters: UpdatePetWithFormRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.petId === null || requestParameters.petId === undefined) { - throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling updatePetWithForm.'); + if (!runtime.exists(requestParameters, 'petId')) { + throw new runtime.RequiredError( + 'petId', + 'Required parameter "petId" was null or undefined when calling updatePetWithForm().' + ); } const queryParameters: any = {}; @@ -343,16 +364,16 @@ export class PetApi extends runtime.BaseAPI { formParams = new URLSearchParams(); } - if (requestParameters.name !== undefined) { - formParams.append('name', requestParameters.name as any); + if (runtime.exists(requestParameters, 'name')) { + formParams.append('name', requestParameters['name'] as any); } - if (requestParameters.status !== undefined) { - formParams.append('status', requestParameters.status as any); + if (runtime.exists(requestParameters, 'status')) { + formParams.append('status', requestParameters['status'] as any); } const response = await this.request({ - path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), + path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters['petId']))), method: 'POST', headers: headerParameters, query: queryParameters, @@ -375,8 +396,11 @@ export class PetApi extends runtime.BaseAPI { * uploads an image */ async uploadFileRaw(requestParameters: UploadFileRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.petId === null || requestParameters.petId === undefined) { - throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling uploadFile.'); + if (!runtime.exists(requestParameters, 'petId')) { + throw new runtime.RequiredError( + 'petId', + 'Required parameter "petId" was null or undefined when calling uploadFile().' + ); } const queryParameters: any = {}; @@ -404,16 +428,16 @@ export class PetApi extends runtime.BaseAPI { formParams = new URLSearchParams(); } - if (requestParameters.additionalMetadata !== undefined) { - formParams.append('additionalMetadata', requestParameters.additionalMetadata as any); + if (runtime.exists(requestParameters, 'additionalMetadata')) { + formParams.append('additionalMetadata', requestParameters['additionalMetadata'] as any); } - if (requestParameters.file !== undefined) { - formParams.append('file', requestParameters.file as any); + if (runtime.exists(requestParameters, 'file')) { + formParams.append('file', requestParameters['file'] as any); } const response = await this.request({ - path: `/pet/{petId}/uploadImage`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), + path: `/pet/{petId}/uploadImage`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters['petId']))), method: 'POST', headers: headerParameters, query: queryParameters, @@ -437,12 +461,18 @@ export class PetApi extends runtime.BaseAPI { * uploads an image (required) */ async uploadFileWithRequiredFileRaw(requestParameters: UploadFileWithRequiredFileRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.petId === null || requestParameters.petId === undefined) { - throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling uploadFileWithRequiredFile.'); + if (!runtime.exists(requestParameters, 'petId')) { + throw new runtime.RequiredError( + 'petId', + 'Required parameter "petId" was null or undefined when calling uploadFileWithRequiredFile().' + ); } - if (requestParameters.requiredFile === null || requestParameters.requiredFile === undefined) { - throw new runtime.RequiredError('requiredFile','Required parameter requestParameters.requiredFile was null or undefined when calling uploadFileWithRequiredFile.'); + if (!runtime.exists(requestParameters, 'requiredFile')) { + throw new runtime.RequiredError( + 'requiredFile', + 'Required parameter "requiredFile" was null or undefined when calling uploadFileWithRequiredFile().' + ); } const queryParameters: any = {}; @@ -470,16 +500,16 @@ export class PetApi extends runtime.BaseAPI { formParams = new URLSearchParams(); } - if (requestParameters.additionalMetadata !== undefined) { - formParams.append('additionalMetadata', requestParameters.additionalMetadata as any); + if (runtime.exists(requestParameters, 'additionalMetadata')) { + formParams.append('additionalMetadata', requestParameters['additionalMetadata'] as any); } - if (requestParameters.requiredFile !== undefined) { - formParams.append('requiredFile', requestParameters.requiredFile as any); + if (runtime.exists(requestParameters, 'requiredFile')) { + formParams.append('requiredFile', requestParameters['requiredFile'] as any); } const response = await this.request({ - path: `/fake/{petId}/uploadImageWithRequiredFile`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), + path: `/fake/{petId}/uploadImageWithRequiredFile`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters['petId']))), method: 'POST', headers: headerParameters, query: queryParameters, diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/apis/StoreApi.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/apis/StoreApi.ts index 3b17a1d7bb0d..4444f71d4cd0 100644 --- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/apis/StoreApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/apis/StoreApi.ts @@ -44,8 +44,11 @@ export class StoreApi extends runtime.BaseAPI { * Delete purchase order by ID */ async deleteOrderRaw(requestParameters: DeleteOrderRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.orderId === null || requestParameters.orderId === undefined) { - throw new runtime.RequiredError('orderId','Required parameter requestParameters.orderId was null or undefined when calling deleteOrder.'); + if (!runtime.exists(requestParameters, 'orderId')) { + throw new runtime.RequiredError( + 'orderId', + 'Required parameter "orderId" was null or undefined when calling deleteOrder().' + ); } const queryParameters: any = {}; @@ -53,7 +56,7 @@ export class StoreApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; const response = await this.request({ - path: `/store/order/{order_id}`.replace(`{${"order_id"}}`, encodeURIComponent(String(requestParameters.orderId))), + path: `/store/order/{order_id}`.replace(`{${"order_id"}}`, encodeURIComponent(String(requestParameters['orderId']))), method: 'DELETE', headers: headerParameters, query: queryParameters, @@ -107,8 +110,11 @@ export class StoreApi extends runtime.BaseAPI { * Find purchase order by ID */ async getOrderByIdRaw(requestParameters: GetOrderByIdRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.orderId === null || requestParameters.orderId === undefined) { - throw new runtime.RequiredError('orderId','Required parameter requestParameters.orderId was null or undefined when calling getOrderById.'); + if (!runtime.exists(requestParameters, 'orderId')) { + throw new runtime.RequiredError( + 'orderId', + 'Required parameter "orderId" was null or undefined when calling getOrderById().' + ); } const queryParameters: any = {}; @@ -116,7 +122,7 @@ export class StoreApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; const response = await this.request({ - path: `/store/order/{order_id}`.replace(`{${"order_id"}}`, encodeURIComponent(String(requestParameters.orderId))), + path: `/store/order/{order_id}`.replace(`{${"order_id"}}`, encodeURIComponent(String(requestParameters['orderId']))), method: 'GET', headers: headerParameters, query: queryParameters, @@ -139,8 +145,11 @@ export class StoreApi extends runtime.BaseAPI { * Place an order for a pet */ async placeOrderRaw(requestParameters: PlaceOrderRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.order === null || requestParameters.order === undefined) { - throw new runtime.RequiredError('order','Required parameter requestParameters.order was null or undefined when calling placeOrder.'); + if (!runtime.exists(requestParameters, 'order')) { + throw new runtime.RequiredError( + 'order', + 'Required parameter "order" was null or undefined when calling placeOrder().' + ); } const queryParameters: any = {}; @@ -154,7 +163,7 @@ export class StoreApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, - body: OrderToJSON(requestParameters.order), + body: OrderToJSON(requestParameters['order']), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => OrderFromJSON(jsonValue)); diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/apis/UserApi.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/apis/UserApi.ts index df5c8f4efcd4..36114480012f 100644 --- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/apis/UserApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/apis/UserApi.ts @@ -62,8 +62,11 @@ export class UserApi extends runtime.BaseAPI { * Create user */ async createUserRaw(requestParameters: CreateUserRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.user === null || requestParameters.user === undefined) { - throw new runtime.RequiredError('user','Required parameter requestParameters.user was null or undefined when calling createUser.'); + if (!runtime.exists(requestParameters, 'user')) { + throw new runtime.RequiredError( + 'user', + 'Required parameter "user" was null or undefined when calling createUser().' + ); } const queryParameters: any = {}; @@ -77,7 +80,7 @@ export class UserApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, - body: UserToJSON(requestParameters.user), + body: UserToJSON(requestParameters['user']), }, initOverrides); return new runtime.VoidApiResponse(response); @@ -96,8 +99,11 @@ export class UserApi extends runtime.BaseAPI { * Creates list of users with given input array */ async createUsersWithArrayInputRaw(requestParameters: CreateUsersWithArrayInputRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.user === null || requestParameters.user === undefined) { - throw new runtime.RequiredError('user','Required parameter requestParameters.user was null or undefined when calling createUsersWithArrayInput.'); + if (!runtime.exists(requestParameters, 'user')) { + throw new runtime.RequiredError( + 'user', + 'Required parameter "user" was null or undefined when calling createUsersWithArrayInput().' + ); } const queryParameters: any = {}; @@ -111,7 +117,7 @@ export class UserApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, - body: requestParameters.user.map(UserToJSON), + body: requestParameters['user']!.map(UserToJSON), }, initOverrides); return new runtime.VoidApiResponse(response); @@ -130,8 +136,11 @@ export class UserApi extends runtime.BaseAPI { * Creates list of users with given input array */ async createUsersWithListInputRaw(requestParameters: CreateUsersWithListInputRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.user === null || requestParameters.user === undefined) { - throw new runtime.RequiredError('user','Required parameter requestParameters.user was null or undefined when calling createUsersWithListInput.'); + if (!runtime.exists(requestParameters, 'user')) { + throw new runtime.RequiredError( + 'user', + 'Required parameter "user" was null or undefined when calling createUsersWithListInput().' + ); } const queryParameters: any = {}; @@ -145,7 +154,7 @@ export class UserApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, - body: requestParameters.user.map(UserToJSON), + body: requestParameters['user']!.map(UserToJSON), }, initOverrides); return new runtime.VoidApiResponse(response); @@ -164,8 +173,11 @@ export class UserApi extends runtime.BaseAPI { * Delete user */ async deleteUserRaw(requestParameters: DeleteUserRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.username === null || requestParameters.username === undefined) { - throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling deleteUser.'); + if (!runtime.exists(requestParameters, 'username')) { + throw new runtime.RequiredError( + 'username', + 'Required parameter "username" was null or undefined when calling deleteUser().' + ); } const queryParameters: any = {}; @@ -173,7 +185,7 @@ export class UserApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; const response = await this.request({ - path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), + path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters['username']))), method: 'DELETE', headers: headerParameters, query: queryParameters, @@ -195,8 +207,11 @@ export class UserApi extends runtime.BaseAPI { * Get user by user name */ async getUserByNameRaw(requestParameters: GetUserByNameRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.username === null || requestParameters.username === undefined) { - throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling getUserByName.'); + if (!runtime.exists(requestParameters, 'username')) { + throw new runtime.RequiredError( + 'username', + 'Required parameter "username" was null or undefined when calling getUserByName().' + ); } const queryParameters: any = {}; @@ -204,7 +219,7 @@ export class UserApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; const response = await this.request({ - path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), + path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters['username']))), method: 'GET', headers: headerParameters, query: queryParameters, @@ -227,22 +242,28 @@ export class UserApi extends runtime.BaseAPI { * Logs user into the system */ async loginUserRaw(requestParameters: LoginUserRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.username === null || requestParameters.username === undefined) { - throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling loginUser.'); + if (!runtime.exists(requestParameters, 'username')) { + throw new runtime.RequiredError( + 'username', + 'Required parameter "username" was null or undefined when calling loginUser().' + ); } - if (requestParameters.password === null || requestParameters.password === undefined) { - throw new runtime.RequiredError('password','Required parameter requestParameters.password was null or undefined when calling loginUser.'); + if (!runtime.exists(requestParameters, 'password')) { + throw new runtime.RequiredError( + 'password', + 'Required parameter "password" was null or undefined when calling loginUser().' + ); } const queryParameters: any = {}; - if (requestParameters.username !== undefined) { - queryParameters['username'] = requestParameters.username; + if (runtime.exists(requestParameters, 'username')) { + queryParameters['username'] = requestParameters['username']; } - if (requestParameters.password !== undefined) { - queryParameters['password'] = requestParameters.password; + if (runtime.exists(requestParameters, 'password')) { + queryParameters['password'] = requestParameters['password']; } const headerParameters: runtime.HTTPHeaders = {}; @@ -302,12 +323,18 @@ export class UserApi extends runtime.BaseAPI { * Updated user */ async updateUserRaw(requestParameters: UpdateUserRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.username === null || requestParameters.username === undefined) { - throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling updateUser.'); + if (!runtime.exists(requestParameters, 'username')) { + throw new runtime.RequiredError( + 'username', + 'Required parameter "username" was null or undefined when calling updateUser().' + ); } - if (requestParameters.user === null || requestParameters.user === undefined) { - throw new runtime.RequiredError('user','Required parameter requestParameters.user was null or undefined when calling updateUser.'); + if (!runtime.exists(requestParameters, 'user')) { + throw new runtime.RequiredError( + 'user', + 'Required parameter "user" was null or undefined when calling updateUser().' + ); } const queryParameters: any = {}; @@ -317,11 +344,11 @@ export class UserApi extends runtime.BaseAPI { headerParameters['Content-Type'] = 'application/json'; const response = await this.request({ - path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), + path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters['username']))), method: 'PUT', headers: headerParameters, query: queryParameters, - body: UserToJSON(requestParameters.user), + body: UserToJSON(requestParameters['user']), }, initOverrides); return new runtime.VoidApiResponse(response); diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/AdditionalPropertiesClass.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/AdditionalPropertiesClass.ts index ae1161178dbc..429a86538cd1 100644 --- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/AdditionalPropertiesClass.ts +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/AdditionalPropertiesClass.ts @@ -37,9 +37,7 @@ export interface AdditionalPropertiesClass { * Check if a given object implements the AdditionalPropertiesClass interface. */ export function instanceOfAdditionalPropertiesClass(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function AdditionalPropertiesClassFromJSON(json: any): AdditionalPropertiesClass { @@ -47,7 +45,7 @@ export function AdditionalPropertiesClassFromJSON(json: any): AdditionalProperti } export function AdditionalPropertiesClassFromJSONTyped(json: any, ignoreDiscriminator: boolean): AdditionalPropertiesClass { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -66,8 +64,8 @@ export function AdditionalPropertiesClassToJSON(value?: AdditionalPropertiesClas } return { - 'map_property': value.mapProperty, - 'map_of_map_property': value.mapOfMapProperty, + 'map_property': value['mapProperty'], + 'map_of_map_property': value['mapOfMapProperty'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/AllOfWithSingleRef.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/AllOfWithSingleRef.ts index 13958e2ab77f..5fc70179d079 100644 --- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/AllOfWithSingleRef.ts +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/AllOfWithSingleRef.ts @@ -44,9 +44,7 @@ export interface AllOfWithSingleRef { * Check if a given object implements the AllOfWithSingleRef interface. */ export function instanceOfAllOfWithSingleRef(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function AllOfWithSingleRefFromJSON(json: any): AllOfWithSingleRef { @@ -54,7 +52,7 @@ export function AllOfWithSingleRefFromJSON(json: any): AllOfWithSingleRef { } export function AllOfWithSingleRefFromJSONTyped(json: any, ignoreDiscriminator: boolean): AllOfWithSingleRef { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -73,8 +71,8 @@ export function AllOfWithSingleRefToJSON(value?: AllOfWithSingleRef | null): any } return { - 'username': value.username, - 'SingleRefType': SingleRefTypeToJSON(value.singleRefType), + 'username': value['username'], + 'SingleRefType': SingleRefTypeToJSON(value['singleRefType']), }; } diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/Animal.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/Animal.ts index 23ac499698ea..2d08a8e50e4a 100644 --- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/Animal.ts +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/Animal.ts @@ -42,10 +42,8 @@ export interface Animal { * Check if a given object implements the Animal interface. */ export function instanceOfAnimal(value: object): boolean { - let isInstance = true; - isInstance = isInstance && "className" in value; - - return isInstance; + if (!('className' in value)) return false; + return true; } export function AnimalFromJSON(json: any): Animal { @@ -53,7 +51,7 @@ export function AnimalFromJSON(json: any): Animal { } export function AnimalFromJSONTyped(json: any, ignoreDiscriminator: boolean): Animal { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } if (!ignoreDiscriminator) { @@ -80,8 +78,8 @@ export function AnimalToJSON(value?: Animal | null): any { } return { - 'className': value.className, - 'color': value.color, + 'className': value['className'], + 'color': value['color'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/ArrayOfArrayOfNumberOnly.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/ArrayOfArrayOfNumberOnly.ts index 7ab12458982f..6aca52358716 100644 --- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/ArrayOfArrayOfNumberOnly.ts +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/ArrayOfArrayOfNumberOnly.ts @@ -31,9 +31,7 @@ export interface ArrayOfArrayOfNumberOnly { * Check if a given object implements the ArrayOfArrayOfNumberOnly interface. */ export function instanceOfArrayOfArrayOfNumberOnly(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function ArrayOfArrayOfNumberOnlyFromJSON(json: any): ArrayOfArrayOfNumberOnly { @@ -41,7 +39,7 @@ export function ArrayOfArrayOfNumberOnlyFromJSON(json: any): ArrayOfArrayOfNumbe } export function ArrayOfArrayOfNumberOnlyFromJSONTyped(json: any, ignoreDiscriminator: boolean): ArrayOfArrayOfNumberOnly { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -59,7 +57,7 @@ export function ArrayOfArrayOfNumberOnlyToJSON(value?: ArrayOfArrayOfNumberOnly } return { - 'ArrayArrayNumber': value.arrayArrayNumber, + 'ArrayArrayNumber': value['arrayArrayNumber'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/ArrayOfNumberOnly.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/ArrayOfNumberOnly.ts index e0bdb81203b7..b39a628ed121 100644 --- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/ArrayOfNumberOnly.ts +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/ArrayOfNumberOnly.ts @@ -31,9 +31,7 @@ export interface ArrayOfNumberOnly { * Check if a given object implements the ArrayOfNumberOnly interface. */ export function instanceOfArrayOfNumberOnly(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function ArrayOfNumberOnlyFromJSON(json: any): ArrayOfNumberOnly { @@ -41,7 +39,7 @@ export function ArrayOfNumberOnlyFromJSON(json: any): ArrayOfNumberOnly { } export function ArrayOfNumberOnlyFromJSONTyped(json: any, ignoreDiscriminator: boolean): ArrayOfNumberOnly { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -59,7 +57,7 @@ export function ArrayOfNumberOnlyToJSON(value?: ArrayOfNumberOnly | null): any { } return { - 'ArrayNumber': value.arrayNumber, + 'ArrayNumber': value['arrayNumber'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/ArrayTest.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/ArrayTest.ts index 30473cdc6562..2396708971fa 100644 --- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/ArrayTest.ts +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/ArrayTest.ts @@ -50,9 +50,7 @@ export interface ArrayTest { * Check if a given object implements the ArrayTest interface. */ export function instanceOfArrayTest(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function ArrayTestFromJSON(json: any): ArrayTest { @@ -60,7 +58,7 @@ export function ArrayTestFromJSON(json: any): ArrayTest { } export function ArrayTestFromJSONTyped(json: any, ignoreDiscriminator: boolean): ArrayTest { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -80,9 +78,9 @@ export function ArrayTestToJSON(value?: ArrayTest | null): any { } return { - 'array_of_string': value.arrayOfString, - 'array_array_of_integer': value.arrayArrayOfInteger, - 'array_array_of_model': value.arrayArrayOfModel, + 'array_of_string': value['arrayOfString'], + 'array_array_of_integer': value['arrayArrayOfInteger'], + 'array_array_of_model': value['arrayArrayOfModel'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/Capitalization.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/Capitalization.ts index 53fec91847d2..30a6a48dfde4 100644 --- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/Capitalization.ts +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/Capitalization.ts @@ -62,9 +62,7 @@ export interface Capitalization { * Check if a given object implements the Capitalization interface. */ export function instanceOfCapitalization(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function CapitalizationFromJSON(json: any): Capitalization { @@ -72,7 +70,7 @@ export function CapitalizationFromJSON(json: any): Capitalization { } export function CapitalizationFromJSONTyped(json: any, ignoreDiscriminator: boolean): Capitalization { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -95,12 +93,12 @@ export function CapitalizationToJSON(value?: Capitalization | null): any { } return { - 'smallCamel': value.smallCamel, - 'CapitalCamel': value.capitalCamel, - 'small_Snake': value.smallSnake, - 'Capital_Snake': value.capitalSnake, - 'SCA_ETH_Flow_Points': value.sCAETHFlowPoints, - 'ATT_NAME': value.aTTNAME, + 'smallCamel': value['smallCamel'], + 'CapitalCamel': value['capitalCamel'], + 'small_Snake': value['smallSnake'], + 'Capital_Snake': value['capitalSnake'], + 'SCA_ETH_Flow_Points': value['sCAETHFlowPoints'], + 'ATT_NAME': value['aTTNAME'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/Cat.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/Cat.ts index dabeedf26255..94507ba96b1f 100644 --- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/Cat.ts +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/Cat.ts @@ -38,9 +38,7 @@ export interface Cat extends Animal { * Check if a given object implements the Cat interface. */ export function instanceOfCat(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function CatFromJSON(json: any): Cat { @@ -48,7 +46,7 @@ export function CatFromJSON(json: any): Cat { } export function CatFromJSONTyped(json: any, ignoreDiscriminator: boolean): Cat { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -66,7 +64,7 @@ export function CatToJSON(value?: Cat | null): any { } return { ...AnimalToJSON(value), - 'declawed': value.declawed, + 'declawed': value['declawed'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/Category.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/Category.ts index d1e2e3f8ac8e..3b4d927fb025 100644 --- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/Category.ts +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/Category.ts @@ -37,10 +37,8 @@ export interface Category { * Check if a given object implements the Category interface. */ export function instanceOfCategory(value: object): boolean { - let isInstance = true; - isInstance = isInstance && "name" in value; - - return isInstance; + if (!('name' in value)) return false; + return true; } export function CategoryFromJSON(json: any): Category { @@ -48,7 +46,7 @@ export function CategoryFromJSON(json: any): Category { } export function CategoryFromJSONTyped(json: any, ignoreDiscriminator: boolean): Category { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -67,8 +65,8 @@ export function CategoryToJSON(value?: Category | null): any { } return { - 'id': value.id, - 'name': value.name, + 'id': value['id'], + 'name': value['name'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/ChildWithNullable.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/ChildWithNullable.ts index 4f53b0070e4b..d1424e2d3d66 100644 --- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/ChildWithNullable.ts +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/ChildWithNullable.ts @@ -40,9 +40,7 @@ export interface ChildWithNullable extends ParentWithNullable { * Check if a given object implements the ChildWithNullable interface. */ export function instanceOfChildWithNullable(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function ChildWithNullableFromJSON(json: any): ChildWithNullable { @@ -50,7 +48,7 @@ export function ChildWithNullableFromJSON(json: any): ChildWithNullable { } export function ChildWithNullableFromJSONTyped(json: any, ignoreDiscriminator: boolean): ChildWithNullable { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -68,7 +66,7 @@ export function ChildWithNullableToJSON(value?: ChildWithNullable | null): any { } return { ...ParentWithNullableToJSON(value), - 'otherProperty': value.otherProperty, + 'otherProperty': value['otherProperty'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/ClassModel.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/ClassModel.ts index 0f01d81b15a6..6309f0dfce81 100644 --- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/ClassModel.ts +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/ClassModel.ts @@ -31,9 +31,7 @@ export interface ClassModel { * Check if a given object implements the ClassModel interface. */ export function instanceOfClassModel(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function ClassModelFromJSON(json: any): ClassModel { @@ -41,7 +39,7 @@ export function ClassModelFromJSON(json: any): ClassModel { } export function ClassModelFromJSONTyped(json: any, ignoreDiscriminator: boolean): ClassModel { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -59,7 +57,7 @@ export function ClassModelToJSON(value?: ClassModel | null): any { } return { - '_class': value._class, + '_class': value['_class'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/Client.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/Client.ts index a9fd27b4f464..96e2993ca963 100644 --- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/Client.ts +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/Client.ts @@ -31,9 +31,7 @@ export interface Client { * Check if a given object implements the Client interface. */ export function instanceOfClient(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function ClientFromJSON(json: any): Client { @@ -41,7 +39,7 @@ export function ClientFromJSON(json: any): Client { } export function ClientFromJSONTyped(json: any, ignoreDiscriminator: boolean): Client { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -59,7 +57,7 @@ export function ClientToJSON(value?: Client | null): any { } return { - 'client': value.client, + 'client': value['client'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/DeprecatedObject.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/DeprecatedObject.ts index 0cec2d09297d..c8113b4c9a39 100644 --- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/DeprecatedObject.ts +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/DeprecatedObject.ts @@ -31,9 +31,7 @@ export interface DeprecatedObject { * Check if a given object implements the DeprecatedObject interface. */ export function instanceOfDeprecatedObject(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function DeprecatedObjectFromJSON(json: any): DeprecatedObject { @@ -41,7 +39,7 @@ export function DeprecatedObjectFromJSON(json: any): DeprecatedObject { } export function DeprecatedObjectFromJSONTyped(json: any, ignoreDiscriminator: boolean): DeprecatedObject { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -59,7 +57,7 @@ export function DeprecatedObjectToJSON(value?: DeprecatedObject | null): any { } return { - 'name': value.name, + 'name': value['name'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/Dog.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/Dog.ts index 65cd613eae03..fec18e3e484c 100644 --- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/Dog.ts +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/Dog.ts @@ -38,9 +38,7 @@ export interface Dog extends Animal { * Check if a given object implements the Dog interface. */ export function instanceOfDog(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function DogFromJSON(json: any): Dog { @@ -48,7 +46,7 @@ export function DogFromJSON(json: any): Dog { } export function DogFromJSONTyped(json: any, ignoreDiscriminator: boolean): Dog { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -66,7 +64,7 @@ export function DogToJSON(value?: Dog | null): any { } return { ...AnimalToJSON(value), - 'breed': value.breed, + 'breed': value['breed'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/EnumArrays.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/EnumArrays.ts index 9603be51cd51..0c93a179655a 100644 --- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/EnumArrays.ts +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/EnumArrays.ts @@ -57,9 +57,7 @@ export type EnumArraysArrayEnumEnum = typeof EnumArraysArrayEnumEnum[keyof typeo * Check if a given object implements the EnumArrays interface. */ export function instanceOfEnumArrays(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function EnumArraysFromJSON(json: any): EnumArrays { @@ -67,7 +65,7 @@ export function EnumArraysFromJSON(json: any): EnumArrays { } export function EnumArraysFromJSONTyped(json: any, ignoreDiscriminator: boolean): EnumArrays { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -86,8 +84,8 @@ export function EnumArraysToJSON(value?: EnumArrays | null): any { } return { - 'just_symbol': value.justSymbol, - 'array_enum': value.arrayEnum, + 'just_symbol': value['justSymbol'], + 'array_enum': value['arrayEnum'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/EnumTest.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/EnumTest.ts index 69e7d4c0217c..9a8b5051c321 100644 --- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/EnumTest.ts +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/EnumTest.ts @@ -73,7 +73,7 @@ export interface EnumTest { * @type {OuterEnum} * @memberof EnumTest */ - outerEnum?: OuterEnum | null; + outerEnum?: OuterEnum; /** * * @type {OuterEnumInteger} @@ -138,10 +138,8 @@ export type EnumTestEnumNumberEnum = typeof EnumTestEnumNumberEnum[keyof typeof * Check if a given object implements the EnumTest interface. */ export function instanceOfEnumTest(value: object): boolean { - let isInstance = true; - isInstance = isInstance && "enumStringRequired" in value; - - return isInstance; + if (!('enumStringRequired' in value)) return false; + return true; } export function EnumTestFromJSON(json: any): EnumTest { @@ -149,7 +147,7 @@ export function EnumTestFromJSON(json: any): EnumTest { } export function EnumTestFromJSONTyped(json: any, ignoreDiscriminator: boolean): EnumTest { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -174,14 +172,14 @@ export function EnumTestToJSON(value?: EnumTest | null): any { } return { - 'enum_string': value.enumString, - 'enum_string_required': value.enumStringRequired, - 'enum_integer': value.enumInteger, - 'enum_number': value.enumNumber, - 'outerEnum': OuterEnumToJSON(value.outerEnum), - 'outerEnumInteger': OuterEnumIntegerToJSON(value.outerEnumInteger), - 'outerEnumDefaultValue': OuterEnumDefaultValueToJSON(value.outerEnumDefaultValue), - 'outerEnumIntegerDefaultValue': OuterEnumIntegerDefaultValueToJSON(value.outerEnumIntegerDefaultValue), + 'enum_string': value['enumString'], + 'enum_string_required': value['enumStringRequired'], + 'enum_integer': value['enumInteger'], + 'enum_number': value['enumNumber'], + 'outerEnum': OuterEnumToJSON(value['outerEnum']), + 'outerEnumInteger': OuterEnumIntegerToJSON(value['outerEnumInteger']), + 'outerEnumDefaultValue': OuterEnumDefaultValueToJSON(value['outerEnumDefaultValue']), + 'outerEnumIntegerDefaultValue': OuterEnumIntegerDefaultValueToJSON(value['outerEnumIntegerDefaultValue']), }; } diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/FakeBigDecimalMap200Response.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/FakeBigDecimalMap200Response.ts index 32154096ade4..bf4371a93c1e 100644 --- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/FakeBigDecimalMap200Response.ts +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/FakeBigDecimalMap200Response.ts @@ -37,9 +37,7 @@ export interface FakeBigDecimalMap200Response { * Check if a given object implements the FakeBigDecimalMap200Response interface. */ export function instanceOfFakeBigDecimalMap200Response(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function FakeBigDecimalMap200ResponseFromJSON(json: any): FakeBigDecimalMap200Response { @@ -47,7 +45,7 @@ export function FakeBigDecimalMap200ResponseFromJSON(json: any): FakeBigDecimalM } export function FakeBigDecimalMap200ResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): FakeBigDecimalMap200Response { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -66,8 +64,8 @@ export function FakeBigDecimalMap200ResponseToJSON(value?: FakeBigDecimalMap200R } return { - 'someId': value.someId, - 'someMap': value.someMap, + 'someId': value['someId'], + 'someMap': value['someMap'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/FileSchemaTestClass.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/FileSchemaTestClass.ts index 71f887cf3271..10e7e77f8f87 100644 --- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/FileSchemaTestClass.ts +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/FileSchemaTestClass.ts @@ -37,9 +37,7 @@ export interface FileSchemaTestClass { * Check if a given object implements the FileSchemaTestClass interface. */ export function instanceOfFileSchemaTestClass(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function FileSchemaTestClassFromJSON(json: any): FileSchemaTestClass { @@ -47,7 +45,7 @@ export function FileSchemaTestClassFromJSON(json: any): FileSchemaTestClass { } export function FileSchemaTestClassFromJSONTyped(json: any, ignoreDiscriminator: boolean): FileSchemaTestClass { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -66,8 +64,8 @@ export function FileSchemaTestClassToJSON(value?: FileSchemaTestClass | null): a } return { - 'file': value.file, - 'files': value.files, + 'file': value['file'], + 'files': value['files'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/Foo.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/Foo.ts index aa5b331c3b68..ec179ce581b5 100644 --- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/Foo.ts +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/Foo.ts @@ -31,9 +31,7 @@ export interface Foo { * Check if a given object implements the Foo interface. */ export function instanceOfFoo(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function FooFromJSON(json: any): Foo { @@ -41,7 +39,7 @@ export function FooFromJSON(json: any): Foo { } export function FooFromJSONTyped(json: any, ignoreDiscriminator: boolean): Foo { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -59,7 +57,7 @@ export function FooToJSON(value?: Foo | null): any { } return { - 'bar': value.bar, + 'bar': value['bar'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/FooGetDefaultResponse.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/FooGetDefaultResponse.ts index 3d49ed834fc6..ffd3e185c760 100644 --- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/FooGetDefaultResponse.ts +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/FooGetDefaultResponse.ts @@ -38,9 +38,7 @@ export interface FooGetDefaultResponse { * Check if a given object implements the FooGetDefaultResponse interface. */ export function instanceOfFooGetDefaultResponse(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function FooGetDefaultResponseFromJSON(json: any): FooGetDefaultResponse { @@ -48,7 +46,7 @@ export function FooGetDefaultResponseFromJSON(json: any): FooGetDefaultResponse } export function FooGetDefaultResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): FooGetDefaultResponse { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -66,7 +64,7 @@ export function FooGetDefaultResponseToJSON(value?: FooGetDefaultResponse | null } return { - 'string': FooToJSON(value.string), + 'string': FooToJSON(value['string']), }; } diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/FormatTest.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/FormatTest.ts index f095016dd22f..b509f3575a2f 100644 --- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/FormatTest.ts +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/FormatTest.ts @@ -128,13 +128,11 @@ export interface FormatTest { * Check if a given object implements the FormatTest interface. */ export function instanceOfFormatTest(value: object): boolean { - let isInstance = true; - isInstance = isInstance && "number" in value; - isInstance = isInstance && "_byte" in value; - isInstance = isInstance && "date" in value; - isInstance = isInstance && "password" in value; - - return isInstance; + if (!('number' in value)) return false; + if (!('_byte' in value)) return false; + if (!('date' in value)) return false; + if (!('password' in value)) return false; + return true; } export function FormatTestFromJSON(json: any): FormatTest { @@ -142,7 +140,7 @@ export function FormatTestFromJSON(json: any): FormatTest { } export function FormatTestFromJSONTyped(json: any, ignoreDiscriminator: boolean): FormatTest { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -175,22 +173,22 @@ export function FormatTestToJSON(value?: FormatTest | null): any { } return { - 'integer': value.integer, - 'int32': value.int32, - 'int64': value.int64, - 'number': value.number, - 'float': value._float, - 'double': value._double, - 'decimal': DecimalToJSON(value.decimal), - 'string': value.string, - 'byte': value._byte, - 'binary': value.binary, - 'date': (value.date.toISOString().substring(0,10)), - 'dateTime': value.dateTime === undefined ? undefined : (value.dateTime.toISOString()), - 'uuid': value.uuid, - 'password': value.password, - 'pattern_with_digits': value.patternWithDigits, - 'pattern_with_digits_and_delimiter': value.patternWithDigitsAndDelimiter, + 'integer': value['integer'], + 'int32': value['int32'], + 'int64': value['int64'], + 'number': value['number'], + 'float': value['_float'], + 'double': value['_double'], + 'decimal': DecimalToJSON(value['decimal']), + 'string': value['string'], + 'byte': value['_byte'], + 'binary': value['binary'], + 'date': ((value['date']).toISOString().substring(0,10)), + 'dateTime': !exists(value, 'dateTime') ? undefined : ((value['dateTime']).toISOString()), + 'uuid': value['uuid'], + 'password': value['password'], + 'pattern_with_digits': value['patternWithDigits'], + 'pattern_with_digits_and_delimiter': value['patternWithDigitsAndDelimiter'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/HasOnlyReadOnly.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/HasOnlyReadOnly.ts index d3dc4be6767e..e59842cd3e2f 100644 --- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/HasOnlyReadOnly.ts +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/HasOnlyReadOnly.ts @@ -37,9 +37,7 @@ export interface HasOnlyReadOnly { * Check if a given object implements the HasOnlyReadOnly interface. */ export function instanceOfHasOnlyReadOnly(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function HasOnlyReadOnlyFromJSON(json: any): HasOnlyReadOnly { @@ -47,7 +45,7 @@ export function HasOnlyReadOnlyFromJSON(json: any): HasOnlyReadOnly { } export function HasOnlyReadOnlyFromJSONTyped(json: any, ignoreDiscriminator: boolean): HasOnlyReadOnly { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/HealthCheckResult.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/HealthCheckResult.ts index d62e1f09b823..6d58f178cdcb 100644 --- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/HealthCheckResult.ts +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/HealthCheckResult.ts @@ -24,16 +24,14 @@ export interface HealthCheckResult { * @type {string} * @memberof HealthCheckResult */ - nullableMessage?: string | null; + nullableMessage?: string; } /** * Check if a given object implements the HealthCheckResult interface. */ export function instanceOfHealthCheckResult(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function HealthCheckResultFromJSON(json: any): HealthCheckResult { @@ -41,7 +39,7 @@ export function HealthCheckResultFromJSON(json: any): HealthCheckResult { } export function HealthCheckResultFromJSONTyped(json: any, ignoreDiscriminator: boolean): HealthCheckResult { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -59,7 +57,7 @@ export function HealthCheckResultToJSON(value?: HealthCheckResult | null): any { } return { - 'NullableMessage': value.nullableMessage, + 'NullableMessage': value['nullableMessage'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/List.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/List.ts index 1334322e823a..c4afb61a4de4 100644 --- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/List.ts +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/List.ts @@ -31,9 +31,7 @@ export interface List { * Check if a given object implements the List interface. */ export function instanceOfList(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function ListFromJSON(json: any): List { @@ -41,7 +39,7 @@ export function ListFromJSON(json: any): List { } export function ListFromJSONTyped(json: any, ignoreDiscriminator: boolean): List { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -59,7 +57,7 @@ export function ListToJSON(value?: List | null): any { } return { - '123-list': value._123list, + '123-list': value['_123list'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/MapTest.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/MapTest.ts index 2ae39dd903f1..b36dfda98d88 100644 --- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/MapTest.ts +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/MapTest.ts @@ -60,9 +60,7 @@ export type MapTestMapOfEnumStringEnum = typeof MapTestMapOfEnumStringEnum[keyof * Check if a given object implements the MapTest interface. */ export function instanceOfMapTest(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function MapTestFromJSON(json: any): MapTest { @@ -70,7 +68,7 @@ export function MapTestFromJSON(json: any): MapTest { } export function MapTestFromJSONTyped(json: any, ignoreDiscriminator: boolean): MapTest { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -91,10 +89,10 @@ export function MapTestToJSON(value?: MapTest | null): any { } return { - 'map_map_of_string': value.mapMapOfString, - 'map_of_enum_string': value.mapOfEnumString, - 'direct_map': value.directMap, - 'indirect_map': value.indirectMap, + 'map_map_of_string': value['mapMapOfString'], + 'map_of_enum_string': value['mapOfEnumString'], + 'direct_map': value['directMap'], + 'indirect_map': value['indirectMap'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/MixedPropertiesAndAdditionalPropertiesClass.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/MixedPropertiesAndAdditionalPropertiesClass.ts index 56e0a29e437d..f22b2b72a221 100644 --- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/MixedPropertiesAndAdditionalPropertiesClass.ts +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/MixedPropertiesAndAdditionalPropertiesClass.ts @@ -50,9 +50,7 @@ export interface MixedPropertiesAndAdditionalPropertiesClass { * Check if a given object implements the MixedPropertiesAndAdditionalPropertiesClass interface. */ export function instanceOfMixedPropertiesAndAdditionalPropertiesClass(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function MixedPropertiesAndAdditionalPropertiesClassFromJSON(json: any): MixedPropertiesAndAdditionalPropertiesClass { @@ -60,7 +58,7 @@ export function MixedPropertiesAndAdditionalPropertiesClassFromJSON(json: any): } export function MixedPropertiesAndAdditionalPropertiesClassFromJSONTyped(json: any, ignoreDiscriminator: boolean): MixedPropertiesAndAdditionalPropertiesClass { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -80,9 +78,9 @@ export function MixedPropertiesAndAdditionalPropertiesClassToJSON(value?: MixedP } return { - 'uuid': value.uuid, - 'dateTime': value.dateTime === undefined ? undefined : (value.dateTime.toISOString()), - 'map': value.map === undefined ? undefined : (mapValues(value.map, AnimalToJSON)), + 'uuid': value['uuid'], + 'dateTime': !exists(value, 'dateTime') ? undefined : ((value['dateTime']).toISOString()), + 'map': !exists(value, 'map') ? undefined : (mapValues(value['map'], AnimalToJSON)), }; } diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/Model200Response.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/Model200Response.ts index 8b32d414747a..8cabcd2d4b3e 100644 --- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/Model200Response.ts +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/Model200Response.ts @@ -37,9 +37,7 @@ export interface Model200Response { * Check if a given object implements the Model200Response interface. */ export function instanceOfModel200Response(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function Model200ResponseFromJSON(json: any): Model200Response { @@ -47,7 +45,7 @@ export function Model200ResponseFromJSON(json: any): Model200Response { } export function Model200ResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): Model200Response { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -66,8 +64,8 @@ export function Model200ResponseToJSON(value?: Model200Response | null): any { } return { - 'name': value.name, - 'class': value._class, + 'name': value['name'], + 'class': value['_class'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/ModelApiResponse.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/ModelApiResponse.ts index 8001d49c55bf..b3685aea30ad 100644 --- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/ModelApiResponse.ts +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/ModelApiResponse.ts @@ -43,9 +43,7 @@ export interface ModelApiResponse { * Check if a given object implements the ModelApiResponse interface. */ export function instanceOfModelApiResponse(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function ModelApiResponseFromJSON(json: any): ModelApiResponse { @@ -53,7 +51,7 @@ export function ModelApiResponseFromJSON(json: any): ModelApiResponse { } export function ModelApiResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): ModelApiResponse { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -73,9 +71,9 @@ export function ModelApiResponseToJSON(value?: ModelApiResponse | null): any { } return { - 'code': value.code, - 'type': value.type, - 'message': value.message, + 'code': value['code'], + 'type': value['type'], + 'message': value['message'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/ModelFile.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/ModelFile.ts index 9d269ea77a1c..0611bad737d6 100644 --- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/ModelFile.ts +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/ModelFile.ts @@ -31,9 +31,7 @@ export interface ModelFile { * Check if a given object implements the ModelFile interface. */ export function instanceOfModelFile(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function ModelFileFromJSON(json: any): ModelFile { @@ -41,7 +39,7 @@ export function ModelFileFromJSON(json: any): ModelFile { } export function ModelFileFromJSONTyped(json: any, ignoreDiscriminator: boolean): ModelFile { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -59,7 +57,7 @@ export function ModelFileToJSON(value?: ModelFile | null): any { } return { - 'sourceURI': value.sourceURI, + 'sourceURI': value['sourceURI'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/Name.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/Name.ts index f58a563b8b5f..4ba736c85a45 100644 --- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/Name.ts +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/Name.ts @@ -49,10 +49,8 @@ export interface Name { * Check if a given object implements the Name interface. */ export function instanceOfName(value: object): boolean { - let isInstance = true; - isInstance = isInstance && "name" in value; - - return isInstance; + if (!('name' in value)) return false; + return true; } export function NameFromJSON(json: any): Name { @@ -60,7 +58,7 @@ export function NameFromJSON(json: any): Name { } export function NameFromJSONTyped(json: any, ignoreDiscriminator: boolean): Name { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -81,8 +79,8 @@ export function NameToJSON(value?: Name | null): any { } return { - 'name': value.name, - 'property': value.property, + 'name': value['name'], + 'property': value['property'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/NullableClass.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/NullableClass.ts index 52e1a2171642..de25ab3382a4 100644 --- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/NullableClass.ts +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/NullableClass.ts @@ -25,49 +25,49 @@ export interface NullableClass { * @type {number} * @memberof NullableClass */ - integerProp?: number | null; + integerProp?: number; /** * * @type {number} * @memberof NullableClass */ - numberProp?: number | null; + numberProp?: number; /** * * @type {boolean} * @memberof NullableClass */ - booleanProp?: boolean | null; + booleanProp?: boolean; /** * * @type {string} * @memberof NullableClass */ - stringProp?: string | null; + stringProp?: string; /** * * @type {Date} * @memberof NullableClass */ - dateProp?: Date | null; + dateProp?: Date; /** * * @type {Date} * @memberof NullableClass */ - datetimeProp?: Date | null; + datetimeProp?: Date; /** * * @type {Array} * @memberof NullableClass */ - arrayNullableProp?: Array | null; + arrayNullableProp?: Array; /** * * @type {Array} * @memberof NullableClass */ - arrayAndItemsNullableProp?: Array | null; + arrayAndItemsNullableProp?: Array; /** * * @type {Array} @@ -79,13 +79,13 @@ export interface NullableClass { * @type {{ [key: string]: object; }} * @memberof NullableClass */ - objectNullableProp?: { [key: string]: object; } | null; + objectNullableProp?: { [key: string]: object; }; /** * * @type {{ [key: string]: object | null; }} * @memberof NullableClass */ - objectAndItemsNullableProp?: { [key: string]: object | null; } | null; + objectAndItemsNullableProp?: { [key: string]: object | null; }; /** * * @type {{ [key: string]: object | null; }} @@ -98,9 +98,7 @@ export interface NullableClass { * Check if a given object implements the NullableClass interface. */ export function instanceOfNullableClass(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function NullableClassFromJSON(json: any): NullableClass { @@ -108,7 +106,7 @@ export function NullableClassFromJSON(json: any): NullableClass { } export function NullableClassFromJSONTyped(json: any, ignoreDiscriminator: boolean): NullableClass { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -118,8 +116,8 @@ export function NullableClassFromJSONTyped(json: any, ignoreDiscriminator: boole 'numberProp': !exists(json, 'number_prop') ? undefined : json['number_prop'], 'booleanProp': !exists(json, 'boolean_prop') ? undefined : json['boolean_prop'], 'stringProp': !exists(json, 'string_prop') ? undefined : json['string_prop'], - 'dateProp': !exists(json, 'date_prop') ? undefined : (json['date_prop'] === null ? null : new Date(json['date_prop'])), - 'datetimeProp': !exists(json, 'datetime_prop') ? undefined : (json['datetime_prop'] === null ? null : new Date(json['datetime_prop'])), + 'dateProp': !exists(json, 'date_prop') ? undefined : (new Date(json['date_prop'])), + 'datetimeProp': !exists(json, 'datetime_prop') ? undefined : (new Date(json['datetime_prop'])), 'arrayNullableProp': !exists(json, 'array_nullable_prop') ? undefined : json['array_nullable_prop'], 'arrayAndItemsNullableProp': !exists(json, 'array_and_items_nullable_prop') ? undefined : json['array_and_items_nullable_prop'], 'arrayItemsNullable': !exists(json, 'array_items_nullable') ? undefined : json['array_items_nullable'], @@ -139,18 +137,18 @@ export function NullableClassToJSON(value?: NullableClass | null): any { return { ...value, - 'integer_prop': value.integerProp, - 'number_prop': value.numberProp, - 'boolean_prop': value.booleanProp, - 'string_prop': value.stringProp, - 'date_prop': value.dateProp === undefined ? undefined : (value.dateProp === null ? null : value.dateProp.toISOString().substring(0,10)), - 'datetime_prop': value.datetimeProp === undefined ? undefined : (value.datetimeProp === null ? null : value.datetimeProp.toISOString()), - 'array_nullable_prop': value.arrayNullableProp, - 'array_and_items_nullable_prop': value.arrayAndItemsNullableProp, - 'array_items_nullable': value.arrayItemsNullable, - 'object_nullable_prop': value.objectNullableProp, - 'object_and_items_nullable_prop': value.objectAndItemsNullableProp, - 'object_items_nullable': value.objectItemsNullable, + 'integer_prop': value['integerProp'], + 'number_prop': value['numberProp'], + 'boolean_prop': value['booleanProp'], + 'string_prop': value['stringProp'], + 'date_prop': !exists(value, 'dateProp') ? undefined : ((value['dateProp'] as any).toISOString().substring(0,10)), + 'datetime_prop': !exists(value, 'datetimeProp') ? undefined : ((value['datetimeProp'] as any).toISOString()), + 'array_nullable_prop': value['arrayNullableProp'], + 'array_and_items_nullable_prop': value['arrayAndItemsNullableProp'], + 'array_items_nullable': value['arrayItemsNullable'], + 'object_nullable_prop': value['objectNullableProp'], + 'object_and_items_nullable_prop': value['objectAndItemsNullableProp'], + 'object_items_nullable': value['objectItemsNullable'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/NumberOnly.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/NumberOnly.ts index f8d62e3fce5e..7a25240d3537 100644 --- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/NumberOnly.ts +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/NumberOnly.ts @@ -31,9 +31,7 @@ export interface NumberOnly { * Check if a given object implements the NumberOnly interface. */ export function instanceOfNumberOnly(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function NumberOnlyFromJSON(json: any): NumberOnly { @@ -41,7 +39,7 @@ export function NumberOnlyFromJSON(json: any): NumberOnly { } export function NumberOnlyFromJSONTyped(json: any, ignoreDiscriminator: boolean): NumberOnly { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -59,7 +57,7 @@ export function NumberOnlyToJSON(value?: NumberOnly | null): any { } return { - 'JustNumber': value.justNumber, + 'JustNumber': value['justNumber'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/ObjectWithDeprecatedFields.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/ObjectWithDeprecatedFields.ts index 335d6d726df7..4a921582669f 100644 --- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/ObjectWithDeprecatedFields.ts +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/ObjectWithDeprecatedFields.ts @@ -59,9 +59,7 @@ export interface ObjectWithDeprecatedFields { * Check if a given object implements the ObjectWithDeprecatedFields interface. */ export function instanceOfObjectWithDeprecatedFields(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function ObjectWithDeprecatedFieldsFromJSON(json: any): ObjectWithDeprecatedFields { @@ -69,7 +67,7 @@ export function ObjectWithDeprecatedFieldsFromJSON(json: any): ObjectWithDepreca } export function ObjectWithDeprecatedFieldsFromJSONTyped(json: any, ignoreDiscriminator: boolean): ObjectWithDeprecatedFields { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -90,10 +88,10 @@ export function ObjectWithDeprecatedFieldsToJSON(value?: ObjectWithDeprecatedFie } return { - 'uuid': value.uuid, - 'id': value.id, - 'deprecatedRef': DeprecatedObjectToJSON(value.deprecatedRef), - 'bars': value.bars, + 'uuid': value['uuid'], + 'id': value['id'], + 'deprecatedRef': DeprecatedObjectToJSON(value['deprecatedRef']), + 'bars': value['bars'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/Order.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/Order.ts index cd72c59ea5c3..6f2b79b5c85b 100644 --- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/Order.ts +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/Order.ts @@ -73,9 +73,7 @@ export type OrderStatusEnum = typeof OrderStatusEnum[keyof typeof OrderStatusEnu * Check if a given object implements the Order interface. */ export function instanceOfOrder(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function OrderFromJSON(json: any): Order { @@ -83,7 +81,7 @@ export function OrderFromJSON(json: any): Order { } export function OrderFromJSONTyped(json: any, ignoreDiscriminator: boolean): Order { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -106,12 +104,12 @@ export function OrderToJSON(value?: Order | null): any { } return { - 'id': value.id, - 'petId': value.petId, - 'quantity': value.quantity, - 'shipDate': value.shipDate === undefined ? undefined : (value.shipDate.toISOString()), - 'status': value.status, - 'complete': value.complete, + 'id': value['id'], + 'petId': value['petId'], + 'quantity': value['quantity'], + 'shipDate': !exists(value, 'shipDate') ? undefined : ((value['shipDate']).toISOString()), + 'status': value['status'], + 'complete': value['complete'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/OuterComposite.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/OuterComposite.ts index 41434f59f308..14b4e4542fab 100644 --- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/OuterComposite.ts +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/OuterComposite.ts @@ -43,9 +43,7 @@ export interface OuterComposite { * Check if a given object implements the OuterComposite interface. */ export function instanceOfOuterComposite(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function OuterCompositeFromJSON(json: any): OuterComposite { @@ -53,7 +51,7 @@ export function OuterCompositeFromJSON(json: any): OuterComposite { } export function OuterCompositeFromJSONTyped(json: any, ignoreDiscriminator: boolean): OuterComposite { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -73,9 +71,9 @@ export function OuterCompositeToJSON(value?: OuterComposite | null): any { } return { - 'my_number': value.myNumber, - 'my_string': value.myString, - 'my_boolean': value.myBoolean, + 'my_number': value['myNumber'], + 'my_string': value['myString'], + 'my_boolean': value['myBoolean'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/OuterObjectWithEnumProperty.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/OuterObjectWithEnumProperty.ts index d9626d5a0d2c..1182b747df28 100644 --- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/OuterObjectWithEnumProperty.ts +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/OuterObjectWithEnumProperty.ts @@ -38,10 +38,8 @@ export interface OuterObjectWithEnumProperty { * Check if a given object implements the OuterObjectWithEnumProperty interface. */ export function instanceOfOuterObjectWithEnumProperty(value: object): boolean { - let isInstance = true; - isInstance = isInstance && "value" in value; - - return isInstance; + if (!('value' in value)) return false; + return true; } export function OuterObjectWithEnumPropertyFromJSON(json: any): OuterObjectWithEnumProperty { @@ -49,7 +47,7 @@ export function OuterObjectWithEnumPropertyFromJSON(json: any): OuterObjectWithE } export function OuterObjectWithEnumPropertyFromJSONTyped(json: any, ignoreDiscriminator: boolean): OuterObjectWithEnumProperty { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -67,7 +65,7 @@ export function OuterObjectWithEnumPropertyToJSON(value?: OuterObjectWithEnumPro } return { - 'value': OuterEnumIntegerToJSON(value.value), + 'value': OuterEnumIntegerToJSON(value['value']), }; } diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/ParentWithNullable.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/ParentWithNullable.ts index 67c7574c229d..829781419f2c 100644 --- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/ParentWithNullable.ts +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/ParentWithNullable.ts @@ -34,7 +34,7 @@ export interface ParentWithNullable { * @type {string} * @memberof ParentWithNullable */ - nullableProperty?: string | null; + nullableProperty?: string; } @@ -51,9 +51,7 @@ export type ParentWithNullableTypeEnum = typeof ParentWithNullableTypeEnum[keyof * Check if a given object implements the ParentWithNullable interface. */ export function instanceOfParentWithNullable(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function ParentWithNullableFromJSON(json: any): ParentWithNullable { @@ -61,7 +59,7 @@ export function ParentWithNullableFromJSON(json: any): ParentWithNullable { } export function ParentWithNullableFromJSONTyped(json: any, ignoreDiscriminator: boolean): ParentWithNullable { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } if (!ignoreDiscriminator) { @@ -85,8 +83,8 @@ export function ParentWithNullableToJSON(value?: ParentWithNullable | null): any } return { - 'type': value.type, - 'nullableProperty': value.nullableProperty, + 'type': value['type'], + 'nullableProperty': value['nullableProperty'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/Pet.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/Pet.ts index 33e2b6db7973..e53a44fc33f5 100644 --- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/Pet.ts +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/Pet.ts @@ -86,11 +86,9 @@ export type PetStatusEnum = typeof PetStatusEnum[keyof typeof PetStatusEnum]; * Check if a given object implements the Pet interface. */ export function instanceOfPet(value: object): boolean { - let isInstance = true; - isInstance = isInstance && "name" in value; - isInstance = isInstance && "photoUrls" in value; - - return isInstance; + if (!('name' in value)) return false; + if (!('photoUrls' in value)) return false; + return true; } export function PetFromJSON(json: any): Pet { @@ -98,7 +96,7 @@ export function PetFromJSON(json: any): Pet { } export function PetFromJSONTyped(json: any, ignoreDiscriminator: boolean): Pet { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -121,12 +119,12 @@ export function PetToJSON(value?: Pet | null): any { } return { - 'id': value.id, - 'category': CategoryToJSON(value.category), - 'name': value.name, - 'photoUrls': Array.from(value.photoUrls as Set), - 'tags': value.tags === undefined ? undefined : ((value.tags as Array).map(TagToJSON)), - 'status': value.status, + 'id': value['id'], + 'category': CategoryToJSON(value['category']), + 'name': value['name'], + 'photoUrls': Array.from(value['photoUrls'] as Set), + 'tags': !exists(value, 'tags') ? undefined : ((value['tags'] as Array).map(TagToJSON)), + 'status': value['status'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/ReadOnlyFirst.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/ReadOnlyFirst.ts index 66d83cff7846..97c192be7826 100644 --- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/ReadOnlyFirst.ts +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/ReadOnlyFirst.ts @@ -37,9 +37,7 @@ export interface ReadOnlyFirst { * Check if a given object implements the ReadOnlyFirst interface. */ export function instanceOfReadOnlyFirst(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function ReadOnlyFirstFromJSON(json: any): ReadOnlyFirst { @@ -47,7 +45,7 @@ export function ReadOnlyFirstFromJSON(json: any): ReadOnlyFirst { } export function ReadOnlyFirstFromJSONTyped(json: any, ignoreDiscriminator: boolean): ReadOnlyFirst { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -66,7 +64,7 @@ export function ReadOnlyFirstToJSON(value?: ReadOnlyFirst | null): any { } return { - 'baz': value.baz, + 'baz': value['baz'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/Return.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/Return.ts index 64d125505b16..9d2a3787c26d 100644 --- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/Return.ts +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/Return.ts @@ -31,9 +31,7 @@ export interface Return { * Check if a given object implements the Return interface. */ export function instanceOfReturn(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function ReturnFromJSON(json: any): Return { @@ -41,7 +39,7 @@ export function ReturnFromJSON(json: any): Return { } export function ReturnFromJSONTyped(json: any, ignoreDiscriminator: boolean): Return { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -59,7 +57,7 @@ export function ReturnToJSON(value?: Return | null): any { } return { - 'return': value._return, + 'return': value['_return'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/SpecialModelName.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/SpecialModelName.ts index aa9065c48671..414fcb168909 100644 --- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/SpecialModelName.ts +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/SpecialModelName.ts @@ -31,9 +31,7 @@ export interface SpecialModelName { * Check if a given object implements the SpecialModelName interface. */ export function instanceOfSpecialModelName(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function SpecialModelNameFromJSON(json: any): SpecialModelName { @@ -41,7 +39,7 @@ export function SpecialModelNameFromJSON(json: any): SpecialModelName { } export function SpecialModelNameFromJSONTyped(json: any, ignoreDiscriminator: boolean): SpecialModelName { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -59,7 +57,7 @@ export function SpecialModelNameToJSON(value?: SpecialModelName | null): any { } return { - '$special[property.name]': value.$specialPropertyName, + '$special[property.name]': value['$specialPropertyName'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/Tag.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/Tag.ts index b52383c07ea4..446a1d0da769 100644 --- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/Tag.ts +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/Tag.ts @@ -37,9 +37,7 @@ export interface Tag { * Check if a given object implements the Tag interface. */ export function instanceOfTag(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function TagFromJSON(json: any): Tag { @@ -47,7 +45,7 @@ export function TagFromJSON(json: any): Tag { } export function TagFromJSONTyped(json: any, ignoreDiscriminator: boolean): Tag { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -66,8 +64,8 @@ export function TagToJSON(value?: Tag | null): any { } return { - 'id': value.id, - 'name': value.name, + 'id': value['id'], + 'name': value['name'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/TestInlineFreeformAdditionalPropertiesRequest.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/TestInlineFreeformAdditionalPropertiesRequest.ts index d8af84017df0..c3c3a41f093f 100644 --- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/TestInlineFreeformAdditionalPropertiesRequest.ts +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/TestInlineFreeformAdditionalPropertiesRequest.ts @@ -32,9 +32,7 @@ export interface TestInlineFreeformAdditionalPropertiesRequest { * Check if a given object implements the TestInlineFreeformAdditionalPropertiesRequest interface. */ export function instanceOfTestInlineFreeformAdditionalPropertiesRequest(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function TestInlineFreeformAdditionalPropertiesRequestFromJSON(json: any): TestInlineFreeformAdditionalPropertiesRequest { @@ -42,7 +40,7 @@ export function TestInlineFreeformAdditionalPropertiesRequestFromJSON(json: any) } export function TestInlineFreeformAdditionalPropertiesRequestFromJSONTyped(json: any, ignoreDiscriminator: boolean): TestInlineFreeformAdditionalPropertiesRequest { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -62,7 +60,7 @@ export function TestInlineFreeformAdditionalPropertiesRequestToJSON(value?: Test return { ...value, - 'someProperty': value.someProperty, + 'someProperty': value['someProperty'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/User.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/User.ts index daa30cd6783f..ed2c73a101e7 100644 --- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/User.ts +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/User.ts @@ -73,9 +73,7 @@ export interface User { * Check if a given object implements the User interface. */ export function instanceOfUser(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function UserFromJSON(json: any): User { @@ -83,7 +81,7 @@ export function UserFromJSON(json: any): User { } export function UserFromJSONTyped(json: any, ignoreDiscriminator: boolean): User { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -108,14 +106,14 @@ export function UserToJSON(value?: User | null): any { } return { - 'id': value.id, - 'username': value.username, - 'firstName': value.firstName, - 'lastName': value.lastName, - 'email': value.email, - 'password': value.password, - 'phone': value.phone, - 'userStatus': value.userStatus, + 'id': value['id'], + 'username': value['username'], + 'firstName': value['firstName'], + 'lastName': value['lastName'], + 'email': value['email'], + 'password': value['password'], + 'phone': value['phone'], + 'userStatus': value['userStatus'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/runtime.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/runtime.ts index 62bff92142aa..11b3fb68ebf9 100644 --- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/runtime.ts @@ -310,9 +310,9 @@ export interface RequestOpts { body?: HTTPBody; } -export function exists(json: any, key: string) { +export function exists(json: any, key: string): boolean { const value = json[key]; - return value !== null && value !== undefined; + return value !== undefined && value !== null; } export function querystring(params: HTTPQuery, prefix: string = ''): string { diff --git a/samples/client/petstore/typescript-fetch/builds/default/apis/PetApi.ts b/samples/client/petstore/typescript-fetch/builds/default/apis/PetApi.ts index 5f507bceb566..87cab8f993a2 100644 --- a/samples/client/petstore/typescript-fetch/builds/default/apis/PetApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/default/apis/PetApi.ts @@ -71,8 +71,11 @@ export class PetApi extends runtime.BaseAPI { * Add a new pet to the store */ async addPetRaw(requestParameters: AddPetRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.body === null || requestParameters.body === undefined) { - throw new runtime.RequiredError('body','Required parameter requestParameters.body was null or undefined when calling addPet.'); + if (!runtime.exists(requestParameters, 'body')) { + throw new runtime.RequiredError( + 'body', + 'Required parameter "body" was null or undefined when calling addPet().' + ); } const queryParameters: any = {}; @@ -91,7 +94,7 @@ export class PetApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, - body: PetToJSON(requestParameters.body), + body: PetToJSON(requestParameters['body']), }, initOverrides); return new runtime.VoidApiResponse(response); @@ -108,16 +111,19 @@ export class PetApi extends runtime.BaseAPI { * Deletes a pet */ async deletePetRaw(requestParameters: DeletePetRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.petId === null || requestParameters.petId === undefined) { - throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling deletePet.'); + if (!runtime.exists(requestParameters, 'petId')) { + throw new runtime.RequiredError( + 'petId', + 'Required parameter "petId" was null or undefined when calling deletePet().' + ); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; - if (requestParameters.apiKey !== undefined && requestParameters.apiKey !== null) { - headerParameters['api_key'] = String(requestParameters.apiKey); + if (runtime.exists(requestParameters, 'apiKey')) { + headerParameters['api_key'] = String(requestParameters['apiKey']); } if (this.configuration && this.configuration.accessToken) { @@ -126,7 +132,7 @@ export class PetApi extends runtime.BaseAPI { } const response = await this.request({ - path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), + path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters['petId']))), method: 'DELETE', headers: headerParameters, query: queryParameters, @@ -147,14 +153,17 @@ export class PetApi extends runtime.BaseAPI { * Finds Pets by status */ async findPetsByStatusRaw(requestParameters: FindPetsByStatusRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>> { - if (requestParameters.status === null || requestParameters.status === undefined) { - throw new runtime.RequiredError('status','Required parameter requestParameters.status was null or undefined when calling findPetsByStatus.'); + if (!runtime.exists(requestParameters, 'status')) { + throw new runtime.RequiredError( + 'status', + 'Required parameter "status" was null or undefined when calling findPetsByStatus().' + ); } const queryParameters: any = {}; - if (requestParameters.status) { - queryParameters['status'] = requestParameters.status.join(runtime.COLLECTION_FORMATS["csv"]); + if (runtime.exists(requestParameters, 'status')) { + queryParameters['status'] = requestParameters['status']!.join(runtime.COLLECTION_FORMATS["csv"]); } const headerParameters: runtime.HTTPHeaders = {}; @@ -189,14 +198,17 @@ export class PetApi extends runtime.BaseAPI { * @deprecated */ async findPetsByTagsRaw(requestParameters: FindPetsByTagsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>> { - if (requestParameters.tags === null || requestParameters.tags === undefined) { - throw new runtime.RequiredError('tags','Required parameter requestParameters.tags was null or undefined when calling findPetsByTags.'); + if (!runtime.exists(requestParameters, 'tags')) { + throw new runtime.RequiredError( + 'tags', + 'Required parameter "tags" was null or undefined when calling findPetsByTags().' + ); } const queryParameters: any = {}; - if (requestParameters.tags) { - queryParameters['tags'] = requestParameters.tags.join(runtime.COLLECTION_FORMATS["csv"]); + if (runtime.exists(requestParameters, 'tags')) { + queryParameters['tags'] = requestParameters['tags']!.join(runtime.COLLECTION_FORMATS["csv"]); } const headerParameters: runtime.HTTPHeaders = {}; @@ -231,8 +243,11 @@ export class PetApi extends runtime.BaseAPI { * Find pet by ID */ async getPetByIdRaw(requestParameters: GetPetByIdRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.petId === null || requestParameters.petId === undefined) { - throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling getPetById.'); + if (!runtime.exists(requestParameters, 'petId')) { + throw new runtime.RequiredError( + 'petId', + 'Required parameter "petId" was null or undefined when calling getPetById().' + ); } const queryParameters: any = {}; @@ -244,7 +259,7 @@ export class PetApi extends runtime.BaseAPI { } const response = await this.request({ - path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), + path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters['petId']))), method: 'GET', headers: headerParameters, query: queryParameters, @@ -266,8 +281,11 @@ export class PetApi extends runtime.BaseAPI { * Update an existing pet */ async updatePetRaw(requestParameters: UpdatePetRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.body === null || requestParameters.body === undefined) { - throw new runtime.RequiredError('body','Required parameter requestParameters.body was null or undefined when calling updatePet.'); + if (!runtime.exists(requestParameters, 'body')) { + throw new runtime.RequiredError( + 'body', + 'Required parameter "body" was null or undefined when calling updatePet().' + ); } const queryParameters: any = {}; @@ -286,7 +304,7 @@ export class PetApi extends runtime.BaseAPI { method: 'PUT', headers: headerParameters, query: queryParameters, - body: PetToJSON(requestParameters.body), + body: PetToJSON(requestParameters['body']), }, initOverrides); return new runtime.VoidApiResponse(response); @@ -303,8 +321,11 @@ export class PetApi extends runtime.BaseAPI { * Updates a pet in the store with form data */ async updatePetWithFormRaw(requestParameters: UpdatePetWithFormRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.petId === null || requestParameters.petId === undefined) { - throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling updatePetWithForm.'); + if (!runtime.exists(requestParameters, 'petId')) { + throw new runtime.RequiredError( + 'petId', + 'Required parameter "petId" was null or undefined when calling updatePetWithForm().' + ); } const queryParameters: any = {}; @@ -330,16 +351,16 @@ export class PetApi extends runtime.BaseAPI { formParams = new URLSearchParams(); } - if (requestParameters.name !== undefined) { - formParams.append('name', requestParameters.name as any); + if (runtime.exists(requestParameters, 'name')) { + formParams.append('name', requestParameters['name'] as any); } - if (requestParameters.status !== undefined) { - formParams.append('status', requestParameters.status as any); + if (runtime.exists(requestParameters, 'status')) { + formParams.append('status', requestParameters['status'] as any); } const response = await this.request({ - path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), + path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters['petId']))), method: 'POST', headers: headerParameters, query: queryParameters, @@ -360,8 +381,11 @@ export class PetApi extends runtime.BaseAPI { * uploads an image */ async uploadFileRaw(requestParameters: UploadFileRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.petId === null || requestParameters.petId === undefined) { - throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling uploadFile.'); + if (!runtime.exists(requestParameters, 'petId')) { + throw new runtime.RequiredError( + 'petId', + 'Required parameter "petId" was null or undefined when calling uploadFile().' + ); } const queryParameters: any = {}; @@ -389,16 +413,16 @@ export class PetApi extends runtime.BaseAPI { formParams = new URLSearchParams(); } - if (requestParameters.additionalMetadata !== undefined) { - formParams.append('additionalMetadata', requestParameters.additionalMetadata as any); + if (runtime.exists(requestParameters, 'additionalMetadata')) { + formParams.append('additionalMetadata', requestParameters['additionalMetadata'] as any); } - if (requestParameters.file !== undefined) { - formParams.append('file', requestParameters.file as any); + if (runtime.exists(requestParameters, 'file')) { + formParams.append('file', requestParameters['file'] as any); } const response = await this.request({ - path: `/pet/{petId}/uploadImage`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), + path: `/pet/{petId}/uploadImage`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters['petId']))), method: 'POST', headers: headerParameters, query: queryParameters, diff --git a/samples/client/petstore/typescript-fetch/builds/default/apis/StoreApi.ts b/samples/client/petstore/typescript-fetch/builds/default/apis/StoreApi.ts index eda5a23e9a8f..74fc267af7da 100644 --- a/samples/client/petstore/typescript-fetch/builds/default/apis/StoreApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/default/apis/StoreApi.ts @@ -44,8 +44,11 @@ export class StoreApi extends runtime.BaseAPI { * Delete purchase order by ID */ async deleteOrderRaw(requestParameters: DeleteOrderRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.orderId === null || requestParameters.orderId === undefined) { - throw new runtime.RequiredError('orderId','Required parameter requestParameters.orderId was null or undefined when calling deleteOrder.'); + if (!runtime.exists(requestParameters, 'orderId')) { + throw new runtime.RequiredError( + 'orderId', + 'Required parameter "orderId" was null or undefined when calling deleteOrder().' + ); } const queryParameters: any = {}; @@ -53,7 +56,7 @@ export class StoreApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; const response = await this.request({ - path: `/store/order/{orderId}`.replace(`{${"orderId"}}`, encodeURIComponent(String(requestParameters.orderId))), + path: `/store/order/{orderId}`.replace(`{${"orderId"}}`, encodeURIComponent(String(requestParameters['orderId']))), method: 'DELETE', headers: headerParameters, query: queryParameters, @@ -107,8 +110,11 @@ export class StoreApi extends runtime.BaseAPI { * Find purchase order by ID */ async getOrderByIdRaw(requestParameters: GetOrderByIdRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.orderId === null || requestParameters.orderId === undefined) { - throw new runtime.RequiredError('orderId','Required parameter requestParameters.orderId was null or undefined when calling getOrderById.'); + if (!runtime.exists(requestParameters, 'orderId')) { + throw new runtime.RequiredError( + 'orderId', + 'Required parameter "orderId" was null or undefined when calling getOrderById().' + ); } const queryParameters: any = {}; @@ -116,7 +122,7 @@ export class StoreApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; const response = await this.request({ - path: `/store/order/{orderId}`.replace(`{${"orderId"}}`, encodeURIComponent(String(requestParameters.orderId))), + path: `/store/order/{orderId}`.replace(`{${"orderId"}}`, encodeURIComponent(String(requestParameters['orderId']))), method: 'GET', headers: headerParameters, query: queryParameters, @@ -138,8 +144,11 @@ export class StoreApi extends runtime.BaseAPI { * Place an order for a pet */ async placeOrderRaw(requestParameters: PlaceOrderRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.body === null || requestParameters.body === undefined) { - throw new runtime.RequiredError('body','Required parameter requestParameters.body was null or undefined when calling placeOrder.'); + if (!runtime.exists(requestParameters, 'body')) { + throw new runtime.RequiredError( + 'body', + 'Required parameter "body" was null or undefined when calling placeOrder().' + ); } const queryParameters: any = {}; @@ -153,7 +162,7 @@ export class StoreApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, - body: OrderToJSON(requestParameters.body), + body: OrderToJSON(requestParameters['body']), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => OrderFromJSON(jsonValue)); diff --git a/samples/client/petstore/typescript-fetch/builds/default/apis/UserApi.ts b/samples/client/petstore/typescript-fetch/builds/default/apis/UserApi.ts index 58f6a7e5d3af..565ceefcaab9 100644 --- a/samples/client/petstore/typescript-fetch/builds/default/apis/UserApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/default/apis/UserApi.ts @@ -62,8 +62,11 @@ export class UserApi extends runtime.BaseAPI { * Create user */ async createUserRaw(requestParameters: CreateUserRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.body === null || requestParameters.body === undefined) { - throw new runtime.RequiredError('body','Required parameter requestParameters.body was null or undefined when calling createUser.'); + if (!runtime.exists(requestParameters, 'body')) { + throw new runtime.RequiredError( + 'body', + 'Required parameter "body" was null or undefined when calling createUser().' + ); } const queryParameters: any = {}; @@ -77,7 +80,7 @@ export class UserApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, - body: UserToJSON(requestParameters.body), + body: UserToJSON(requestParameters['body']), }, initOverrides); return new runtime.VoidApiResponse(response); @@ -95,8 +98,11 @@ export class UserApi extends runtime.BaseAPI { * Creates list of users with given input array */ async createUsersWithArrayInputRaw(requestParameters: CreateUsersWithArrayInputRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.body === null || requestParameters.body === undefined) { - throw new runtime.RequiredError('body','Required parameter requestParameters.body was null or undefined when calling createUsersWithArrayInput.'); + if (!runtime.exists(requestParameters, 'body')) { + throw new runtime.RequiredError( + 'body', + 'Required parameter "body" was null or undefined when calling createUsersWithArrayInput().' + ); } const queryParameters: any = {}; @@ -110,7 +116,7 @@ export class UserApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, - body: requestParameters.body.map(UserToJSON), + body: requestParameters['body']!.map(UserToJSON), }, initOverrides); return new runtime.VoidApiResponse(response); @@ -127,8 +133,11 @@ export class UserApi extends runtime.BaseAPI { * Creates list of users with given input array */ async createUsersWithListInputRaw(requestParameters: CreateUsersWithListInputRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.body === null || requestParameters.body === undefined) { - throw new runtime.RequiredError('body','Required parameter requestParameters.body was null or undefined when calling createUsersWithListInput.'); + if (!runtime.exists(requestParameters, 'body')) { + throw new runtime.RequiredError( + 'body', + 'Required parameter "body" was null or undefined when calling createUsersWithListInput().' + ); } const queryParameters: any = {}; @@ -142,7 +151,7 @@ export class UserApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, - body: requestParameters.body.map(UserToJSON), + body: requestParameters['body']!.map(UserToJSON), }, initOverrides); return new runtime.VoidApiResponse(response); @@ -160,8 +169,11 @@ export class UserApi extends runtime.BaseAPI { * Delete user */ async deleteUserRaw(requestParameters: DeleteUserRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.username === null || requestParameters.username === undefined) { - throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling deleteUser.'); + if (!runtime.exists(requestParameters, 'username')) { + throw new runtime.RequiredError( + 'username', + 'Required parameter "username" was null or undefined when calling deleteUser().' + ); } const queryParameters: any = {}; @@ -169,7 +181,7 @@ export class UserApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; const response = await this.request({ - path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), + path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters['username']))), method: 'DELETE', headers: headerParameters, query: queryParameters, @@ -190,8 +202,11 @@ export class UserApi extends runtime.BaseAPI { * Get user by user name */ async getUserByNameRaw(requestParameters: GetUserByNameRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.username === null || requestParameters.username === undefined) { - throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling getUserByName.'); + if (!runtime.exists(requestParameters, 'username')) { + throw new runtime.RequiredError( + 'username', + 'Required parameter "username" was null or undefined when calling getUserByName().' + ); } const queryParameters: any = {}; @@ -199,7 +214,7 @@ export class UserApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; const response = await this.request({ - path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), + path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters['username']))), method: 'GET', headers: headerParameters, query: queryParameters, @@ -220,22 +235,28 @@ export class UserApi extends runtime.BaseAPI { * Logs user into the system */ async loginUserRaw(requestParameters: LoginUserRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.username === null || requestParameters.username === undefined) { - throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling loginUser.'); + if (!runtime.exists(requestParameters, 'username')) { + throw new runtime.RequiredError( + 'username', + 'Required parameter "username" was null or undefined when calling loginUser().' + ); } - if (requestParameters.password === null || requestParameters.password === undefined) { - throw new runtime.RequiredError('password','Required parameter requestParameters.password was null or undefined when calling loginUser.'); + if (!runtime.exists(requestParameters, 'password')) { + throw new runtime.RequiredError( + 'password', + 'Required parameter "password" was null or undefined when calling loginUser().' + ); } const queryParameters: any = {}; - if (requestParameters.username !== undefined) { - queryParameters['username'] = requestParameters.username; + if (runtime.exists(requestParameters, 'username')) { + queryParameters['username'] = requestParameters['username']; } - if (requestParameters.password !== undefined) { - queryParameters['password'] = requestParameters.password; + if (runtime.exists(requestParameters, 'password')) { + queryParameters['password'] = requestParameters['password']; } const headerParameters: runtime.HTTPHeaders = {}; @@ -292,12 +313,18 @@ export class UserApi extends runtime.BaseAPI { * Updated user */ async updateUserRaw(requestParameters: UpdateUserRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.username === null || requestParameters.username === undefined) { - throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling updateUser.'); + if (!runtime.exists(requestParameters, 'username')) { + throw new runtime.RequiredError( + 'username', + 'Required parameter "username" was null or undefined when calling updateUser().' + ); } - if (requestParameters.body === null || requestParameters.body === undefined) { - throw new runtime.RequiredError('body','Required parameter requestParameters.body was null or undefined when calling updateUser.'); + if (!runtime.exists(requestParameters, 'body')) { + throw new runtime.RequiredError( + 'body', + 'Required parameter "body" was null or undefined when calling updateUser().' + ); } const queryParameters: any = {}; @@ -307,11 +334,11 @@ export class UserApi extends runtime.BaseAPI { headerParameters['Content-Type'] = 'application/json'; const response = await this.request({ - path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), + path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters['username']))), method: 'PUT', headers: headerParameters, query: queryParameters, - body: UserToJSON(requestParameters.body), + body: UserToJSON(requestParameters['body']), }, initOverrides); return new runtime.VoidApiResponse(response); diff --git a/samples/client/petstore/typescript-fetch/builds/default/models/Category.ts b/samples/client/petstore/typescript-fetch/builds/default/models/Category.ts index 882567387201..001bc135bb96 100644 --- a/samples/client/petstore/typescript-fetch/builds/default/models/Category.ts +++ b/samples/client/petstore/typescript-fetch/builds/default/models/Category.ts @@ -37,9 +37,7 @@ export interface Category { * Check if a given object implements the Category interface. */ export function instanceOfCategory(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function CategoryFromJSON(json: any): Category { @@ -47,7 +45,7 @@ export function CategoryFromJSON(json: any): Category { } export function CategoryFromJSONTyped(json: any, ignoreDiscriminator: boolean): Category { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -66,8 +64,8 @@ export function CategoryToJSON(value?: Category | null): any { } return { - 'id': value.id, - 'name': value.name, + 'id': value['id'], + 'name': value['name'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/default/models/ModelApiResponse.ts b/samples/client/petstore/typescript-fetch/builds/default/models/ModelApiResponse.ts index bf50981fc2e2..a7fc63d81f1b 100644 --- a/samples/client/petstore/typescript-fetch/builds/default/models/ModelApiResponse.ts +++ b/samples/client/petstore/typescript-fetch/builds/default/models/ModelApiResponse.ts @@ -43,9 +43,7 @@ export interface ModelApiResponse { * Check if a given object implements the ModelApiResponse interface. */ export function instanceOfModelApiResponse(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function ModelApiResponseFromJSON(json: any): ModelApiResponse { @@ -53,7 +51,7 @@ export function ModelApiResponseFromJSON(json: any): ModelApiResponse { } export function ModelApiResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): ModelApiResponse { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -73,9 +71,9 @@ export function ModelApiResponseToJSON(value?: ModelApiResponse | null): any { } return { - 'code': value.code, - 'type': value.type, - 'message': value.message, + 'code': value['code'], + 'type': value['type'], + 'message': value['message'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/default/models/Order.ts b/samples/client/petstore/typescript-fetch/builds/default/models/Order.ts index 0d69755d4887..9e12fc242793 100644 --- a/samples/client/petstore/typescript-fetch/builds/default/models/Order.ts +++ b/samples/client/petstore/typescript-fetch/builds/default/models/Order.ts @@ -73,9 +73,7 @@ export type OrderStatusEnum = typeof OrderStatusEnum[keyof typeof OrderStatusEnu * Check if a given object implements the Order interface. */ export function instanceOfOrder(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function OrderFromJSON(json: any): Order { @@ -83,7 +81,7 @@ export function OrderFromJSON(json: any): Order { } export function OrderFromJSONTyped(json: any, ignoreDiscriminator: boolean): Order { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -106,12 +104,12 @@ export function OrderToJSON(value?: Order | null): any { } return { - 'id': value.id, - 'petId': value.petId, - 'quantity': value.quantity, - 'shipDate': value.shipDate === undefined ? undefined : (value.shipDate.toISOString()), - 'status': value.status, - 'complete': value.complete, + 'id': value['id'], + 'petId': value['petId'], + 'quantity': value['quantity'], + 'shipDate': !exists(value, 'shipDate') ? undefined : ((value['shipDate']).toISOString()), + 'status': value['status'], + 'complete': value['complete'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/default/models/Pet.ts b/samples/client/petstore/typescript-fetch/builds/default/models/Pet.ts index 73c70f03a3e5..8906602f6f4b 100644 --- a/samples/client/petstore/typescript-fetch/builds/default/models/Pet.ts +++ b/samples/client/petstore/typescript-fetch/builds/default/models/Pet.ts @@ -86,11 +86,9 @@ export type PetStatusEnum = typeof PetStatusEnum[keyof typeof PetStatusEnum]; * Check if a given object implements the Pet interface. */ export function instanceOfPet(value: object): boolean { - let isInstance = true; - isInstance = isInstance && "name" in value; - isInstance = isInstance && "photoUrls" in value; - - return isInstance; + if (!('name' in value)) return false; + if (!('photoUrls' in value)) return false; + return true; } export function PetFromJSON(json: any): Pet { @@ -98,7 +96,7 @@ export function PetFromJSON(json: any): Pet { } export function PetFromJSONTyped(json: any, ignoreDiscriminator: boolean): Pet { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -121,12 +119,12 @@ export function PetToJSON(value?: Pet | null): any { } return { - 'id': value.id, - 'category': CategoryToJSON(value.category), - 'name': value.name, - 'photoUrls': value.photoUrls, - 'tags': value.tags === undefined ? undefined : ((value.tags as Array).map(TagToJSON)), - 'status': value.status, + 'id': value['id'], + 'category': CategoryToJSON(value['category']), + 'name': value['name'], + 'photoUrls': value['photoUrls'], + 'tags': !exists(value, 'tags') ? undefined : ((value['tags'] as Array).map(TagToJSON)), + 'status': value['status'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/default/models/Tag.ts b/samples/client/petstore/typescript-fetch/builds/default/models/Tag.ts index e4902aa53cfd..24a25f383dba 100644 --- a/samples/client/petstore/typescript-fetch/builds/default/models/Tag.ts +++ b/samples/client/petstore/typescript-fetch/builds/default/models/Tag.ts @@ -37,9 +37,7 @@ export interface Tag { * Check if a given object implements the Tag interface. */ export function instanceOfTag(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function TagFromJSON(json: any): Tag { @@ -47,7 +45,7 @@ export function TagFromJSON(json: any): Tag { } export function TagFromJSONTyped(json: any, ignoreDiscriminator: boolean): Tag { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -66,8 +64,8 @@ export function TagToJSON(value?: Tag | null): any { } return { - 'id': value.id, - 'name': value.name, + 'id': value['id'], + 'name': value['name'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/default/models/User.ts b/samples/client/petstore/typescript-fetch/builds/default/models/User.ts index f22da928907c..00ab35b80563 100644 --- a/samples/client/petstore/typescript-fetch/builds/default/models/User.ts +++ b/samples/client/petstore/typescript-fetch/builds/default/models/User.ts @@ -73,9 +73,7 @@ export interface User { * Check if a given object implements the User interface. */ export function instanceOfUser(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function UserFromJSON(json: any): User { @@ -83,7 +81,7 @@ export function UserFromJSON(json: any): User { } export function UserFromJSONTyped(json: any, ignoreDiscriminator: boolean): User { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -108,14 +106,14 @@ export function UserToJSON(value?: User | null): any { } return { - 'id': value.id, - 'username': value.username, - 'firstName': value.firstName, - 'lastName': value.lastName, - 'email': value.email, - 'password': value.password, - 'phone': value.phone, - 'userStatus': value.userStatus, + 'id': value['id'], + 'username': value['username'], + 'firstName': value['firstName'], + 'lastName': value['lastName'], + 'email': value['email'], + 'password': value['password'], + 'phone': value['phone'], + 'userStatus': value['userStatus'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/default/runtime.ts b/samples/client/petstore/typescript-fetch/builds/default/runtime.ts index 71ecdb875d14..813bf0fb4dfe 100644 --- a/samples/client/petstore/typescript-fetch/builds/default/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/default/runtime.ts @@ -310,9 +310,9 @@ export interface RequestOpts { body?: HTTPBody; } -export function exists(json: any, key: string) { +export function exists(json: any, key: string): boolean { const value = json[key]; - return value !== null && value !== undefined; + return value !== undefined && value !== null; } export function querystring(params: HTTPQuery, prefix: string = ''): string { diff --git a/samples/client/petstore/typescript-fetch/builds/enum/apis/DefaultApi.ts b/samples/client/petstore/typescript-fetch/builds/enum/apis/DefaultApi.ts index 198072bfc065..f54273179d37 100644 --- a/samples/client/petstore/typescript-fetch/builds/enum/apis/DefaultApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/enum/apis/DefaultApi.ts @@ -40,9 +40,9 @@ export interface FakeEnumRequestGetInlineRequest { export interface FakeEnumRequestGetRefRequest { stringEnum?: StringEnum; - nullableStringEnum?: StringEnum | null; + nullableStringEnum?: StringEnum; numberEnum?: NumberEnum; - nullableNumberEnum?: NumberEnum | null; + nullableNumberEnum?: NumberEnum; } export interface FakeEnumRequestPostInlineRequest { @@ -63,20 +63,20 @@ export class DefaultApi extends runtime.BaseAPI { async fakeEnumRequestGetInlineRaw(requestParameters: FakeEnumRequestGetInlineRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { const queryParameters: any = {}; - if (requestParameters.stringEnum !== undefined) { - queryParameters['string-enum'] = requestParameters.stringEnum; + if (runtime.exists(requestParameters, 'stringEnum')) { + queryParameters['string-enum'] = requestParameters['stringEnum']; } - if (requestParameters.nullableStringEnum !== undefined) { - queryParameters['nullable-string-enum'] = requestParameters.nullableStringEnum; + if (runtime.exists(requestParameters, 'nullableStringEnum')) { + queryParameters['nullable-string-enum'] = requestParameters['nullableStringEnum']; } - if (requestParameters.numberEnum !== undefined) { - queryParameters['number-enum'] = requestParameters.numberEnum; + if (runtime.exists(requestParameters, 'numberEnum')) { + queryParameters['number-enum'] = requestParameters['numberEnum']; } - if (requestParameters.nullableNumberEnum !== undefined) { - queryParameters['nullable-number-enum'] = requestParameters.nullableNumberEnum; + if (runtime.exists(requestParameters, 'nullableNumberEnum')) { + queryParameters['nullable-number-enum'] = requestParameters['nullableNumberEnum']; } const headerParameters: runtime.HTTPHeaders = {}; @@ -103,20 +103,20 @@ export class DefaultApi extends runtime.BaseAPI { async fakeEnumRequestGetRefRaw(requestParameters: FakeEnumRequestGetRefRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { const queryParameters: any = {}; - if (requestParameters.stringEnum !== undefined) { - queryParameters['string-enum'] = requestParameters.stringEnum; + if (runtime.exists(requestParameters, 'stringEnum')) { + queryParameters['string-enum'] = requestParameters['stringEnum']; } - if (requestParameters.nullableStringEnum !== undefined) { - queryParameters['nullable-string-enum'] = requestParameters.nullableStringEnum; + if (runtime.exists(requestParameters, 'nullableStringEnum')) { + queryParameters['nullable-string-enum'] = requestParameters['nullableStringEnum']; } - if (requestParameters.numberEnum !== undefined) { - queryParameters['number-enum'] = requestParameters.numberEnum; + if (runtime.exists(requestParameters, 'numberEnum')) { + queryParameters['number-enum'] = requestParameters['numberEnum']; } - if (requestParameters.nullableNumberEnum !== undefined) { - queryParameters['nullable-number-enum'] = requestParameters.nullableNumberEnum; + if (runtime.exists(requestParameters, 'nullableNumberEnum')) { + queryParameters['nullable-number-enum'] = requestParameters['nullableNumberEnum']; } const headerParameters: runtime.HTTPHeaders = {}; @@ -152,7 +152,7 @@ export class DefaultApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, - body: FakeEnumRequestGetInline200ResponseToJSON(requestParameters.fakeEnumRequestGetInline200Response), + body: FakeEnumRequestGetInline200ResponseToJSON(requestParameters['fakeEnumRequestGetInline200Response']), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => FakeEnumRequestGetInline200ResponseFromJSON(jsonValue)); @@ -179,7 +179,7 @@ export class DefaultApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, - body: EnumPatternObjectToJSON(requestParameters.enumPatternObject), + body: EnumPatternObjectToJSON(requestParameters['enumPatternObject']), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => EnumPatternObjectFromJSON(jsonValue)); diff --git a/samples/client/petstore/typescript-fetch/builds/enum/models/EnumPatternObject.ts b/samples/client/petstore/typescript-fetch/builds/enum/models/EnumPatternObject.ts index ebee6ba47f7d..38d190ba0f39 100644 --- a/samples/client/petstore/typescript-fetch/builds/enum/models/EnumPatternObject.ts +++ b/samples/client/petstore/typescript-fetch/builds/enum/models/EnumPatternObject.ts @@ -43,7 +43,7 @@ export interface EnumPatternObject { * @type {StringEnum} * @memberof EnumPatternObject */ - nullableStringEnum?: StringEnum | null; + nullableStringEnum?: StringEnum; /** * * @type {NumberEnum} @@ -55,16 +55,14 @@ export interface EnumPatternObject { * @type {NumberEnum} * @memberof EnumPatternObject */ - nullableNumberEnum?: NumberEnum | null; + nullableNumberEnum?: NumberEnum; } /** * Check if a given object implements the EnumPatternObject interface. */ export function instanceOfEnumPatternObject(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function EnumPatternObjectFromJSON(json: any): EnumPatternObject { @@ -72,7 +70,7 @@ export function EnumPatternObjectFromJSON(json: any): EnumPatternObject { } export function EnumPatternObjectFromJSONTyped(json: any, ignoreDiscriminator: boolean): EnumPatternObject { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -93,10 +91,10 @@ export function EnumPatternObjectToJSON(value?: EnumPatternObject | null): any { } return { - 'string-enum': StringEnumToJSON(value.stringEnum), - 'nullable-string-enum': StringEnumToJSON(value.nullableStringEnum), - 'number-enum': NumberEnumToJSON(value.numberEnum), - 'nullable-number-enum': NumberEnumToJSON(value.nullableNumberEnum), + 'string-enum': StringEnumToJSON(value['stringEnum']), + 'nullable-string-enum': StringEnumToJSON(value['nullableStringEnum']), + 'number-enum': NumberEnumToJSON(value['numberEnum']), + 'nullable-number-enum': NumberEnumToJSON(value['nullableNumberEnum']), }; } diff --git a/samples/client/petstore/typescript-fetch/builds/enum/models/FakeEnumRequestGetInline200Response.ts b/samples/client/petstore/typescript-fetch/builds/enum/models/FakeEnumRequestGetInline200Response.ts index 35bc8a8a8aa7..3ce94b18453f 100644 --- a/samples/client/petstore/typescript-fetch/builds/enum/models/FakeEnumRequestGetInline200Response.ts +++ b/samples/client/petstore/typescript-fetch/builds/enum/models/FakeEnumRequestGetInline200Response.ts @@ -91,9 +91,7 @@ export type FakeEnumRequestGetInline200ResponseNullableNumberEnumEnum = typeof F * Check if a given object implements the FakeEnumRequestGetInline200Response interface. */ export function instanceOfFakeEnumRequestGetInline200Response(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function FakeEnumRequestGetInline200ResponseFromJSON(json: any): FakeEnumRequestGetInline200Response { @@ -101,7 +99,7 @@ export function FakeEnumRequestGetInline200ResponseFromJSON(json: any): FakeEnum } export function FakeEnumRequestGetInline200ResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): FakeEnumRequestGetInline200Response { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -122,10 +120,10 @@ export function FakeEnumRequestGetInline200ResponseToJSON(value?: FakeEnumReques } return { - 'string-enum': value.stringEnum, - 'nullable-string-enum': value.nullableStringEnum, - 'number-enum': value.numberEnum, - 'nullable-number-enum': value.nullableNumberEnum, + 'string-enum': value['stringEnum'], + 'nullable-string-enum': value['nullableStringEnum'], + 'number-enum': value['numberEnum'], + 'nullable-number-enum': value['nullableNumberEnum'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/enum/runtime.ts b/samples/client/petstore/typescript-fetch/builds/enum/runtime.ts index cef607c3fcb5..4f1da922f6df 100644 --- a/samples/client/petstore/typescript-fetch/builds/enum/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/enum/runtime.ts @@ -310,9 +310,9 @@ export interface RequestOpts { body?: HTTPBody; } -export function exists(json: any, key: string) { +export function exists(json: any, key: string): boolean { const value = json[key]; - return value !== null && value !== undefined; + return value !== undefined && value !== null; } export function querystring(params: HTTPQuery, prefix: string = ''): string { diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/src/apis/PetApi.ts b/samples/client/petstore/typescript-fetch/builds/es6-target/src/apis/PetApi.ts index 5f507bceb566..87cab8f993a2 100644 --- a/samples/client/petstore/typescript-fetch/builds/es6-target/src/apis/PetApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/src/apis/PetApi.ts @@ -71,8 +71,11 @@ export class PetApi extends runtime.BaseAPI { * Add a new pet to the store */ async addPetRaw(requestParameters: AddPetRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.body === null || requestParameters.body === undefined) { - throw new runtime.RequiredError('body','Required parameter requestParameters.body was null or undefined when calling addPet.'); + if (!runtime.exists(requestParameters, 'body')) { + throw new runtime.RequiredError( + 'body', + 'Required parameter "body" was null or undefined when calling addPet().' + ); } const queryParameters: any = {}; @@ -91,7 +94,7 @@ export class PetApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, - body: PetToJSON(requestParameters.body), + body: PetToJSON(requestParameters['body']), }, initOverrides); return new runtime.VoidApiResponse(response); @@ -108,16 +111,19 @@ export class PetApi extends runtime.BaseAPI { * Deletes a pet */ async deletePetRaw(requestParameters: DeletePetRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.petId === null || requestParameters.petId === undefined) { - throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling deletePet.'); + if (!runtime.exists(requestParameters, 'petId')) { + throw new runtime.RequiredError( + 'petId', + 'Required parameter "petId" was null or undefined when calling deletePet().' + ); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; - if (requestParameters.apiKey !== undefined && requestParameters.apiKey !== null) { - headerParameters['api_key'] = String(requestParameters.apiKey); + if (runtime.exists(requestParameters, 'apiKey')) { + headerParameters['api_key'] = String(requestParameters['apiKey']); } if (this.configuration && this.configuration.accessToken) { @@ -126,7 +132,7 @@ export class PetApi extends runtime.BaseAPI { } const response = await this.request({ - path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), + path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters['petId']))), method: 'DELETE', headers: headerParameters, query: queryParameters, @@ -147,14 +153,17 @@ export class PetApi extends runtime.BaseAPI { * Finds Pets by status */ async findPetsByStatusRaw(requestParameters: FindPetsByStatusRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>> { - if (requestParameters.status === null || requestParameters.status === undefined) { - throw new runtime.RequiredError('status','Required parameter requestParameters.status was null or undefined when calling findPetsByStatus.'); + if (!runtime.exists(requestParameters, 'status')) { + throw new runtime.RequiredError( + 'status', + 'Required parameter "status" was null or undefined when calling findPetsByStatus().' + ); } const queryParameters: any = {}; - if (requestParameters.status) { - queryParameters['status'] = requestParameters.status.join(runtime.COLLECTION_FORMATS["csv"]); + if (runtime.exists(requestParameters, 'status')) { + queryParameters['status'] = requestParameters['status']!.join(runtime.COLLECTION_FORMATS["csv"]); } const headerParameters: runtime.HTTPHeaders = {}; @@ -189,14 +198,17 @@ export class PetApi extends runtime.BaseAPI { * @deprecated */ async findPetsByTagsRaw(requestParameters: FindPetsByTagsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>> { - if (requestParameters.tags === null || requestParameters.tags === undefined) { - throw new runtime.RequiredError('tags','Required parameter requestParameters.tags was null or undefined when calling findPetsByTags.'); + if (!runtime.exists(requestParameters, 'tags')) { + throw new runtime.RequiredError( + 'tags', + 'Required parameter "tags" was null or undefined when calling findPetsByTags().' + ); } const queryParameters: any = {}; - if (requestParameters.tags) { - queryParameters['tags'] = requestParameters.tags.join(runtime.COLLECTION_FORMATS["csv"]); + if (runtime.exists(requestParameters, 'tags')) { + queryParameters['tags'] = requestParameters['tags']!.join(runtime.COLLECTION_FORMATS["csv"]); } const headerParameters: runtime.HTTPHeaders = {}; @@ -231,8 +243,11 @@ export class PetApi extends runtime.BaseAPI { * Find pet by ID */ async getPetByIdRaw(requestParameters: GetPetByIdRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.petId === null || requestParameters.petId === undefined) { - throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling getPetById.'); + if (!runtime.exists(requestParameters, 'petId')) { + throw new runtime.RequiredError( + 'petId', + 'Required parameter "petId" was null or undefined when calling getPetById().' + ); } const queryParameters: any = {}; @@ -244,7 +259,7 @@ export class PetApi extends runtime.BaseAPI { } const response = await this.request({ - path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), + path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters['petId']))), method: 'GET', headers: headerParameters, query: queryParameters, @@ -266,8 +281,11 @@ export class PetApi extends runtime.BaseAPI { * Update an existing pet */ async updatePetRaw(requestParameters: UpdatePetRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.body === null || requestParameters.body === undefined) { - throw new runtime.RequiredError('body','Required parameter requestParameters.body was null or undefined when calling updatePet.'); + if (!runtime.exists(requestParameters, 'body')) { + throw new runtime.RequiredError( + 'body', + 'Required parameter "body" was null or undefined when calling updatePet().' + ); } const queryParameters: any = {}; @@ -286,7 +304,7 @@ export class PetApi extends runtime.BaseAPI { method: 'PUT', headers: headerParameters, query: queryParameters, - body: PetToJSON(requestParameters.body), + body: PetToJSON(requestParameters['body']), }, initOverrides); return new runtime.VoidApiResponse(response); @@ -303,8 +321,11 @@ export class PetApi extends runtime.BaseAPI { * Updates a pet in the store with form data */ async updatePetWithFormRaw(requestParameters: UpdatePetWithFormRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.petId === null || requestParameters.petId === undefined) { - throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling updatePetWithForm.'); + if (!runtime.exists(requestParameters, 'petId')) { + throw new runtime.RequiredError( + 'petId', + 'Required parameter "petId" was null or undefined when calling updatePetWithForm().' + ); } const queryParameters: any = {}; @@ -330,16 +351,16 @@ export class PetApi extends runtime.BaseAPI { formParams = new URLSearchParams(); } - if (requestParameters.name !== undefined) { - formParams.append('name', requestParameters.name as any); + if (runtime.exists(requestParameters, 'name')) { + formParams.append('name', requestParameters['name'] as any); } - if (requestParameters.status !== undefined) { - formParams.append('status', requestParameters.status as any); + if (runtime.exists(requestParameters, 'status')) { + formParams.append('status', requestParameters['status'] as any); } const response = await this.request({ - path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), + path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters['petId']))), method: 'POST', headers: headerParameters, query: queryParameters, @@ -360,8 +381,11 @@ export class PetApi extends runtime.BaseAPI { * uploads an image */ async uploadFileRaw(requestParameters: UploadFileRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.petId === null || requestParameters.petId === undefined) { - throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling uploadFile.'); + if (!runtime.exists(requestParameters, 'petId')) { + throw new runtime.RequiredError( + 'petId', + 'Required parameter "petId" was null or undefined when calling uploadFile().' + ); } const queryParameters: any = {}; @@ -389,16 +413,16 @@ export class PetApi extends runtime.BaseAPI { formParams = new URLSearchParams(); } - if (requestParameters.additionalMetadata !== undefined) { - formParams.append('additionalMetadata', requestParameters.additionalMetadata as any); + if (runtime.exists(requestParameters, 'additionalMetadata')) { + formParams.append('additionalMetadata', requestParameters['additionalMetadata'] as any); } - if (requestParameters.file !== undefined) { - formParams.append('file', requestParameters.file as any); + if (runtime.exists(requestParameters, 'file')) { + formParams.append('file', requestParameters['file'] as any); } const response = await this.request({ - path: `/pet/{petId}/uploadImage`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), + path: `/pet/{petId}/uploadImage`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters['petId']))), method: 'POST', headers: headerParameters, query: queryParameters, diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/src/apis/StoreApi.ts b/samples/client/petstore/typescript-fetch/builds/es6-target/src/apis/StoreApi.ts index eda5a23e9a8f..74fc267af7da 100644 --- a/samples/client/petstore/typescript-fetch/builds/es6-target/src/apis/StoreApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/src/apis/StoreApi.ts @@ -44,8 +44,11 @@ export class StoreApi extends runtime.BaseAPI { * Delete purchase order by ID */ async deleteOrderRaw(requestParameters: DeleteOrderRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.orderId === null || requestParameters.orderId === undefined) { - throw new runtime.RequiredError('orderId','Required parameter requestParameters.orderId was null or undefined when calling deleteOrder.'); + if (!runtime.exists(requestParameters, 'orderId')) { + throw new runtime.RequiredError( + 'orderId', + 'Required parameter "orderId" was null or undefined when calling deleteOrder().' + ); } const queryParameters: any = {}; @@ -53,7 +56,7 @@ export class StoreApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; const response = await this.request({ - path: `/store/order/{orderId}`.replace(`{${"orderId"}}`, encodeURIComponent(String(requestParameters.orderId))), + path: `/store/order/{orderId}`.replace(`{${"orderId"}}`, encodeURIComponent(String(requestParameters['orderId']))), method: 'DELETE', headers: headerParameters, query: queryParameters, @@ -107,8 +110,11 @@ export class StoreApi extends runtime.BaseAPI { * Find purchase order by ID */ async getOrderByIdRaw(requestParameters: GetOrderByIdRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.orderId === null || requestParameters.orderId === undefined) { - throw new runtime.RequiredError('orderId','Required parameter requestParameters.orderId was null or undefined when calling getOrderById.'); + if (!runtime.exists(requestParameters, 'orderId')) { + throw new runtime.RequiredError( + 'orderId', + 'Required parameter "orderId" was null or undefined when calling getOrderById().' + ); } const queryParameters: any = {}; @@ -116,7 +122,7 @@ export class StoreApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; const response = await this.request({ - path: `/store/order/{orderId}`.replace(`{${"orderId"}}`, encodeURIComponent(String(requestParameters.orderId))), + path: `/store/order/{orderId}`.replace(`{${"orderId"}}`, encodeURIComponent(String(requestParameters['orderId']))), method: 'GET', headers: headerParameters, query: queryParameters, @@ -138,8 +144,11 @@ export class StoreApi extends runtime.BaseAPI { * Place an order for a pet */ async placeOrderRaw(requestParameters: PlaceOrderRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.body === null || requestParameters.body === undefined) { - throw new runtime.RequiredError('body','Required parameter requestParameters.body was null or undefined when calling placeOrder.'); + if (!runtime.exists(requestParameters, 'body')) { + throw new runtime.RequiredError( + 'body', + 'Required parameter "body" was null or undefined when calling placeOrder().' + ); } const queryParameters: any = {}; @@ -153,7 +162,7 @@ export class StoreApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, - body: OrderToJSON(requestParameters.body), + body: OrderToJSON(requestParameters['body']), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => OrderFromJSON(jsonValue)); diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/src/apis/UserApi.ts b/samples/client/petstore/typescript-fetch/builds/es6-target/src/apis/UserApi.ts index 58f6a7e5d3af..565ceefcaab9 100644 --- a/samples/client/petstore/typescript-fetch/builds/es6-target/src/apis/UserApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/src/apis/UserApi.ts @@ -62,8 +62,11 @@ export class UserApi extends runtime.BaseAPI { * Create user */ async createUserRaw(requestParameters: CreateUserRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.body === null || requestParameters.body === undefined) { - throw new runtime.RequiredError('body','Required parameter requestParameters.body was null or undefined when calling createUser.'); + if (!runtime.exists(requestParameters, 'body')) { + throw new runtime.RequiredError( + 'body', + 'Required parameter "body" was null or undefined when calling createUser().' + ); } const queryParameters: any = {}; @@ -77,7 +80,7 @@ export class UserApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, - body: UserToJSON(requestParameters.body), + body: UserToJSON(requestParameters['body']), }, initOverrides); return new runtime.VoidApiResponse(response); @@ -95,8 +98,11 @@ export class UserApi extends runtime.BaseAPI { * Creates list of users with given input array */ async createUsersWithArrayInputRaw(requestParameters: CreateUsersWithArrayInputRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.body === null || requestParameters.body === undefined) { - throw new runtime.RequiredError('body','Required parameter requestParameters.body was null or undefined when calling createUsersWithArrayInput.'); + if (!runtime.exists(requestParameters, 'body')) { + throw new runtime.RequiredError( + 'body', + 'Required parameter "body" was null or undefined when calling createUsersWithArrayInput().' + ); } const queryParameters: any = {}; @@ -110,7 +116,7 @@ export class UserApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, - body: requestParameters.body.map(UserToJSON), + body: requestParameters['body']!.map(UserToJSON), }, initOverrides); return new runtime.VoidApiResponse(response); @@ -127,8 +133,11 @@ export class UserApi extends runtime.BaseAPI { * Creates list of users with given input array */ async createUsersWithListInputRaw(requestParameters: CreateUsersWithListInputRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.body === null || requestParameters.body === undefined) { - throw new runtime.RequiredError('body','Required parameter requestParameters.body was null or undefined when calling createUsersWithListInput.'); + if (!runtime.exists(requestParameters, 'body')) { + throw new runtime.RequiredError( + 'body', + 'Required parameter "body" was null or undefined when calling createUsersWithListInput().' + ); } const queryParameters: any = {}; @@ -142,7 +151,7 @@ export class UserApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, - body: requestParameters.body.map(UserToJSON), + body: requestParameters['body']!.map(UserToJSON), }, initOverrides); return new runtime.VoidApiResponse(response); @@ -160,8 +169,11 @@ export class UserApi extends runtime.BaseAPI { * Delete user */ async deleteUserRaw(requestParameters: DeleteUserRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.username === null || requestParameters.username === undefined) { - throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling deleteUser.'); + if (!runtime.exists(requestParameters, 'username')) { + throw new runtime.RequiredError( + 'username', + 'Required parameter "username" was null or undefined when calling deleteUser().' + ); } const queryParameters: any = {}; @@ -169,7 +181,7 @@ export class UserApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; const response = await this.request({ - path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), + path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters['username']))), method: 'DELETE', headers: headerParameters, query: queryParameters, @@ -190,8 +202,11 @@ export class UserApi extends runtime.BaseAPI { * Get user by user name */ async getUserByNameRaw(requestParameters: GetUserByNameRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.username === null || requestParameters.username === undefined) { - throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling getUserByName.'); + if (!runtime.exists(requestParameters, 'username')) { + throw new runtime.RequiredError( + 'username', + 'Required parameter "username" was null or undefined when calling getUserByName().' + ); } const queryParameters: any = {}; @@ -199,7 +214,7 @@ export class UserApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; const response = await this.request({ - path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), + path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters['username']))), method: 'GET', headers: headerParameters, query: queryParameters, @@ -220,22 +235,28 @@ export class UserApi extends runtime.BaseAPI { * Logs user into the system */ async loginUserRaw(requestParameters: LoginUserRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.username === null || requestParameters.username === undefined) { - throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling loginUser.'); + if (!runtime.exists(requestParameters, 'username')) { + throw new runtime.RequiredError( + 'username', + 'Required parameter "username" was null or undefined when calling loginUser().' + ); } - if (requestParameters.password === null || requestParameters.password === undefined) { - throw new runtime.RequiredError('password','Required parameter requestParameters.password was null or undefined when calling loginUser.'); + if (!runtime.exists(requestParameters, 'password')) { + throw new runtime.RequiredError( + 'password', + 'Required parameter "password" was null or undefined when calling loginUser().' + ); } const queryParameters: any = {}; - if (requestParameters.username !== undefined) { - queryParameters['username'] = requestParameters.username; + if (runtime.exists(requestParameters, 'username')) { + queryParameters['username'] = requestParameters['username']; } - if (requestParameters.password !== undefined) { - queryParameters['password'] = requestParameters.password; + if (runtime.exists(requestParameters, 'password')) { + queryParameters['password'] = requestParameters['password']; } const headerParameters: runtime.HTTPHeaders = {}; @@ -292,12 +313,18 @@ export class UserApi extends runtime.BaseAPI { * Updated user */ async updateUserRaw(requestParameters: UpdateUserRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.username === null || requestParameters.username === undefined) { - throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling updateUser.'); + if (!runtime.exists(requestParameters, 'username')) { + throw new runtime.RequiredError( + 'username', + 'Required parameter "username" was null or undefined when calling updateUser().' + ); } - if (requestParameters.body === null || requestParameters.body === undefined) { - throw new runtime.RequiredError('body','Required parameter requestParameters.body was null or undefined when calling updateUser.'); + if (!runtime.exists(requestParameters, 'body')) { + throw new runtime.RequiredError( + 'body', + 'Required parameter "body" was null or undefined when calling updateUser().' + ); } const queryParameters: any = {}; @@ -307,11 +334,11 @@ export class UserApi extends runtime.BaseAPI { headerParameters['Content-Type'] = 'application/json'; const response = await this.request({ - path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), + path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters['username']))), method: 'PUT', headers: headerParameters, query: queryParameters, - body: UserToJSON(requestParameters.body), + body: UserToJSON(requestParameters['body']), }, initOverrides); return new runtime.VoidApiResponse(response); 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 882567387201..001bc135bb96 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 @@ -37,9 +37,7 @@ export interface Category { * Check if a given object implements the Category interface. */ export function instanceOfCategory(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function CategoryFromJSON(json: any): Category { @@ -47,7 +45,7 @@ export function CategoryFromJSON(json: any): Category { } export function CategoryFromJSONTyped(json: any, ignoreDiscriminator: boolean): Category { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -66,8 +64,8 @@ export function CategoryToJSON(value?: Category | null): any { } return { - 'id': value.id, - 'name': value.name, + '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 bf50981fc2e2..a7fc63d81f1b 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 @@ -43,9 +43,7 @@ export interface ModelApiResponse { * Check if a given object implements the ModelApiResponse interface. */ export function instanceOfModelApiResponse(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function ModelApiResponseFromJSON(json: any): ModelApiResponse { @@ -53,7 +51,7 @@ export function ModelApiResponseFromJSON(json: any): ModelApiResponse { } export function ModelApiResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): ModelApiResponse { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -73,9 +71,9 @@ export function ModelApiResponseToJSON(value?: ModelApiResponse | null): any { } return { - 'code': value.code, - 'type': value.type, - 'message': value.message, + '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 0d69755d4887..9e12fc242793 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 @@ -73,9 +73,7 @@ export type OrderStatusEnum = typeof OrderStatusEnum[keyof typeof OrderStatusEnu * Check if a given object implements the Order interface. */ export function instanceOfOrder(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function OrderFromJSON(json: any): Order { @@ -83,7 +81,7 @@ export function OrderFromJSON(json: any): Order { } export function OrderFromJSONTyped(json: any, ignoreDiscriminator: boolean): Order { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -106,12 +104,12 @@ export function OrderToJSON(value?: Order | null): any { } return { - 'id': value.id, - 'petId': value.petId, - 'quantity': value.quantity, - 'shipDate': value.shipDate === undefined ? undefined : (value.shipDate.toISOString()), - 'status': value.status, - 'complete': value.complete, + 'id': value['id'], + 'petId': value['petId'], + 'quantity': value['quantity'], + 'shipDate': !exists(value, 'shipDate') ? undefined : ((value['shipDate']).toISOString()), + 'status': value['status'], + 'complete': value['complete'], }; } 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 73c70f03a3e5..8906602f6f4b 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 @@ -86,11 +86,9 @@ export type PetStatusEnum = typeof PetStatusEnum[keyof typeof PetStatusEnum]; * Check if a given object implements the Pet interface. */ export function instanceOfPet(value: object): boolean { - let isInstance = true; - isInstance = isInstance && "name" in value; - isInstance = isInstance && "photoUrls" in value; - - return isInstance; + if (!('name' in value)) return false; + if (!('photoUrls' in value)) return false; + return true; } export function PetFromJSON(json: any): Pet { @@ -98,7 +96,7 @@ export function PetFromJSON(json: any): Pet { } export function PetFromJSONTyped(json: any, ignoreDiscriminator: boolean): Pet { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -121,12 +119,12 @@ export function PetToJSON(value?: Pet | null): any { } return { - 'id': value.id, - 'category': CategoryToJSON(value.category), - 'name': value.name, - 'photoUrls': value.photoUrls, - 'tags': value.tags === undefined ? undefined : ((value.tags as Array).map(TagToJSON)), - 'status': value.status, + 'id': value['id'], + 'category': CategoryToJSON(value['category']), + 'name': value['name'], + 'photoUrls': value['photoUrls'], + 'tags': !exists(value, 'tags') ? undefined : ((value['tags'] as Array).map(TagToJSON)), + 'status': value['status'], }; } 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 e4902aa53cfd..24a25f383dba 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 @@ -37,9 +37,7 @@ export interface Tag { * Check if a given object implements the Tag interface. */ export function instanceOfTag(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function TagFromJSON(json: any): Tag { @@ -47,7 +45,7 @@ export function TagFromJSON(json: any): Tag { } export function TagFromJSONTyped(json: any, ignoreDiscriminator: boolean): Tag { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -66,8 +64,8 @@ export function TagToJSON(value?: Tag | null): any { } return { - 'id': value.id, - 'name': value.name, + '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 f22da928907c..00ab35b80563 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 @@ -73,9 +73,7 @@ export interface User { * Check if a given object implements the User interface. */ export function instanceOfUser(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function UserFromJSON(json: any): User { @@ -83,7 +81,7 @@ export function UserFromJSON(json: any): User { } export function UserFromJSONTyped(json: any, ignoreDiscriminator: boolean): User { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -108,14 +106,14 @@ export function UserToJSON(value?: User | null): any { } return { - 'id': value.id, - 'username': value.username, - 'firstName': value.firstName, - 'lastName': value.lastName, - 'email': value.email, - 'password': value.password, - 'phone': value.phone, - 'userStatus': value.userStatus, + 'id': value['id'], + 'username': value['username'], + 'firstName': value['firstName'], + 'lastName': value['lastName'], + 'email': value['email'], + 'password': value['password'], + 'phone': value['phone'], + 'userStatus': value['userStatus'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/src/runtime.ts b/samples/client/petstore/typescript-fetch/builds/es6-target/src/runtime.ts index 71ecdb875d14..813bf0fb4dfe 100644 --- a/samples/client/petstore/typescript-fetch/builds/es6-target/src/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/src/runtime.ts @@ -310,9 +310,9 @@ export interface RequestOpts { body?: HTTPBody; } -export function exists(json: any, key: string) { +export function exists(json: any, key: string): boolean { const value = json[key]; - return value !== null && value !== undefined; + return value !== undefined && value !== null; } export function querystring(params: HTTPQuery, prefix: string = ''): string { diff --git a/samples/client/petstore/typescript-fetch/builds/multiple-parameters/apis/PetApi.ts b/samples/client/petstore/typescript-fetch/builds/multiple-parameters/apis/PetApi.ts index 45628b2738d2..bfef64a126ac 100644 --- a/samples/client/petstore/typescript-fetch/builds/multiple-parameters/apis/PetApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/multiple-parameters/apis/PetApi.ts @@ -71,8 +71,11 @@ export class PetApi extends runtime.BaseAPI { * Add a new pet to the store */ async addPetRaw(requestParameters: AddPetRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.body === null || requestParameters.body === undefined) { - throw new runtime.RequiredError('body','Required parameter requestParameters.body was null or undefined when calling addPet.'); + if (!runtime.exists(requestParameters, 'body')) { + throw new runtime.RequiredError( + 'body', + 'Required parameter "body" was null or undefined when calling addPet().' + ); } const queryParameters: any = {}; @@ -91,7 +94,7 @@ export class PetApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, - body: PetToJSON(requestParameters.body), + body: PetToJSON(requestParameters['body']), }, initOverrides); return new runtime.VoidApiResponse(response); @@ -108,16 +111,19 @@ export class PetApi extends runtime.BaseAPI { * Deletes a pet */ async deletePetRaw(requestParameters: DeletePetRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.petId === null || requestParameters.petId === undefined) { - throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling deletePet.'); + if (!runtime.exists(requestParameters, 'petId')) { + throw new runtime.RequiredError( + 'petId', + 'Required parameter "petId" was null or undefined when calling deletePet().' + ); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; - if (requestParameters.apiKey !== undefined && requestParameters.apiKey !== null) { - headerParameters['api_key'] = String(requestParameters.apiKey); + if (runtime.exists(requestParameters, 'apiKey')) { + headerParameters['api_key'] = String(requestParameters['apiKey']); } if (this.configuration && this.configuration.accessToken) { @@ -126,7 +132,7 @@ export class PetApi extends runtime.BaseAPI { } const response = await this.request({ - path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), + path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters['petId']))), method: 'DELETE', headers: headerParameters, query: queryParameters, @@ -147,14 +153,17 @@ export class PetApi extends runtime.BaseAPI { * Finds Pets by status */ async findPetsByStatusRaw(requestParameters: FindPetsByStatusRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>> { - if (requestParameters.status === null || requestParameters.status === undefined) { - throw new runtime.RequiredError('status','Required parameter requestParameters.status was null or undefined when calling findPetsByStatus.'); + if (!runtime.exists(requestParameters, 'status')) { + throw new runtime.RequiredError( + 'status', + 'Required parameter "status" was null or undefined when calling findPetsByStatus().' + ); } const queryParameters: any = {}; - if (requestParameters.status) { - queryParameters['status'] = requestParameters.status.join(runtime.COLLECTION_FORMATS["csv"]); + if (runtime.exists(requestParameters, 'status')) { + queryParameters['status'] = requestParameters['status']!.join(runtime.COLLECTION_FORMATS["csv"]); } const headerParameters: runtime.HTTPHeaders = {}; @@ -189,14 +198,17 @@ export class PetApi extends runtime.BaseAPI { * @deprecated */ async findPetsByTagsRaw(requestParameters: FindPetsByTagsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>> { - if (requestParameters.tags === null || requestParameters.tags === undefined) { - throw new runtime.RequiredError('tags','Required parameter requestParameters.tags was null or undefined when calling findPetsByTags.'); + if (!runtime.exists(requestParameters, 'tags')) { + throw new runtime.RequiredError( + 'tags', + 'Required parameter "tags" was null or undefined when calling findPetsByTags().' + ); } const queryParameters: any = {}; - if (requestParameters.tags) { - queryParameters['tags'] = requestParameters.tags.join(runtime.COLLECTION_FORMATS["csv"]); + if (runtime.exists(requestParameters, 'tags')) { + queryParameters['tags'] = requestParameters['tags']!.join(runtime.COLLECTION_FORMATS["csv"]); } const headerParameters: runtime.HTTPHeaders = {}; @@ -231,8 +243,11 @@ export class PetApi extends runtime.BaseAPI { * Find pet by ID */ async getPetByIdRaw(requestParameters: GetPetByIdRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.petId === null || requestParameters.petId === undefined) { - throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling getPetById.'); + if (!runtime.exists(requestParameters, 'petId')) { + throw new runtime.RequiredError( + 'petId', + 'Required parameter "petId" was null or undefined when calling getPetById().' + ); } const queryParameters: any = {}; @@ -244,7 +259,7 @@ export class PetApi extends runtime.BaseAPI { } const response = await this.request({ - path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), + path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters['petId']))), method: 'GET', headers: headerParameters, query: queryParameters, @@ -266,8 +281,11 @@ export class PetApi extends runtime.BaseAPI { * Update an existing pet */ async updatePetRaw(requestParameters: UpdatePetRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.body === null || requestParameters.body === undefined) { - throw new runtime.RequiredError('body','Required parameter requestParameters.body was null or undefined when calling updatePet.'); + if (!runtime.exists(requestParameters, 'body')) { + throw new runtime.RequiredError( + 'body', + 'Required parameter "body" was null or undefined when calling updatePet().' + ); } const queryParameters: any = {}; @@ -286,7 +304,7 @@ export class PetApi extends runtime.BaseAPI { method: 'PUT', headers: headerParameters, query: queryParameters, - body: PetToJSON(requestParameters.body), + body: PetToJSON(requestParameters['body']), }, initOverrides); return new runtime.VoidApiResponse(response); @@ -303,8 +321,11 @@ export class PetApi extends runtime.BaseAPI { * Updates a pet in the store with form data */ async updatePetWithFormRaw(requestParameters: UpdatePetWithFormRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.petId === null || requestParameters.petId === undefined) { - throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling updatePetWithForm.'); + if (!runtime.exists(requestParameters, 'petId')) { + throw new runtime.RequiredError( + 'petId', + 'Required parameter "petId" was null or undefined when calling updatePetWithForm().' + ); } const queryParameters: any = {}; @@ -330,16 +351,16 @@ export class PetApi extends runtime.BaseAPI { formParams = new URLSearchParams(); } - if (requestParameters.name !== undefined) { - formParams.append('name', requestParameters.name as any); + if (runtime.exists(requestParameters, 'name')) { + formParams.append('name', requestParameters['name'] as any); } - if (requestParameters.status !== undefined) { - formParams.append('status', requestParameters.status as any); + if (runtime.exists(requestParameters, 'status')) { + formParams.append('status', requestParameters['status'] as any); } const response = await this.request({ - path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), + path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters['petId']))), method: 'POST', headers: headerParameters, query: queryParameters, @@ -360,8 +381,11 @@ export class PetApi extends runtime.BaseAPI { * uploads an image */ async uploadFileRaw(requestParameters: UploadFileRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.petId === null || requestParameters.petId === undefined) { - throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling uploadFile.'); + if (!runtime.exists(requestParameters, 'petId')) { + throw new runtime.RequiredError( + 'petId', + 'Required parameter "petId" was null or undefined when calling uploadFile().' + ); } const queryParameters: any = {}; @@ -389,16 +413,16 @@ export class PetApi extends runtime.BaseAPI { formParams = new URLSearchParams(); } - if (requestParameters.additionalMetadata !== undefined) { - formParams.append('additionalMetadata', requestParameters.additionalMetadata as any); + if (runtime.exists(requestParameters, 'additionalMetadata')) { + formParams.append('additionalMetadata', requestParameters['additionalMetadata'] as any); } - if (requestParameters.file !== undefined) { - formParams.append('file', requestParameters.file as any); + if (runtime.exists(requestParameters, 'file')) { + formParams.append('file', requestParameters['file'] as any); } const response = await this.request({ - path: `/pet/{petId}/uploadImage`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), + path: `/pet/{petId}/uploadImage`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters['petId']))), method: 'POST', headers: headerParameters, query: queryParameters, diff --git a/samples/client/petstore/typescript-fetch/builds/multiple-parameters/apis/StoreApi.ts b/samples/client/petstore/typescript-fetch/builds/multiple-parameters/apis/StoreApi.ts index 97d90e388f30..71f08a8daed8 100644 --- a/samples/client/petstore/typescript-fetch/builds/multiple-parameters/apis/StoreApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/multiple-parameters/apis/StoreApi.ts @@ -44,8 +44,11 @@ export class StoreApi extends runtime.BaseAPI { * Delete purchase order by ID */ async deleteOrderRaw(requestParameters: DeleteOrderRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.orderId === null || requestParameters.orderId === undefined) { - throw new runtime.RequiredError('orderId','Required parameter requestParameters.orderId was null or undefined when calling deleteOrder.'); + if (!runtime.exists(requestParameters, 'orderId')) { + throw new runtime.RequiredError( + 'orderId', + 'Required parameter "orderId" was null or undefined when calling deleteOrder().' + ); } const queryParameters: any = {}; @@ -53,7 +56,7 @@ export class StoreApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; const response = await this.request({ - path: `/store/order/{orderId}`.replace(`{${"orderId"}}`, encodeURIComponent(String(requestParameters.orderId))), + path: `/store/order/{orderId}`.replace(`{${"orderId"}}`, encodeURIComponent(String(requestParameters['orderId']))), method: 'DELETE', headers: headerParameters, query: queryParameters, @@ -107,8 +110,11 @@ export class StoreApi extends runtime.BaseAPI { * Find purchase order by ID */ async getOrderByIdRaw(requestParameters: GetOrderByIdRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.orderId === null || requestParameters.orderId === undefined) { - throw new runtime.RequiredError('orderId','Required parameter requestParameters.orderId was null or undefined when calling getOrderById.'); + if (!runtime.exists(requestParameters, 'orderId')) { + throw new runtime.RequiredError( + 'orderId', + 'Required parameter "orderId" was null or undefined when calling getOrderById().' + ); } const queryParameters: any = {}; @@ -116,7 +122,7 @@ export class StoreApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; const response = await this.request({ - path: `/store/order/{orderId}`.replace(`{${"orderId"}}`, encodeURIComponent(String(requestParameters.orderId))), + path: `/store/order/{orderId}`.replace(`{${"orderId"}}`, encodeURIComponent(String(requestParameters['orderId']))), method: 'GET', headers: headerParameters, query: queryParameters, @@ -138,8 +144,11 @@ export class StoreApi extends runtime.BaseAPI { * Place an order for a pet */ async placeOrderRaw(requestParameters: PlaceOrderRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.body === null || requestParameters.body === undefined) { - throw new runtime.RequiredError('body','Required parameter requestParameters.body was null or undefined when calling placeOrder.'); + if (!runtime.exists(requestParameters, 'body')) { + throw new runtime.RequiredError( + 'body', + 'Required parameter "body" was null or undefined when calling placeOrder().' + ); } const queryParameters: any = {}; @@ -153,7 +162,7 @@ export class StoreApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, - body: OrderToJSON(requestParameters.body), + body: OrderToJSON(requestParameters['body']), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => OrderFromJSON(jsonValue)); diff --git a/samples/client/petstore/typescript-fetch/builds/multiple-parameters/apis/UserApi.ts b/samples/client/petstore/typescript-fetch/builds/multiple-parameters/apis/UserApi.ts index 4397fef0a0eb..49ed31f55b8f 100644 --- a/samples/client/petstore/typescript-fetch/builds/multiple-parameters/apis/UserApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/multiple-parameters/apis/UserApi.ts @@ -62,8 +62,11 @@ export class UserApi extends runtime.BaseAPI { * Create user */ async createUserRaw(requestParameters: CreateUserRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.body === null || requestParameters.body === undefined) { - throw new runtime.RequiredError('body','Required parameter requestParameters.body was null or undefined when calling createUser.'); + if (!runtime.exists(requestParameters, 'body')) { + throw new runtime.RequiredError( + 'body', + 'Required parameter "body" was null or undefined when calling createUser().' + ); } const queryParameters: any = {}; @@ -77,7 +80,7 @@ export class UserApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, - body: UserToJSON(requestParameters.body), + body: UserToJSON(requestParameters['body']), }, initOverrides); return new runtime.VoidApiResponse(response); @@ -95,8 +98,11 @@ export class UserApi extends runtime.BaseAPI { * Creates list of users with given input array */ async createUsersWithArrayInputRaw(requestParameters: CreateUsersWithArrayInputRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.body === null || requestParameters.body === undefined) { - throw new runtime.RequiredError('body','Required parameter requestParameters.body was null or undefined when calling createUsersWithArrayInput.'); + if (!runtime.exists(requestParameters, 'body')) { + throw new runtime.RequiredError( + 'body', + 'Required parameter "body" was null or undefined when calling createUsersWithArrayInput().' + ); } const queryParameters: any = {}; @@ -110,7 +116,7 @@ export class UserApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, - body: requestParameters.body.map(UserToJSON), + body: requestParameters['body']!.map(UserToJSON), }, initOverrides); return new runtime.VoidApiResponse(response); @@ -127,8 +133,11 @@ export class UserApi extends runtime.BaseAPI { * Creates list of users with given input array */ async createUsersWithListInputRaw(requestParameters: CreateUsersWithListInputRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.body === null || requestParameters.body === undefined) { - throw new runtime.RequiredError('body','Required parameter requestParameters.body was null or undefined when calling createUsersWithListInput.'); + if (!runtime.exists(requestParameters, 'body')) { + throw new runtime.RequiredError( + 'body', + 'Required parameter "body" was null or undefined when calling createUsersWithListInput().' + ); } const queryParameters: any = {}; @@ -142,7 +151,7 @@ export class UserApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, - body: requestParameters.body.map(UserToJSON), + body: requestParameters['body']!.map(UserToJSON), }, initOverrides); return new runtime.VoidApiResponse(response); @@ -160,8 +169,11 @@ export class UserApi extends runtime.BaseAPI { * Delete user */ async deleteUserRaw(requestParameters: DeleteUserRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.username === null || requestParameters.username === undefined) { - throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling deleteUser.'); + if (!runtime.exists(requestParameters, 'username')) { + throw new runtime.RequiredError( + 'username', + 'Required parameter "username" was null or undefined when calling deleteUser().' + ); } const queryParameters: any = {}; @@ -169,7 +181,7 @@ export class UserApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; const response = await this.request({ - path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), + path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters['username']))), method: 'DELETE', headers: headerParameters, query: queryParameters, @@ -190,8 +202,11 @@ export class UserApi extends runtime.BaseAPI { * Get user by user name */ async getUserByNameRaw(requestParameters: GetUserByNameRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.username === null || requestParameters.username === undefined) { - throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling getUserByName.'); + if (!runtime.exists(requestParameters, 'username')) { + throw new runtime.RequiredError( + 'username', + 'Required parameter "username" was null or undefined when calling getUserByName().' + ); } const queryParameters: any = {}; @@ -199,7 +214,7 @@ export class UserApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; const response = await this.request({ - path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), + path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters['username']))), method: 'GET', headers: headerParameters, query: queryParameters, @@ -220,22 +235,28 @@ export class UserApi extends runtime.BaseAPI { * Logs user into the system */ async loginUserRaw(requestParameters: LoginUserRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.username === null || requestParameters.username === undefined) { - throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling loginUser.'); + if (!runtime.exists(requestParameters, 'username')) { + throw new runtime.RequiredError( + 'username', + 'Required parameter "username" was null or undefined when calling loginUser().' + ); } - if (requestParameters.password === null || requestParameters.password === undefined) { - throw new runtime.RequiredError('password','Required parameter requestParameters.password was null or undefined when calling loginUser.'); + if (!runtime.exists(requestParameters, 'password')) { + throw new runtime.RequiredError( + 'password', + 'Required parameter "password" was null or undefined when calling loginUser().' + ); } const queryParameters: any = {}; - if (requestParameters.username !== undefined) { - queryParameters['username'] = requestParameters.username; + if (runtime.exists(requestParameters, 'username')) { + queryParameters['username'] = requestParameters['username']; } - if (requestParameters.password !== undefined) { - queryParameters['password'] = requestParameters.password; + if (runtime.exists(requestParameters, 'password')) { + queryParameters['password'] = requestParameters['password']; } const headerParameters: runtime.HTTPHeaders = {}; @@ -292,12 +313,18 @@ export class UserApi extends runtime.BaseAPI { * Updated user */ async updateUserRaw(requestParameters: UpdateUserRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.username === null || requestParameters.username === undefined) { - throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling updateUser.'); + if (!runtime.exists(requestParameters, 'username')) { + throw new runtime.RequiredError( + 'username', + 'Required parameter "username" was null or undefined when calling updateUser().' + ); } - if (requestParameters.body === null || requestParameters.body === undefined) { - throw new runtime.RequiredError('body','Required parameter requestParameters.body was null or undefined when calling updateUser.'); + if (!runtime.exists(requestParameters, 'body')) { + throw new runtime.RequiredError( + 'body', + 'Required parameter "body" was null or undefined when calling updateUser().' + ); } const queryParameters: any = {}; @@ -307,11 +334,11 @@ export class UserApi extends runtime.BaseAPI { headerParameters['Content-Type'] = 'application/json'; const response = await this.request({ - path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), + path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters['username']))), method: 'PUT', headers: headerParameters, query: queryParameters, - body: UserToJSON(requestParameters.body), + body: UserToJSON(requestParameters['body']), }, initOverrides); return new runtime.VoidApiResponse(response); diff --git a/samples/client/petstore/typescript-fetch/builds/multiple-parameters/models/Category.ts b/samples/client/petstore/typescript-fetch/builds/multiple-parameters/models/Category.ts index 882567387201..001bc135bb96 100644 --- a/samples/client/petstore/typescript-fetch/builds/multiple-parameters/models/Category.ts +++ b/samples/client/petstore/typescript-fetch/builds/multiple-parameters/models/Category.ts @@ -37,9 +37,7 @@ export interface Category { * Check if a given object implements the Category interface. */ export function instanceOfCategory(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function CategoryFromJSON(json: any): Category { @@ -47,7 +45,7 @@ export function CategoryFromJSON(json: any): Category { } export function CategoryFromJSONTyped(json: any, ignoreDiscriminator: boolean): Category { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -66,8 +64,8 @@ export function CategoryToJSON(value?: Category | null): any { } return { - 'id': value.id, - 'name': value.name, + 'id': value['id'], + 'name': value['name'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/multiple-parameters/models/ModelApiResponse.ts b/samples/client/petstore/typescript-fetch/builds/multiple-parameters/models/ModelApiResponse.ts index bf50981fc2e2..a7fc63d81f1b 100644 --- a/samples/client/petstore/typescript-fetch/builds/multiple-parameters/models/ModelApiResponse.ts +++ b/samples/client/petstore/typescript-fetch/builds/multiple-parameters/models/ModelApiResponse.ts @@ -43,9 +43,7 @@ export interface ModelApiResponse { * Check if a given object implements the ModelApiResponse interface. */ export function instanceOfModelApiResponse(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function ModelApiResponseFromJSON(json: any): ModelApiResponse { @@ -53,7 +51,7 @@ export function ModelApiResponseFromJSON(json: any): ModelApiResponse { } export function ModelApiResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): ModelApiResponse { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -73,9 +71,9 @@ export function ModelApiResponseToJSON(value?: ModelApiResponse | null): any { } return { - 'code': value.code, - 'type': value.type, - 'message': value.message, + 'code': value['code'], + 'type': value['type'], + 'message': value['message'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/multiple-parameters/models/Order.ts b/samples/client/petstore/typescript-fetch/builds/multiple-parameters/models/Order.ts index 0d69755d4887..9e12fc242793 100644 --- a/samples/client/petstore/typescript-fetch/builds/multiple-parameters/models/Order.ts +++ b/samples/client/petstore/typescript-fetch/builds/multiple-parameters/models/Order.ts @@ -73,9 +73,7 @@ export type OrderStatusEnum = typeof OrderStatusEnum[keyof typeof OrderStatusEnu * Check if a given object implements the Order interface. */ export function instanceOfOrder(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function OrderFromJSON(json: any): Order { @@ -83,7 +81,7 @@ export function OrderFromJSON(json: any): Order { } export function OrderFromJSONTyped(json: any, ignoreDiscriminator: boolean): Order { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -106,12 +104,12 @@ export function OrderToJSON(value?: Order | null): any { } return { - 'id': value.id, - 'petId': value.petId, - 'quantity': value.quantity, - 'shipDate': value.shipDate === undefined ? undefined : (value.shipDate.toISOString()), - 'status': value.status, - 'complete': value.complete, + 'id': value['id'], + 'petId': value['petId'], + 'quantity': value['quantity'], + 'shipDate': !exists(value, 'shipDate') ? undefined : ((value['shipDate']).toISOString()), + 'status': value['status'], + 'complete': value['complete'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/multiple-parameters/models/Pet.ts b/samples/client/petstore/typescript-fetch/builds/multiple-parameters/models/Pet.ts index 73c70f03a3e5..8906602f6f4b 100644 --- a/samples/client/petstore/typescript-fetch/builds/multiple-parameters/models/Pet.ts +++ b/samples/client/petstore/typescript-fetch/builds/multiple-parameters/models/Pet.ts @@ -86,11 +86,9 @@ export type PetStatusEnum = typeof PetStatusEnum[keyof typeof PetStatusEnum]; * Check if a given object implements the Pet interface. */ export function instanceOfPet(value: object): boolean { - let isInstance = true; - isInstance = isInstance && "name" in value; - isInstance = isInstance && "photoUrls" in value; - - return isInstance; + if (!('name' in value)) return false; + if (!('photoUrls' in value)) return false; + return true; } export function PetFromJSON(json: any): Pet { @@ -98,7 +96,7 @@ export function PetFromJSON(json: any): Pet { } export function PetFromJSONTyped(json: any, ignoreDiscriminator: boolean): Pet { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -121,12 +119,12 @@ export function PetToJSON(value?: Pet | null): any { } return { - 'id': value.id, - 'category': CategoryToJSON(value.category), - 'name': value.name, - 'photoUrls': value.photoUrls, - 'tags': value.tags === undefined ? undefined : ((value.tags as Array).map(TagToJSON)), - 'status': value.status, + 'id': value['id'], + 'category': CategoryToJSON(value['category']), + 'name': value['name'], + 'photoUrls': value['photoUrls'], + 'tags': !exists(value, 'tags') ? undefined : ((value['tags'] as Array).map(TagToJSON)), + 'status': value['status'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/multiple-parameters/models/Tag.ts b/samples/client/petstore/typescript-fetch/builds/multiple-parameters/models/Tag.ts index e4902aa53cfd..24a25f383dba 100644 --- a/samples/client/petstore/typescript-fetch/builds/multiple-parameters/models/Tag.ts +++ b/samples/client/petstore/typescript-fetch/builds/multiple-parameters/models/Tag.ts @@ -37,9 +37,7 @@ export interface Tag { * Check if a given object implements the Tag interface. */ export function instanceOfTag(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function TagFromJSON(json: any): Tag { @@ -47,7 +45,7 @@ export function TagFromJSON(json: any): Tag { } export function TagFromJSONTyped(json: any, ignoreDiscriminator: boolean): Tag { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -66,8 +64,8 @@ export function TagToJSON(value?: Tag | null): any { } return { - 'id': value.id, - 'name': value.name, + 'id': value['id'], + 'name': value['name'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/multiple-parameters/models/User.ts b/samples/client/petstore/typescript-fetch/builds/multiple-parameters/models/User.ts index f22da928907c..00ab35b80563 100644 --- a/samples/client/petstore/typescript-fetch/builds/multiple-parameters/models/User.ts +++ b/samples/client/petstore/typescript-fetch/builds/multiple-parameters/models/User.ts @@ -73,9 +73,7 @@ export interface User { * Check if a given object implements the User interface. */ export function instanceOfUser(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function UserFromJSON(json: any): User { @@ -83,7 +81,7 @@ export function UserFromJSON(json: any): User { } export function UserFromJSONTyped(json: any, ignoreDiscriminator: boolean): User { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -108,14 +106,14 @@ export function UserToJSON(value?: User | null): any { } return { - 'id': value.id, - 'username': value.username, - 'firstName': value.firstName, - 'lastName': value.lastName, - 'email': value.email, - 'password': value.password, - 'phone': value.phone, - 'userStatus': value.userStatus, + 'id': value['id'], + 'username': value['username'], + 'firstName': value['firstName'], + 'lastName': value['lastName'], + 'email': value['email'], + 'password': value['password'], + 'phone': value['phone'], + 'userStatus': value['userStatus'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/multiple-parameters/runtime.ts b/samples/client/petstore/typescript-fetch/builds/multiple-parameters/runtime.ts index 71ecdb875d14..813bf0fb4dfe 100644 --- a/samples/client/petstore/typescript-fetch/builds/multiple-parameters/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/multiple-parameters/runtime.ts @@ -310,9 +310,9 @@ export interface RequestOpts { body?: HTTPBody; } -export function exists(json: any, key: string) { +export function exists(json: any, key: string): boolean { const value = json[key]; - return value !== null && value !== undefined; + return value !== undefined && value !== null; } export function querystring(params: HTTPQuery, prefix: string = ''): string { diff --git a/samples/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces/src/apis/PetApi.ts b/samples/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces/src/apis/PetApi.ts index 47c11d68ca95..c1e5d3f61069 100644 --- a/samples/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces/src/apis/PetApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces/src/apis/PetApi.ts @@ -71,8 +71,11 @@ export class PetApi extends runtime.BaseAPI { * Add a new pet to the store */ async addPetRaw(requestParameters: PetApiAddPetRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.body === null || requestParameters.body === undefined) { - throw new runtime.RequiredError('body','Required parameter requestParameters.body was null or undefined when calling addPet.'); + if (!runtime.exists(requestParameters, 'body')) { + throw new runtime.RequiredError( + 'body', + 'Required parameter "body" was null or undefined when calling addPet().' + ); } const queryParameters: any = {}; @@ -91,7 +94,7 @@ export class PetApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, - body: PetToJSON(requestParameters.body), + body: PetToJSON(requestParameters['body']), }, initOverrides); return new runtime.VoidApiResponse(response); @@ -108,16 +111,19 @@ export class PetApi extends runtime.BaseAPI { * Deletes a pet */ async deletePetRaw(requestParameters: PetApiDeletePetRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.petId === null || requestParameters.petId === undefined) { - throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling deletePet.'); + if (!runtime.exists(requestParameters, 'petId')) { + throw new runtime.RequiredError( + 'petId', + 'Required parameter "petId" was null or undefined when calling deletePet().' + ); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; - if (requestParameters.apiKey !== undefined && requestParameters.apiKey !== null) { - headerParameters['api_key'] = String(requestParameters.apiKey); + if (runtime.exists(requestParameters, 'apiKey')) { + headerParameters['api_key'] = String(requestParameters['apiKey']); } if (this.configuration && this.configuration.accessToken) { @@ -126,7 +132,7 @@ export class PetApi extends runtime.BaseAPI { } const response = await this.request({ - path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), + path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters['petId']))), method: 'DELETE', headers: headerParameters, query: queryParameters, @@ -147,14 +153,17 @@ export class PetApi extends runtime.BaseAPI { * Finds Pets by status */ async findPetsByStatusRaw(requestParameters: PetApiFindPetsByStatusRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>> { - if (requestParameters.status === null || requestParameters.status === undefined) { - throw new runtime.RequiredError('status','Required parameter requestParameters.status was null or undefined when calling findPetsByStatus.'); + if (!runtime.exists(requestParameters, 'status')) { + throw new runtime.RequiredError( + 'status', + 'Required parameter "status" was null or undefined when calling findPetsByStatus().' + ); } const queryParameters: any = {}; - if (requestParameters.status) { - queryParameters['status'] = requestParameters.status.join(runtime.COLLECTION_FORMATS["csv"]); + if (runtime.exists(requestParameters, 'status')) { + queryParameters['status'] = requestParameters['status']!.join(runtime.COLLECTION_FORMATS["csv"]); } const headerParameters: runtime.HTTPHeaders = {}; @@ -189,14 +198,17 @@ export class PetApi extends runtime.BaseAPI { * @deprecated */ async findPetsByTagsRaw(requestParameters: PetApiFindPetsByTagsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>> { - if (requestParameters.tags === null || requestParameters.tags === undefined) { - throw new runtime.RequiredError('tags','Required parameter requestParameters.tags was null or undefined when calling findPetsByTags.'); + if (!runtime.exists(requestParameters, 'tags')) { + throw new runtime.RequiredError( + 'tags', + 'Required parameter "tags" was null or undefined when calling findPetsByTags().' + ); } const queryParameters: any = {}; - if (requestParameters.tags) { - queryParameters['tags'] = requestParameters.tags.join(runtime.COLLECTION_FORMATS["csv"]); + if (runtime.exists(requestParameters, 'tags')) { + queryParameters['tags'] = requestParameters['tags']!.join(runtime.COLLECTION_FORMATS["csv"]); } const headerParameters: runtime.HTTPHeaders = {}; @@ -231,8 +243,11 @@ export class PetApi extends runtime.BaseAPI { * Find pet by ID */ async getPetByIdRaw(requestParameters: PetApiGetPetByIdRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.petId === null || requestParameters.petId === undefined) { - throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling getPetById.'); + if (!runtime.exists(requestParameters, 'petId')) { + throw new runtime.RequiredError( + 'petId', + 'Required parameter "petId" was null or undefined when calling getPetById().' + ); } const queryParameters: any = {}; @@ -244,7 +259,7 @@ export class PetApi extends runtime.BaseAPI { } const response = await this.request({ - path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), + path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters['petId']))), method: 'GET', headers: headerParameters, query: queryParameters, @@ -266,8 +281,11 @@ export class PetApi extends runtime.BaseAPI { * Update an existing pet */ async updatePetRaw(requestParameters: PetApiUpdatePetRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.body === null || requestParameters.body === undefined) { - throw new runtime.RequiredError('body','Required parameter requestParameters.body was null or undefined when calling updatePet.'); + if (!runtime.exists(requestParameters, 'body')) { + throw new runtime.RequiredError( + 'body', + 'Required parameter "body" was null or undefined when calling updatePet().' + ); } const queryParameters: any = {}; @@ -286,7 +304,7 @@ export class PetApi extends runtime.BaseAPI { method: 'PUT', headers: headerParameters, query: queryParameters, - body: PetToJSON(requestParameters.body), + body: PetToJSON(requestParameters['body']), }, initOverrides); return new runtime.VoidApiResponse(response); @@ -303,8 +321,11 @@ export class PetApi extends runtime.BaseAPI { * Updates a pet in the store with form data */ async updatePetWithFormRaw(requestParameters: PetApiUpdatePetWithFormRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.petId === null || requestParameters.petId === undefined) { - throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling updatePetWithForm.'); + if (!runtime.exists(requestParameters, 'petId')) { + throw new runtime.RequiredError( + 'petId', + 'Required parameter "petId" was null or undefined when calling updatePetWithForm().' + ); } const queryParameters: any = {}; @@ -330,16 +351,16 @@ export class PetApi extends runtime.BaseAPI { formParams = new URLSearchParams(); } - if (requestParameters.name !== undefined) { - formParams.append('name', requestParameters.name as any); + if (runtime.exists(requestParameters, 'name')) { + formParams.append('name', requestParameters['name'] as any); } - if (requestParameters.status !== undefined) { - formParams.append('status', requestParameters.status as any); + if (runtime.exists(requestParameters, 'status')) { + formParams.append('status', requestParameters['status'] as any); } const response = await this.request({ - path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), + path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters['petId']))), method: 'POST', headers: headerParameters, query: queryParameters, @@ -360,8 +381,11 @@ export class PetApi extends runtime.BaseAPI { * uploads an image */ async uploadFileRaw(requestParameters: PetApiUploadFileRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.petId === null || requestParameters.petId === undefined) { - throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling uploadFile.'); + if (!runtime.exists(requestParameters, 'petId')) { + throw new runtime.RequiredError( + 'petId', + 'Required parameter "petId" was null or undefined when calling uploadFile().' + ); } const queryParameters: any = {}; @@ -389,16 +413,16 @@ export class PetApi extends runtime.BaseAPI { formParams = new URLSearchParams(); } - if (requestParameters.additionalMetadata !== undefined) { - formParams.append('additionalMetadata', requestParameters.additionalMetadata as any); + if (runtime.exists(requestParameters, 'additionalMetadata')) { + formParams.append('additionalMetadata', requestParameters['additionalMetadata'] as any); } - if (requestParameters.file !== undefined) { - formParams.append('file', requestParameters.file as any); + if (runtime.exists(requestParameters, 'file')) { + formParams.append('file', requestParameters['file'] as any); } const response = await this.request({ - path: `/pet/{petId}/uploadImage`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), + path: `/pet/{petId}/uploadImage`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters['petId']))), method: 'POST', headers: headerParameters, query: queryParameters, diff --git a/samples/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces/src/apis/StoreApi.ts b/samples/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces/src/apis/StoreApi.ts index 3af1283917aa..c4166be39728 100644 --- a/samples/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces/src/apis/StoreApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces/src/apis/StoreApi.ts @@ -44,8 +44,11 @@ export class StoreApi extends runtime.BaseAPI { * Delete purchase order by ID */ async deleteOrderRaw(requestParameters: StoreApiDeleteOrderRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.orderId === null || requestParameters.orderId === undefined) { - throw new runtime.RequiredError('orderId','Required parameter requestParameters.orderId was null or undefined when calling deleteOrder.'); + if (!runtime.exists(requestParameters, 'orderId')) { + throw new runtime.RequiredError( + 'orderId', + 'Required parameter "orderId" was null or undefined when calling deleteOrder().' + ); } const queryParameters: any = {}; @@ -53,7 +56,7 @@ export class StoreApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; const response = await this.request({ - path: `/store/order/{orderId}`.replace(`{${"orderId"}}`, encodeURIComponent(String(requestParameters.orderId))), + path: `/store/order/{orderId}`.replace(`{${"orderId"}}`, encodeURIComponent(String(requestParameters['orderId']))), method: 'DELETE', headers: headerParameters, query: queryParameters, @@ -107,8 +110,11 @@ export class StoreApi extends runtime.BaseAPI { * Find purchase order by ID */ async getOrderByIdRaw(requestParameters: StoreApiGetOrderByIdRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.orderId === null || requestParameters.orderId === undefined) { - throw new runtime.RequiredError('orderId','Required parameter requestParameters.orderId was null or undefined when calling getOrderById.'); + if (!runtime.exists(requestParameters, 'orderId')) { + throw new runtime.RequiredError( + 'orderId', + 'Required parameter "orderId" was null or undefined when calling getOrderById().' + ); } const queryParameters: any = {}; @@ -116,7 +122,7 @@ export class StoreApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; const response = await this.request({ - path: `/store/order/{orderId}`.replace(`{${"orderId"}}`, encodeURIComponent(String(requestParameters.orderId))), + path: `/store/order/{orderId}`.replace(`{${"orderId"}}`, encodeURIComponent(String(requestParameters['orderId']))), method: 'GET', headers: headerParameters, query: queryParameters, @@ -138,8 +144,11 @@ export class StoreApi extends runtime.BaseAPI { * Place an order for a pet */ async placeOrderRaw(requestParameters: StoreApiPlaceOrderRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.body === null || requestParameters.body === undefined) { - throw new runtime.RequiredError('body','Required parameter requestParameters.body was null or undefined when calling placeOrder.'); + if (!runtime.exists(requestParameters, 'body')) { + throw new runtime.RequiredError( + 'body', + 'Required parameter "body" was null or undefined when calling placeOrder().' + ); } const queryParameters: any = {}; @@ -153,7 +162,7 @@ export class StoreApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, - body: OrderToJSON(requestParameters.body), + body: OrderToJSON(requestParameters['body']), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => OrderFromJSON(jsonValue)); diff --git a/samples/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces/src/apis/UserApi.ts b/samples/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces/src/apis/UserApi.ts index 9738d83f9c64..c0830aaf5bee 100644 --- a/samples/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces/src/apis/UserApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces/src/apis/UserApi.ts @@ -62,8 +62,11 @@ export class UserApi extends runtime.BaseAPI { * Create user */ async createUserRaw(requestParameters: UserApiCreateUserRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.body === null || requestParameters.body === undefined) { - throw new runtime.RequiredError('body','Required parameter requestParameters.body was null or undefined when calling createUser.'); + if (!runtime.exists(requestParameters, 'body')) { + throw new runtime.RequiredError( + 'body', + 'Required parameter "body" was null or undefined when calling createUser().' + ); } const queryParameters: any = {}; @@ -77,7 +80,7 @@ export class UserApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, - body: UserToJSON(requestParameters.body), + body: UserToJSON(requestParameters['body']), }, initOverrides); return new runtime.VoidApiResponse(response); @@ -95,8 +98,11 @@ export class UserApi extends runtime.BaseAPI { * Creates list of users with given input array */ async createUsersWithArrayInputRaw(requestParameters: UserApiCreateUsersWithArrayInputRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.body === null || requestParameters.body === undefined) { - throw new runtime.RequiredError('body','Required parameter requestParameters.body was null or undefined when calling createUsersWithArrayInput.'); + if (!runtime.exists(requestParameters, 'body')) { + throw new runtime.RequiredError( + 'body', + 'Required parameter "body" was null or undefined when calling createUsersWithArrayInput().' + ); } const queryParameters: any = {}; @@ -110,7 +116,7 @@ export class UserApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, - body: requestParameters.body.map(UserToJSON), + body: requestParameters['body']!.map(UserToJSON), }, initOverrides); return new runtime.VoidApiResponse(response); @@ -127,8 +133,11 @@ export class UserApi extends runtime.BaseAPI { * Creates list of users with given input array */ async createUsersWithListInputRaw(requestParameters: UserApiCreateUsersWithListInputRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.body === null || requestParameters.body === undefined) { - throw new runtime.RequiredError('body','Required parameter requestParameters.body was null or undefined when calling createUsersWithListInput.'); + if (!runtime.exists(requestParameters, 'body')) { + throw new runtime.RequiredError( + 'body', + 'Required parameter "body" was null or undefined when calling createUsersWithListInput().' + ); } const queryParameters: any = {}; @@ -142,7 +151,7 @@ export class UserApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, - body: requestParameters.body.map(UserToJSON), + body: requestParameters['body']!.map(UserToJSON), }, initOverrides); return new runtime.VoidApiResponse(response); @@ -160,8 +169,11 @@ export class UserApi extends runtime.BaseAPI { * Delete user */ async deleteUserRaw(requestParameters: UserApiDeleteUserRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.username === null || requestParameters.username === undefined) { - throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling deleteUser.'); + if (!runtime.exists(requestParameters, 'username')) { + throw new runtime.RequiredError( + 'username', + 'Required parameter "username" was null or undefined when calling deleteUser().' + ); } const queryParameters: any = {}; @@ -169,7 +181,7 @@ export class UserApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; const response = await this.request({ - path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), + path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters['username']))), method: 'DELETE', headers: headerParameters, query: queryParameters, @@ -190,8 +202,11 @@ export class UserApi extends runtime.BaseAPI { * Get user by user name */ async getUserByNameRaw(requestParameters: UserApiGetUserByNameRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.username === null || requestParameters.username === undefined) { - throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling getUserByName.'); + if (!runtime.exists(requestParameters, 'username')) { + throw new runtime.RequiredError( + 'username', + 'Required parameter "username" was null or undefined when calling getUserByName().' + ); } const queryParameters: any = {}; @@ -199,7 +214,7 @@ export class UserApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; const response = await this.request({ - path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), + path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters['username']))), method: 'GET', headers: headerParameters, query: queryParameters, @@ -220,22 +235,28 @@ export class UserApi extends runtime.BaseAPI { * Logs user into the system */ async loginUserRaw(requestParameters: UserApiLoginUserRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.username === null || requestParameters.username === undefined) { - throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling loginUser.'); + if (!runtime.exists(requestParameters, 'username')) { + throw new runtime.RequiredError( + 'username', + 'Required parameter "username" was null or undefined when calling loginUser().' + ); } - if (requestParameters.password === null || requestParameters.password === undefined) { - throw new runtime.RequiredError('password','Required parameter requestParameters.password was null or undefined when calling loginUser.'); + if (!runtime.exists(requestParameters, 'password')) { + throw new runtime.RequiredError( + 'password', + 'Required parameter "password" was null or undefined when calling loginUser().' + ); } const queryParameters: any = {}; - if (requestParameters.username !== undefined) { - queryParameters['username'] = requestParameters.username; + if (runtime.exists(requestParameters, 'username')) { + queryParameters['username'] = requestParameters['username']; } - if (requestParameters.password !== undefined) { - queryParameters['password'] = requestParameters.password; + if (runtime.exists(requestParameters, 'password')) { + queryParameters['password'] = requestParameters['password']; } const headerParameters: runtime.HTTPHeaders = {}; @@ -292,12 +313,18 @@ export class UserApi extends runtime.BaseAPI { * Updated user */ async updateUserRaw(requestParameters: UserApiUpdateUserRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.username === null || requestParameters.username === undefined) { - throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling updateUser.'); + if (!runtime.exists(requestParameters, 'username')) { + throw new runtime.RequiredError( + 'username', + 'Required parameter "username" was null or undefined when calling updateUser().' + ); } - if (requestParameters.body === null || requestParameters.body === undefined) { - throw new runtime.RequiredError('body','Required parameter requestParameters.body was null or undefined when calling updateUser.'); + if (!runtime.exists(requestParameters, 'body')) { + throw new runtime.RequiredError( + 'body', + 'Required parameter "body" was null or undefined when calling updateUser().' + ); } const queryParameters: any = {}; @@ -307,11 +334,11 @@ export class UserApi extends runtime.BaseAPI { headerParameters['Content-Type'] = 'application/json'; const response = await this.request({ - path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), + path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters['username']))), method: 'PUT', headers: headerParameters, query: queryParameters, - body: UserToJSON(requestParameters.body), + body: UserToJSON(requestParameters['body']), }, initOverrides); return new runtime.VoidApiResponse(response); 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 882567387201..001bc135bb96 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 @@ -37,9 +37,7 @@ export interface Category { * Check if a given object implements the Category interface. */ export function instanceOfCategory(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function CategoryFromJSON(json: any): Category { @@ -47,7 +45,7 @@ export function CategoryFromJSON(json: any): Category { } export function CategoryFromJSONTyped(json: any, ignoreDiscriminator: boolean): Category { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -66,8 +64,8 @@ export function CategoryToJSON(value?: Category | null): any { } return { - 'id': value.id, - 'name': value.name, + '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 bf50981fc2e2..a7fc63d81f1b 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 @@ -43,9 +43,7 @@ export interface ModelApiResponse { * Check if a given object implements the ModelApiResponse interface. */ export function instanceOfModelApiResponse(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function ModelApiResponseFromJSON(json: any): ModelApiResponse { @@ -53,7 +51,7 @@ export function ModelApiResponseFromJSON(json: any): ModelApiResponse { } export function ModelApiResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): ModelApiResponse { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -73,9 +71,9 @@ export function ModelApiResponseToJSON(value?: ModelApiResponse | null): any { } return { - 'code': value.code, - 'type': value.type, - 'message': value.message, + '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 0d69755d4887..9e12fc242793 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 @@ -73,9 +73,7 @@ export type OrderStatusEnum = typeof OrderStatusEnum[keyof typeof OrderStatusEnu * Check if a given object implements the Order interface. */ export function instanceOfOrder(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function OrderFromJSON(json: any): Order { @@ -83,7 +81,7 @@ export function OrderFromJSON(json: any): Order { } export function OrderFromJSONTyped(json: any, ignoreDiscriminator: boolean): Order { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -106,12 +104,12 @@ export function OrderToJSON(value?: Order | null): any { } return { - 'id': value.id, - 'petId': value.petId, - 'quantity': value.quantity, - 'shipDate': value.shipDate === undefined ? undefined : (value.shipDate.toISOString()), - 'status': value.status, - 'complete': value.complete, + 'id': value['id'], + 'petId': value['petId'], + 'quantity': value['quantity'], + 'shipDate': !exists(value, 'shipDate') ? undefined : ((value['shipDate']).toISOString()), + 'status': value['status'], + 'complete': value['complete'], }; } 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 73c70f03a3e5..8906602f6f4b 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 @@ -86,11 +86,9 @@ export type PetStatusEnum = typeof PetStatusEnum[keyof typeof PetStatusEnum]; * Check if a given object implements the Pet interface. */ export function instanceOfPet(value: object): boolean { - let isInstance = true; - isInstance = isInstance && "name" in value; - isInstance = isInstance && "photoUrls" in value; - - return isInstance; + if (!('name' in value)) return false; + if (!('photoUrls' in value)) return false; + return true; } export function PetFromJSON(json: any): Pet { @@ -98,7 +96,7 @@ export function PetFromJSON(json: any): Pet { } export function PetFromJSONTyped(json: any, ignoreDiscriminator: boolean): Pet { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -121,12 +119,12 @@ export function PetToJSON(value?: Pet | null): any { } return { - 'id': value.id, - 'category': CategoryToJSON(value.category), - 'name': value.name, - 'photoUrls': value.photoUrls, - 'tags': value.tags === undefined ? undefined : ((value.tags as Array).map(TagToJSON)), - 'status': value.status, + 'id': value['id'], + 'category': CategoryToJSON(value['category']), + 'name': value['name'], + 'photoUrls': value['photoUrls'], + 'tags': !exists(value, 'tags') ? undefined : ((value['tags'] as Array).map(TagToJSON)), + 'status': value['status'], }; } 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 e4902aa53cfd..24a25f383dba 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 @@ -37,9 +37,7 @@ export interface Tag { * Check if a given object implements the Tag interface. */ export function instanceOfTag(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function TagFromJSON(json: any): Tag { @@ -47,7 +45,7 @@ export function TagFromJSON(json: any): Tag { } export function TagFromJSONTyped(json: any, ignoreDiscriminator: boolean): Tag { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -66,8 +64,8 @@ export function TagToJSON(value?: Tag | null): any { } return { - 'id': value.id, - 'name': value.name, + '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 f22da928907c..00ab35b80563 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 @@ -73,9 +73,7 @@ export interface User { * Check if a given object implements the User interface. */ export function instanceOfUser(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function UserFromJSON(json: any): User { @@ -83,7 +81,7 @@ export function UserFromJSON(json: any): User { } export function UserFromJSONTyped(json: any, ignoreDiscriminator: boolean): User { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -108,14 +106,14 @@ export function UserToJSON(value?: User | null): any { } return { - 'id': value.id, - 'username': value.username, - 'firstName': value.firstName, - 'lastName': value.lastName, - 'email': value.email, - 'password': value.password, - 'phone': value.phone, - 'userStatus': value.userStatus, + 'id': value['id'], + 'username': value['username'], + 'firstName': value['firstName'], + 'lastName': value['lastName'], + 'email': value['email'], + 'password': value['password'], + 'phone': value['phone'], + 'userStatus': value['userStatus'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces/src/runtime.ts b/samples/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces/src/runtime.ts index 71ecdb875d14..813bf0fb4dfe 100644 --- a/samples/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces/src/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces/src/runtime.ts @@ -310,9 +310,9 @@ export interface RequestOpts { body?: HTTPBody; } -export function exists(json: any, key: string) { +export function exists(json: any, key: string): boolean { const value = json[key]; - return value !== null && value !== undefined; + return value !== undefined && value !== null; } export function querystring(params: HTTPQuery, prefix: string = ''): string { diff --git a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/apis/BehaviorApi.ts b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/apis/BehaviorApi.ts index f1fbb107ba1a..1f9c29198de2 100644 --- a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/apis/BehaviorApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/apis/BehaviorApi.ts @@ -42,8 +42,11 @@ export class BehaviorApi extends runtime.BaseAPI { * Get permissions for the behavior */ async getBehaviorPermissionsRaw(requestParameters: GetBehaviorPermissionsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.behaviorId === null || requestParameters.behaviorId === undefined) { - throw new runtime.RequiredError('behaviorId','Required parameter requestParameters.behaviorId was null or undefined when calling getBehaviorPermissions.'); + if (!runtime.exists(requestParameters, 'behaviorId')) { + throw new runtime.RequiredError( + 'behaviorId', + 'Required parameter "behaviorId" was null or undefined when calling getBehaviorPermissions().' + ); } const queryParameters: any = {}; @@ -51,7 +54,7 @@ export class BehaviorApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; const response = await this.request({ - path: `/fake_behavior/{behavior-id}/permissions`.replace(`{${"behavior-id"}}`, encodeURIComponent(String(requestParameters.behaviorId))), + path: `/fake_behavior/{behavior-id}/permissions`.replace(`{${"behavior-id"}}`, encodeURIComponent(String(requestParameters['behaviorId']))), method: 'GET', headers: headerParameters, query: queryParameters, @@ -72,8 +75,11 @@ export class BehaviorApi extends runtime.BaseAPI { * Get the type of behavior */ async getBehaviorTypeRaw(requestParameters: GetBehaviorTypeRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.behaviorId === null || requestParameters.behaviorId === undefined) { - throw new runtime.RequiredError('behaviorId','Required parameter requestParameters.behaviorId was null or undefined when calling getBehaviorType.'); + if (!runtime.exists(requestParameters, 'behaviorId')) { + throw new runtime.RequiredError( + 'behaviorId', + 'Required parameter "behaviorId" was null or undefined when calling getBehaviorType().' + ); } const queryParameters: any = {}; @@ -81,7 +87,7 @@ export class BehaviorApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; const response = await this.request({ - path: `/fake_behavior/{behavior-id}/type`.replace(`{${"behavior-id"}}`, encodeURIComponent(String(requestParameters.behaviorId))), + path: `/fake_behavior/{behavior-id}/type`.replace(`{${"behavior-id"}}`, encodeURIComponent(String(requestParameters['behaviorId']))), method: 'GET', headers: headerParameters, query: queryParameters, diff --git a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/apis/BehaviorApiSagas.ts b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/apis/BehaviorApiSagas.ts index cb6c3371f0a4..0c98a78f6338 100644 --- a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/apis/BehaviorApiSagas.ts +++ b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/apis/BehaviorApiSagas.ts @@ -69,7 +69,7 @@ export function *getBehaviorPermissionsSagaImp(_action_: Action = yield apiCall(Api.behaviorApi, Api.behaviorApi.getBehaviorPermissions, + const response: Required = yield apiCall(Api.behaviorApi, Api.behaviorApi['getBehaviorPermissions'], parseFloat(behaviorId), ); @@ -113,7 +113,7 @@ export function *getBehaviorTypeSagaImp(_action_: Action yield put(getBehaviorTypeRequest(_action_.payload)); - const response: Required = yield apiCall(Api.behaviorApi, Api.behaviorApi.getBehaviorType, + const response: Required = yield apiCall(Api.behaviorApi, Api.behaviorApi['getBehaviorType'], parseFloat(behaviorId), ); diff --git a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/apis/PetApi.ts b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/apis/PetApi.ts index 2f54dafe66e9..8aa504326391 100644 --- a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/apis/PetApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/apis/PetApi.ts @@ -100,8 +100,11 @@ export class PetApi extends runtime.BaseAPI { * Add a new pet to the store */ async addPetRaw(requestParameters: AddPetRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.dummyCat === null || requestParameters.dummyCat === undefined) { - throw new runtime.RequiredError('dummyCat','Required parameter requestParameters.dummyCat was null or undefined when calling addPet.'); + if (!runtime.exists(requestParameters, 'dummyCat')) { + throw new runtime.RequiredError( + 'dummyCat', + 'Required parameter "dummyCat" was null or undefined when calling addPet().' + ); } const queryParameters: any = {}; @@ -120,7 +123,7 @@ export class PetApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, - body: CategoryToJSON(requestParameters.dummyCat), + body: CategoryToJSON(requestParameters['dummyCat']), }, initOverrides); return new runtime.VoidApiResponse(response); @@ -137,16 +140,19 @@ export class PetApi extends runtime.BaseAPI { * Deletes a pet */ async deletePetRaw(requestParameters: DeletePetRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.petId === null || requestParameters.petId === undefined) { - throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling deletePet.'); + if (!runtime.exists(requestParameters, 'petId')) { + throw new runtime.RequiredError( + 'petId', + 'Required parameter "petId" was null or undefined when calling deletePet().' + ); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; - if (requestParameters.apiKey !== undefined && requestParameters.apiKey !== null) { - headerParameters['api_key'] = String(requestParameters.apiKey); + if (runtime.exists(requestParameters, 'apiKey')) { + headerParameters['api_key'] = String(requestParameters['apiKey']); } if (this.configuration && this.configuration.accessToken) { @@ -155,7 +161,7 @@ export class PetApi extends runtime.BaseAPI { } const response = await this.request({ - path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), + path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters['petId']))), method: 'DELETE', headers: headerParameters, query: queryParameters, @@ -177,14 +183,17 @@ export class PetApi extends runtime.BaseAPI { * @deprecated */ async findPetsByIdsRaw(requestParameters: FindPetsByIdsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>> { - if (requestParameters.ids === null || requestParameters.ids === undefined) { - throw new runtime.RequiredError('ids','Required parameter requestParameters.ids was null or undefined when calling findPetsByIds.'); + if (!runtime.exists(requestParameters, 'ids')) { + throw new runtime.RequiredError( + 'ids', + 'Required parameter "ids" was null or undefined when calling findPetsByIds().' + ); } const queryParameters: any = {}; - if (requestParameters.ids) { - queryParameters['ids'] = requestParameters.ids.join(runtime.COLLECTION_FORMATS["csv"]); + if (runtime.exists(requestParameters, 'ids')) { + queryParameters['ids'] = requestParameters['ids']!.join(runtime.COLLECTION_FORMATS["csv"]); } const headerParameters: runtime.HTTPHeaders = {}; @@ -219,14 +228,17 @@ export class PetApi extends runtime.BaseAPI { * Finds Pets by status */ async findPetsByStatusRaw(requestParameters: FindPetsByStatusRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.status === null || requestParameters.status === undefined) { - throw new runtime.RequiredError('status','Required parameter requestParameters.status was null or undefined when calling findPetsByStatus.'); + if (!runtime.exists(requestParameters, 'status')) { + throw new runtime.RequiredError( + 'status', + 'Required parameter "status" was null or undefined when calling findPetsByStatus().' + ); } const queryParameters: any = {}; - if (requestParameters.status) { - queryParameters['status'] = requestParameters.status.join(runtime.COLLECTION_FORMATS["csv"]); + if (runtime.exists(requestParameters, 'status')) { + queryParameters['status'] = requestParameters['status']!.join(runtime.COLLECTION_FORMATS["csv"]); } const headerParameters: runtime.HTTPHeaders = {}; @@ -261,14 +273,17 @@ export class PetApi extends runtime.BaseAPI { * @deprecated */ async findPetsByTagsRaw(requestParameters: FindPetsByTagsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>> { - if (requestParameters.tags === null || requestParameters.tags === undefined) { - throw new runtime.RequiredError('tags','Required parameter requestParameters.tags was null or undefined when calling findPetsByTags.'); + if (!runtime.exists(requestParameters, 'tags')) { + throw new runtime.RequiredError( + 'tags', + 'Required parameter "tags" was null or undefined when calling findPetsByTags().' + ); } const queryParameters: any = {}; - if (requestParameters.tags) { - queryParameters['tags'] = requestParameters.tags.join(runtime.COLLECTION_FORMATS["csv"]); + if (runtime.exists(requestParameters, 'tags')) { + queryParameters['tags'] = requestParameters['tags']!.join(runtime.COLLECTION_FORMATS["csv"]); } const headerParameters: runtime.HTTPHeaders = {}; @@ -304,14 +319,17 @@ export class PetApi extends runtime.BaseAPI { * @deprecated */ async findPetsByUserIdsRaw(requestParameters: FindPetsByUserIdsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.ids === null || requestParameters.ids === undefined) { - throw new runtime.RequiredError('ids','Required parameter requestParameters.ids was null or undefined when calling findPetsByUserIds.'); + if (!runtime.exists(requestParameters, 'ids')) { + throw new runtime.RequiredError( + 'ids', + 'Required parameter "ids" was null or undefined when calling findPetsByUserIds().' + ); } const queryParameters: any = {}; - if (requestParameters.ids) { - queryParameters['ids'] = requestParameters.ids.join(runtime.COLLECTION_FORMATS["csv"]); + if (runtime.exists(requestParameters, 'ids')) { + queryParameters['ids'] = requestParameters['ids']!.join(runtime.COLLECTION_FORMATS["csv"]); } const headerParameters: runtime.HTTPHeaders = {}; @@ -346,8 +364,11 @@ export class PetApi extends runtime.BaseAPI { * Find pet by ID */ async getPetByIdRaw(requestParameters: GetPetByIdRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.petId === null || requestParameters.petId === undefined) { - throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling getPetById.'); + if (!runtime.exists(requestParameters, 'petId')) { + throw new runtime.RequiredError( + 'petId', + 'Required parameter "petId" was null or undefined when calling getPetById().' + ); } const queryParameters: any = {}; @@ -359,7 +380,7 @@ export class PetApi extends runtime.BaseAPI { } const response = await this.request({ - path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), + path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters['petId']))), method: 'GET', headers: headerParameters, query: queryParameters, @@ -381,8 +402,11 @@ export class PetApi extends runtime.BaseAPI { * Gets regions for a single pet. */ async getPetRegionsRaw(requestParameters: GetPetRegionsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.petId === null || requestParameters.petId === undefined) { - throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling getPetRegions.'); + if (!runtime.exists(requestParameters, 'petId')) { + throw new runtime.RequiredError( + 'petId', + 'Required parameter "petId" was null or undefined when calling getPetRegions().' + ); } const queryParameters: any = {}; @@ -390,7 +414,7 @@ export class PetApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; const response = await this.request({ - path: `/pet/{petId}/regions`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), + path: `/pet/{petId}/regions`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters['petId']))), method: 'GET', headers: headerParameters, query: queryParameters, @@ -411,8 +435,11 @@ export class PetApi extends runtime.BaseAPI { * Update an existing pet */ async updatePetRaw(requestParameters: UpdatePetRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.body === null || requestParameters.body === undefined) { - throw new runtime.RequiredError('body','Required parameter requestParameters.body was null or undefined when calling updatePet.'); + if (!runtime.exists(requestParameters, 'body')) { + throw new runtime.RequiredError( + 'body', + 'Required parameter "body" was null or undefined when calling updatePet().' + ); } const queryParameters: any = {}; @@ -431,7 +458,7 @@ export class PetApi extends runtime.BaseAPI { method: 'PUT', headers: headerParameters, query: queryParameters, - body: PetToJSON(requestParameters.body), + body: PetToJSON(requestParameters['body']), }, initOverrides); return new runtime.VoidApiResponse(response); @@ -448,12 +475,18 @@ export class PetApi extends runtime.BaseAPI { * Updates the pet regions. */ async updatePetRegionsRaw(requestParameters: UpdatePetRegionsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.petId === null || requestParameters.petId === undefined) { - throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling updatePetRegions.'); + if (!runtime.exists(requestParameters, 'petId')) { + throw new runtime.RequiredError( + 'petId', + 'Required parameter "petId" was null or undefined when calling updatePetRegions().' + ); } - if (requestParameters.newRegions === null || requestParameters.newRegions === undefined) { - throw new runtime.RequiredError('newRegions','Required parameter requestParameters.newRegions was null or undefined when calling updatePetRegions.'); + if (!runtime.exists(requestParameters, 'newRegions')) { + throw new runtime.RequiredError( + 'newRegions', + 'Required parameter "newRegions" was null or undefined when calling updatePetRegions().' + ); } const queryParameters: any = {}; @@ -463,11 +496,11 @@ export class PetApi extends runtime.BaseAPI { headerParameters['Content-Type'] = 'application/json'; const response = await this.request({ - path: `/pet/{petId}/regions`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), + path: `/pet/{petId}/regions`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters['petId']))), method: 'PUT', headers: headerParameters, query: queryParameters, - body: requestParameters.newRegions, + body: requestParameters['newRegions'], }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => PetRegionsResponseFromJSON(jsonValue)); @@ -485,8 +518,11 @@ export class PetApi extends runtime.BaseAPI { * Updates a pet in the store with form data */ async updatePetWithFormRaw(requestParameters: UpdatePetWithFormRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.petId === null || requestParameters.petId === undefined) { - throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling updatePetWithForm.'); + if (!runtime.exists(requestParameters, 'petId')) { + throw new runtime.RequiredError( + 'petId', + 'Required parameter "petId" was null or undefined when calling updatePetWithForm().' + ); } const queryParameters: any = {}; @@ -512,16 +548,16 @@ export class PetApi extends runtime.BaseAPI { formParams = new URLSearchParams(); } - if (requestParameters.name !== undefined) { - formParams.append('name', requestParameters.name as any); + if (runtime.exists(requestParameters, 'name')) { + formParams.append('name', requestParameters['name'] as any); } - if (requestParameters.status !== undefined) { - formParams.append('status', requestParameters.status as any); + if (runtime.exists(requestParameters, 'status')) { + formParams.append('status', requestParameters['status'] as any); } const response = await this.request({ - path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), + path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters['petId']))), method: 'POST', headers: headerParameters, query: queryParameters, @@ -542,8 +578,11 @@ export class PetApi extends runtime.BaseAPI { * uploads an image */ async uploadFileRaw(requestParameters: UploadFileRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.petId === null || requestParameters.petId === undefined) { - throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling uploadFile.'); + if (!runtime.exists(requestParameters, 'petId')) { + throw new runtime.RequiredError( + 'petId', + 'Required parameter "petId" was null or undefined when calling uploadFile().' + ); } const queryParameters: any = {}; @@ -571,16 +610,16 @@ export class PetApi extends runtime.BaseAPI { formParams = new URLSearchParams(); } - if (requestParameters.additionalMetadata !== undefined) { - formParams.append('additionalMetadata', requestParameters.additionalMetadata as any); + if (runtime.exists(requestParameters, 'additionalMetadata')) { + formParams.append('additionalMetadata', requestParameters['additionalMetadata'] as any); } - if (requestParameters.file !== undefined) { - formParams.append('file', requestParameters.file as any); + if (runtime.exists(requestParameters, 'file')) { + formParams.append('file', requestParameters['file'] as any); } const response = await this.request({ - path: `/pet/{petId}/uploadImage`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), + path: `/pet/{petId}/uploadImage`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters['petId']))), method: 'POST', headers: headerParameters, query: queryParameters, diff --git a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/apis/PetApiSagas.ts b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/apis/PetApiSagas.ts index da8af274744e..841f613f3910 100644 --- a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/apis/PetApiSagas.ts +++ b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/apis/PetApiSagas.ts @@ -95,7 +95,7 @@ export function *addPetSagaImp(_action_: Action) { yield put(addPetRequest(_action_.payload)); - const response = yield apiCall(Api.petApi, Api.petApi.addPet, + const response = yield apiCall(Api.petApi, Api.petApi['addPet'], categoryRecordUtils.toApi(dummyCat), ); @@ -139,7 +139,7 @@ export function *deletePetSagaImp(_action_: Action) { yield put(deletePetRequest(_action_.payload)); - const response = yield apiCall(Api.petApi, Api.petApi.deletePet, + const response = yield apiCall(Api.petApi, Api.petApi['deletePet'], parseFloat(petId), apiKey, ); @@ -184,7 +184,7 @@ export function *findPetsByIdsSagaImp(_action_: Action) { yield put(findPetsByIdsRequest(requestPayload)); - const response: Required> = yield apiCall(Api.petApi, Api.petApi.findPetsByIds, + const response: Required> = yield apiCall(Api.petApi, Api.petApi['findPetsByIds'], ids.map(p => (p ? parseFloat(p) : null) as number ).toArray(), ); @@ -237,7 +237,7 @@ export function *findPetsByStatusSagaImp(_action_: Action = yield apiCall(Api.petApi, Api.petApi.findPetsByStatus, + const response: Required = yield apiCall(Api.petApi, Api.petApi['findPetsByStatus'], status.toJS(), ); @@ -290,7 +290,7 @@ export function *findPetsByTagsSagaImp(_action_: Action) yield put(findPetsByTagsRequest(requestPayload)); - const response: Required> = yield apiCall(Api.petApi, Api.petApi.findPetsByTags, + const response: Required> = yield apiCall(Api.petApi, Api.petApi['findPetsByTags'], tags.toJS(), ); @@ -343,7 +343,7 @@ export function *findPetsByUserIdsSagaImp(_action_: Action = yield apiCall(Api.petApi, Api.petApi.findPetsByUserIds, + const response: Required = yield apiCall(Api.petApi, Api.petApi['findPetsByUserIds'], ids.map(p => (p ? parseFloat(p) : null) as number ).toArray(), ); @@ -396,7 +396,7 @@ export function *getPetByIdSagaImp(_action_: Action) { yield put(getPetByIdRequest(requestPayload)); - const response: Required = yield apiCall(Api.petApi, Api.petApi.getPetById, + const response: Required = yield apiCall(Api.petApi, Api.petApi['getPetById'], parseFloat(petId), ); @@ -447,7 +447,7 @@ export function *getPetRegionsSagaImp(_action_: Action) { yield put(getPetRegionsRequest(_action_.payload)); - const response: Required = yield apiCall(Api.petApi, Api.petApi.getPetRegions, + const response: Required = yield apiCall(Api.petApi, Api.petApi['getPetRegions'], parseFloat(petId), ); @@ -491,7 +491,7 @@ export function *updatePetSagaImp(_action_: Action) { yield put(updatePetRequest(_action_.payload)); - const response = yield apiCall(Api.petApi, Api.petApi.updatePet, + const response = yield apiCall(Api.petApi, Api.petApi['updatePet'], petRecordUtils.toApi(body), ); @@ -535,7 +535,7 @@ export function *updatePetRegionsSagaImp(_action_: Action = yield apiCall(Api.petApi, Api.petApi.updatePetRegions, + const response: Required = yield apiCall(Api.petApi, Api.petApi['updatePetRegions'], parseFloat(petId), newRegions.map(p => p.toArray().map(p2 => (p2 ? parseFloat(p2) : null) as number)).toArray(), ); @@ -584,7 +584,7 @@ export function *updatePetWithFormSagaImp(_action_: Action) { yield put(uploadFileRequest(requestPayload)); - const response: Required = yield apiCall(Api.petApi, Api.petApi.uploadFile, + const response: Required = yield apiCall(Api.petApi, Api.petApi['uploadFile'], parseFloat(petId), additionalMetadata, file, diff --git a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/apis/PetPartApi.ts b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/apis/PetPartApi.ts index 93fdede05ee7..5317ee8f514d 100644 --- a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/apis/PetPartApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/apis/PetPartApi.ts @@ -47,8 +47,11 @@ export class PetPartApi extends runtime.BaseAPI { * Returns single pet part type for the petPart id. */ async getFakePetPartTypeRaw(requestParameters: GetFakePetPartTypeRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.fakePetPartId === null || requestParameters.fakePetPartId === undefined) { - throw new runtime.RequiredError('fakePetPartId','Required parameter requestParameters.fakePetPartId was null or undefined when calling getFakePetPartType.'); + if (!runtime.exists(requestParameters, 'fakePetPartId')) { + throw new runtime.RequiredError( + 'fakePetPartId', + 'Required parameter "fakePetPartId" was null or undefined when calling getFakePetPartType().' + ); } const queryParameters: any = {}; @@ -56,7 +59,7 @@ export class PetPartApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; const response = await this.request({ - path: `/fake_petParts/{fake_petPart-id}/part-type`.replace(`{${"fake_petPart-id"}}`, encodeURIComponent(String(requestParameters.fakePetPartId))), + path: `/fake_petParts/{fake_petPart-id}/part-type`.replace(`{${"fake_petPart-id"}}`, encodeURIComponent(String(requestParameters['fakePetPartId']))), method: 'GET', headers: headerParameters, query: queryParameters, @@ -77,48 +80,60 @@ export class PetPartApi extends runtime.BaseAPI { * Get the matching parts for the given pet part. */ async getMatchingPartsRaw(requestParameters: GetMatchingPartsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.fakePetPartId === null || requestParameters.fakePetPartId === undefined) { - throw new runtime.RequiredError('fakePetPartId','Required parameter requestParameters.fakePetPartId was null or undefined when calling getMatchingParts.'); + if (!runtime.exists(requestParameters, 'fakePetPartId')) { + throw new runtime.RequiredError( + 'fakePetPartId', + 'Required parameter "fakePetPartId" was null or undefined when calling getMatchingParts().' + ); } - if (requestParameters._long === null || requestParameters._long === undefined) { - throw new runtime.RequiredError('_long','Required parameter requestParameters._long was null or undefined when calling getMatchingParts.'); + if (!runtime.exists(requestParameters, '_long')) { + throw new runtime.RequiredError( + '_long', + 'Required parameter "_long" was null or undefined when calling getMatchingParts().' + ); } - if (requestParameters.smooth === null || requestParameters.smooth === undefined) { - throw new runtime.RequiredError('smooth','Required parameter requestParameters.smooth was null or undefined when calling getMatchingParts.'); + if (!runtime.exists(requestParameters, 'smooth')) { + throw new runtime.RequiredError( + 'smooth', + 'Required parameter "smooth" was null or undefined when calling getMatchingParts().' + ); } - if (requestParameters._short === null || requestParameters._short === undefined) { - throw new runtime.RequiredError('_short','Required parameter requestParameters._short was null or undefined when calling getMatchingParts.'); + if (!runtime.exists(requestParameters, '_short')) { + throw new runtime.RequiredError( + '_short', + 'Required parameter "_short" was null or undefined when calling getMatchingParts().' + ); } const queryParameters: any = {}; - if (requestParameters._long !== undefined) { - queryParameters['long'] = requestParameters._long; + if (runtime.exists(requestParameters, '_long')) { + queryParameters['long'] = requestParameters['_long']; } - if (requestParameters.smooth !== undefined) { - queryParameters['smooth'] = requestParameters.smooth; + if (runtime.exists(requestParameters, 'smooth')) { + queryParameters['smooth'] = requestParameters['smooth']; } - if (requestParameters.name !== undefined) { - queryParameters['name'] = requestParameters.name; + if (runtime.exists(requestParameters, 'name')) { + queryParameters['name'] = requestParameters['name']; } - if (requestParameters.connectedPart !== undefined) { - queryParameters['connected-part'] = requestParameters.connectedPart; + if (runtime.exists(requestParameters, 'connectedPart')) { + queryParameters['connected-part'] = requestParameters['connectedPart']; } - if (requestParameters._short !== undefined) { - queryParameters['short'] = requestParameters._short; + if (runtime.exists(requestParameters, '_short')) { + queryParameters['short'] = requestParameters['_short']; } const headerParameters: runtime.HTTPHeaders = {}; const response = await this.request({ - path: `/fake_petParts/{fake_petPart-id}/matching-parts`.replace(`{${"fake_petPart-id"}}`, encodeURIComponent(String(requestParameters.fakePetPartId))), + path: `/fake_petParts/{fake_petPart-id}/matching-parts`.replace(`{${"fake_petPart-id"}}`, encodeURIComponent(String(requestParameters['fakePetPartId']))), method: 'GET', headers: headerParameters, query: queryParameters, diff --git a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/apis/PetPartApiSagas.ts b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/apis/PetPartApiSagas.ts index 2975642fc138..41189b279198 100644 --- a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/apis/PetPartApiSagas.ts +++ b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/apis/PetPartApiSagas.ts @@ -70,7 +70,7 @@ export function *getFakePetPartTypeSagaImp(_action_: Action = yield apiCall(Api.petPartApi, Api.petPartApi.getFakePetPartType, + const response: Required = yield apiCall(Api.petPartApi, Api.petPartApi['getFakePetPartType'], parseFloat(fakePetPartId), ); @@ -126,7 +126,7 @@ export function *getMatchingPartsSagaImp(_action_: Action = yield apiCall(Api.petPartApi, Api.petPartApi.getMatchingParts, + const response: Required = yield apiCall(Api.petPartApi, Api.petPartApi['getMatchingParts'], parseFloat(fakePetPartId), _long, smooth, diff --git a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/apis/StoreApi.ts b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/apis/StoreApi.ts index 97d90e388f30..71f08a8daed8 100644 --- a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/apis/StoreApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/apis/StoreApi.ts @@ -44,8 +44,11 @@ export class StoreApi extends runtime.BaseAPI { * Delete purchase order by ID */ async deleteOrderRaw(requestParameters: DeleteOrderRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.orderId === null || requestParameters.orderId === undefined) { - throw new runtime.RequiredError('orderId','Required parameter requestParameters.orderId was null or undefined when calling deleteOrder.'); + if (!runtime.exists(requestParameters, 'orderId')) { + throw new runtime.RequiredError( + 'orderId', + 'Required parameter "orderId" was null or undefined when calling deleteOrder().' + ); } const queryParameters: any = {}; @@ -53,7 +56,7 @@ export class StoreApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; const response = await this.request({ - path: `/store/order/{orderId}`.replace(`{${"orderId"}}`, encodeURIComponent(String(requestParameters.orderId))), + path: `/store/order/{orderId}`.replace(`{${"orderId"}}`, encodeURIComponent(String(requestParameters['orderId']))), method: 'DELETE', headers: headerParameters, query: queryParameters, @@ -107,8 +110,11 @@ export class StoreApi extends runtime.BaseAPI { * Find purchase order by ID */ async getOrderByIdRaw(requestParameters: GetOrderByIdRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.orderId === null || requestParameters.orderId === undefined) { - throw new runtime.RequiredError('orderId','Required parameter requestParameters.orderId was null or undefined when calling getOrderById.'); + if (!runtime.exists(requestParameters, 'orderId')) { + throw new runtime.RequiredError( + 'orderId', + 'Required parameter "orderId" was null or undefined when calling getOrderById().' + ); } const queryParameters: any = {}; @@ -116,7 +122,7 @@ export class StoreApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; const response = await this.request({ - path: `/store/order/{orderId}`.replace(`{${"orderId"}}`, encodeURIComponent(String(requestParameters.orderId))), + path: `/store/order/{orderId}`.replace(`{${"orderId"}}`, encodeURIComponent(String(requestParameters['orderId']))), method: 'GET', headers: headerParameters, query: queryParameters, @@ -138,8 +144,11 @@ export class StoreApi extends runtime.BaseAPI { * Place an order for a pet */ async placeOrderRaw(requestParameters: PlaceOrderRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.body === null || requestParameters.body === undefined) { - throw new runtime.RequiredError('body','Required parameter requestParameters.body was null or undefined when calling placeOrder.'); + if (!runtime.exists(requestParameters, 'body')) { + throw new runtime.RequiredError( + 'body', + 'Required parameter "body" was null or undefined when calling placeOrder().' + ); } const queryParameters: any = {}; @@ -153,7 +162,7 @@ export class StoreApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, - body: OrderToJSON(requestParameters.body), + body: OrderToJSON(requestParameters['body']), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => OrderFromJSON(jsonValue)); diff --git a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/apis/StoreApiSagas.ts b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/apis/StoreApiSagas.ts index bb97efa62433..ea92ff2f2163 100644 --- a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/apis/StoreApiSagas.ts +++ b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/apis/StoreApiSagas.ts @@ -67,7 +67,7 @@ export function *deleteOrderSagaImp(_action_: Action) { yield put(deleteOrderRequest(_action_.payload)); - const response = yield apiCall(Api.storeApi, Api.storeApi.deleteOrder, + const response = yield apiCall(Api.storeApi, Api.storeApi['deleteOrder'], orderId, ); @@ -103,7 +103,7 @@ export function *getInventorySagaImp(_action_: Action) { yield put(getInventoryRequest()); - const response: Required<{ [key: string]: number; }> = yield apiCall(Api.storeApi, Api.storeApi.getInventory, + const response: Required<{ [key: string]: number; }> = yield apiCall(Api.storeApi, Api.storeApi['getInventory'], ); let successReturnValue: any = undefined; @@ -147,7 +147,7 @@ export function *getOrderByIdSagaImp(_action_: Action) { yield put(getOrderByIdRequest(requestPayload)); - const response: Required = yield apiCall(Api.storeApi, Api.storeApi.getOrderById, + const response: Required = yield apiCall(Api.storeApi, Api.storeApi['getOrderById'], parseFloat(orderId), ); @@ -200,7 +200,7 @@ export function *placeOrderSagaImp(_action_: Action) { yield put(placeOrderRequest(requestPayload)); - const response: Required = yield apiCall(Api.storeApi, Api.storeApi.placeOrder, + const response: Required = yield apiCall(Api.storeApi, Api.storeApi['placeOrder'], orderRecordUtils.toApi(body), ); diff --git a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/apis/UserApi.ts b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/apis/UserApi.ts index 2392a0df4c13..e2c54ff475c7 100644 --- a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/apis/UserApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/apis/UserApi.ts @@ -65,8 +65,11 @@ export class UserApi extends runtime.BaseAPI { * Create user */ async createUserRaw(requestParameters: CreateUserRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.body === null || requestParameters.body === undefined) { - throw new runtime.RequiredError('body','Required parameter requestParameters.body was null or undefined when calling createUser.'); + if (!runtime.exists(requestParameters, 'body')) { + throw new runtime.RequiredError( + 'body', + 'Required parameter "body" was null or undefined when calling createUser().' + ); } const queryParameters: any = {}; @@ -80,7 +83,7 @@ export class UserApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, - body: UserToJSON(requestParameters.body), + body: UserToJSON(requestParameters['body']), }, initOverrides); return new runtime.VoidApiResponse(response); @@ -98,8 +101,11 @@ export class UserApi extends runtime.BaseAPI { * Creates list of users with given input array */ async createUsersWithArrayInputRaw(requestParameters: CreateUsersWithArrayInputRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.body === null || requestParameters.body === undefined) { - throw new runtime.RequiredError('body','Required parameter requestParameters.body was null or undefined when calling createUsersWithArrayInput.'); + if (!runtime.exists(requestParameters, 'body')) { + throw new runtime.RequiredError( + 'body', + 'Required parameter "body" was null or undefined when calling createUsersWithArrayInput().' + ); } const queryParameters: any = {}; @@ -113,7 +119,7 @@ export class UserApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, - body: requestParameters.body.map(UserToJSON), + body: requestParameters['body']!.map(UserToJSON), }, initOverrides); return new runtime.VoidApiResponse(response); @@ -130,8 +136,11 @@ export class UserApi extends runtime.BaseAPI { * Creates list of users with given input array */ async createUsersWithListInputRaw(requestParameters: CreateUsersWithListInputRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.body === null || requestParameters.body === undefined) { - throw new runtime.RequiredError('body','Required parameter requestParameters.body was null or undefined when calling createUsersWithListInput.'); + if (!runtime.exists(requestParameters, 'body')) { + throw new runtime.RequiredError( + 'body', + 'Required parameter "body" was null or undefined when calling createUsersWithListInput().' + ); } const queryParameters: any = {}; @@ -145,7 +154,7 @@ export class UserApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, - body: requestParameters.body.map(UserToJSON), + body: requestParameters['body']!.map(UserToJSON), }, initOverrides); return new runtime.VoidApiResponse(response); @@ -163,8 +172,11 @@ export class UserApi extends runtime.BaseAPI { * Delete user */ async deleteUserRaw(requestParameters: DeleteUserRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.username === null || requestParameters.username === undefined) { - throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling deleteUser.'); + if (!runtime.exists(requestParameters, 'username')) { + throw new runtime.RequiredError( + 'username', + 'Required parameter "username" was null or undefined when calling deleteUser().' + ); } const queryParameters: any = {}; @@ -172,7 +184,7 @@ export class UserApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; const response = await this.request({ - path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), + path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters['username']))), method: 'DELETE', headers: headerParameters, query: queryParameters, @@ -193,8 +205,11 @@ export class UserApi extends runtime.BaseAPI { * Get user by user name */ async getUserByNameRaw(requestParameters: GetUserByNameRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.username === null || requestParameters.username === undefined) { - throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling getUserByName.'); + if (!runtime.exists(requestParameters, 'username')) { + throw new runtime.RequiredError( + 'username', + 'Required parameter "username" was null or undefined when calling getUserByName().' + ); } const queryParameters: any = {}; @@ -202,7 +217,7 @@ export class UserApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; const response = await this.request({ - path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), + path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters['username']))), method: 'GET', headers: headerParameters, query: queryParameters, @@ -223,22 +238,28 @@ export class UserApi extends runtime.BaseAPI { * Logs user into the system */ async loginUserRaw(requestParameters: LoginUserRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.username === null || requestParameters.username === undefined) { - throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling loginUser.'); + if (!runtime.exists(requestParameters, 'username')) { + throw new runtime.RequiredError( + 'username', + 'Required parameter "username" was null or undefined when calling loginUser().' + ); } - if (requestParameters.password === null || requestParameters.password === undefined) { - throw new runtime.RequiredError('password','Required parameter requestParameters.password was null or undefined when calling loginUser.'); + if (!runtime.exists(requestParameters, 'password')) { + throw new runtime.RequiredError( + 'password', + 'Required parameter "password" was null or undefined when calling loginUser().' + ); } const queryParameters: any = {}; - if (requestParameters.username !== undefined) { - queryParameters['username'] = requestParameters.username; + if (runtime.exists(requestParameters, 'username')) { + queryParameters['username'] = requestParameters['username']; } - if (requestParameters.password !== undefined) { - queryParameters['password'] = requestParameters.password; + if (runtime.exists(requestParameters, 'password')) { + queryParameters['password'] = requestParameters['password']; } const headerParameters: runtime.HTTPHeaders = {}; @@ -295,12 +316,18 @@ export class UserApi extends runtime.BaseAPI { * Updated user */ async updateUserRaw(requestParameters: UpdateUserRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.username === null || requestParameters.username === undefined) { - throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling updateUser.'); + if (!runtime.exists(requestParameters, 'username')) { + throw new runtime.RequiredError( + 'username', + 'Required parameter "username" was null or undefined when calling updateUser().' + ); } - if (requestParameters.body === null || requestParameters.body === undefined) { - throw new runtime.RequiredError('body','Required parameter requestParameters.body was null or undefined when calling updateUser.'); + if (!runtime.exists(requestParameters, 'body')) { + throw new runtime.RequiredError( + 'body', + 'Required parameter "body" was null or undefined when calling updateUser().' + ); } const queryParameters: any = {}; @@ -310,11 +337,11 @@ export class UserApi extends runtime.BaseAPI { headerParameters['Content-Type'] = 'application/json'; const response = await this.request({ - path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), + path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters['username']))), method: 'PUT', headers: headerParameters, query: queryParameters, - body: UserToJSON(requestParameters.body), + body: UserToJSON(requestParameters['body']), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => DefaultMetaOnlyResponseFromJSON(jsonValue)); diff --git a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/apis/UserApiSagas.ts b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/apis/UserApiSagas.ts index ffad5d36d9ef..ddef1ef77b04 100644 --- a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/apis/UserApiSagas.ts +++ b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/apis/UserApiSagas.ts @@ -74,7 +74,7 @@ export function *createUserSagaImp(_action_: Action) { yield put(createUserRequest(_action_.payload)); - const response = yield apiCall(Api.userApi, Api.userApi.createUser, + const response = yield apiCall(Api.userApi, Api.userApi['createUser'], userRecordUtils.toApi(body), ); @@ -116,7 +116,7 @@ export function *createUsersWithArrayInputSagaImp(_action_: Action) { yield put(deleteUserRequest(_action_.payload)); - const response = yield apiCall(Api.userApi, Api.userApi.deleteUser, + const response = yield apiCall(Api.userApi, Api.userApi['deleteUser'], username, ); @@ -244,7 +244,7 @@ export function *getUserByNameSagaImp(_action_: Action) { yield put(getUserByNameRequest(requestPayload)); - const response: Required = yield apiCall(Api.userApi, Api.userApi.getUserByName, + const response: Required = yield apiCall(Api.userApi, Api.userApi['getUserByName'], username, ); @@ -297,7 +297,7 @@ export function *loginUserSagaImp(_action_: Action) { yield put(loginUserRequest(_action_.payload)); - const response: Required = yield apiCall(Api.userApi, Api.userApi.loginUser, + const response: Required = yield apiCall(Api.userApi, Api.userApi['loginUser'], username, password, ); @@ -335,7 +335,7 @@ export function *logoutUserSagaImp(_action_: Action) { yield put(logoutUserRequest()); - const response = yield apiCall(Api.userApi, Api.userApi.logoutUser, + const response = yield apiCall(Api.userApi, Api.userApi['logoutUser'], ); yield put(logoutUserSuccess()); @@ -378,7 +378,7 @@ export function *updateUserSagaImp(_action_: Action) { yield put(updateUserRequest(_action_.payload)); - const response: Required = yield apiCall(Api.userApi, Api.userApi.updateUser, + const response: Required = yield apiCall(Api.userApi, Api.userApi['updateUser'], username, userRecordUtils.toApi(body), ); diff --git a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/Category.ts b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/Category.ts index 882567387201..001bc135bb96 100644 --- a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/Category.ts +++ b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/Category.ts @@ -37,9 +37,7 @@ export interface Category { * Check if a given object implements the Category interface. */ export function instanceOfCategory(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function CategoryFromJSON(json: any): Category { @@ -47,7 +45,7 @@ export function CategoryFromJSON(json: any): Category { } export function CategoryFromJSONTyped(json: any, ignoreDiscriminator: boolean): Category { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -66,8 +64,8 @@ export function CategoryToJSON(value?: Category | null): any { } return { - 'id': value.id, - 'name': value.name, + 'id': value['id'], + 'name': value['name'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/CategoryRecord.ts b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/CategoryRecord.ts index 905a06373264..2bb757b734aa 100644 --- a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/CategoryRecord.ts +++ b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/CategoryRecord.ts @@ -50,7 +50,7 @@ knownRecordFactories.set(CategoryRecordEntityProps.recType, CategoryRecordEntity class CategoryRecordUtils extends ApiRecordUtils { public normalize(apiObject: Category, asEntity?: boolean): Category { (apiObject as any).recType = asEntity ? CategoryRecordEntityProps.recType : CategoryRecordProps.recType; - if (apiObject.id) { (apiObject as any).id = apiObject.id.toString(); } + if (apiObject['id']) { (apiObject as any)['id'] = apiObject['id'].toString(); } return apiObject; } @@ -94,7 +94,7 @@ class CategoryRecordUtils extends ApiRecordUtils { public toApi(record: CategoryRecord): Category { const apiObject = super.toApi(record); - if (record.id) { apiObject.id = parseFloat(record.id); } + if (record['id']) { apiObject['id'] = parseFloat(record['id']); } return apiObject; } } diff --git a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/DefaultMetaOnlyResponse.ts b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/DefaultMetaOnlyResponse.ts index 6e974ed08da3..93b4baacc1a0 100644 --- a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/DefaultMetaOnlyResponse.ts +++ b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/DefaultMetaOnlyResponse.ts @@ -38,10 +38,8 @@ export interface DefaultMetaOnlyResponse { * Check if a given object implements the DefaultMetaOnlyResponse interface. */ export function instanceOfDefaultMetaOnlyResponse(value: object): boolean { - let isInstance = true; - isInstance = isInstance && "meta" in value; - - return isInstance; + if (!('meta' in value)) return false; + return true; } export function DefaultMetaOnlyResponseFromJSON(json: any): DefaultMetaOnlyResponse { @@ -49,7 +47,7 @@ export function DefaultMetaOnlyResponseFromJSON(json: any): DefaultMetaOnlyRespo } export function DefaultMetaOnlyResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): DefaultMetaOnlyResponse { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -67,7 +65,7 @@ export function DefaultMetaOnlyResponseToJSON(value?: DefaultMetaOnlyResponse | } return { - 'meta': ResponseMetaToJSON(value.meta), + 'meta': ResponseMetaToJSON(value['meta']), }; } diff --git a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/DefaultMetaOnlyResponseRecord.ts b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/DefaultMetaOnlyResponseRecord.ts index b59a715e84c9..73ce3a84c712 100644 --- a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/DefaultMetaOnlyResponseRecord.ts +++ b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/DefaultMetaOnlyResponseRecord.ts @@ -46,13 +46,13 @@ knownRecordFactories.set(DefaultMetaOnlyResponseRecordProps.recType, DefaultMeta class DefaultMetaOnlyResponseRecordUtils extends ApiRecordUtils { public normalize(apiObject: DefaultMetaOnlyResponse, asEntity?: boolean): DefaultMetaOnlyResponse { (apiObject as any).recType = DefaultMetaOnlyResponseRecordProps.recType; - responseMetaRecordUtils.normalize(apiObject.meta); + responseMetaRecordUtils.normalize(apiObject['meta']); return apiObject; } public toApi(record: DefaultMetaOnlyResponseRecord): DefaultMetaOnlyResponse { const apiObject = super.toApi(record); - apiObject.meta = responseMetaRecordUtils.toApi(record.meta); + apiObject['meta'] = responseMetaRecordUtils.toApi(record['meta']); return apiObject; } } diff --git a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/FindPetsByStatusResponse.ts b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/FindPetsByStatusResponse.ts index 2107c98467d0..2ee087651466 100644 --- a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/FindPetsByStatusResponse.ts +++ b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/FindPetsByStatusResponse.ts @@ -50,10 +50,8 @@ export interface FindPetsByStatusResponse { * Check if a given object implements the FindPetsByStatusResponse interface. */ export function instanceOfFindPetsByStatusResponse(value: object): boolean { - let isInstance = true; - isInstance = isInstance && "meta" in value; - - return isInstance; + if (!('meta' in value)) return false; + return true; } export function FindPetsByStatusResponseFromJSON(json: any): FindPetsByStatusResponse { @@ -61,7 +59,7 @@ export function FindPetsByStatusResponseFromJSON(json: any): FindPetsByStatusRes } export function FindPetsByStatusResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): FindPetsByStatusResponse { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -80,8 +78,8 @@ export function FindPetsByStatusResponseToJSON(value?: FindPetsByStatusResponse } return { - 'meta': ResponseMetaToJSON(value.meta), - 'data': value.data === undefined ? undefined : ((value.data as Array).map(PetToJSON)), + 'meta': ResponseMetaToJSON(value['meta']), + 'data': !exists(value, 'data') ? undefined : ((value['data'] as Array).map(PetToJSON)), }; } diff --git a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/FindPetsByStatusResponseRecord.ts b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/FindPetsByStatusResponseRecord.ts index 3ac38102f828..f22a5c3f59cb 100644 --- a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/FindPetsByStatusResponseRecord.ts +++ b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/FindPetsByStatusResponseRecord.ts @@ -54,15 +54,15 @@ knownRecordFactories.set(FindPetsByStatusResponseRecordProps.recType, FindPetsBy class FindPetsByStatusResponseRecordUtils extends ApiRecordUtils { public normalize(apiObject: FindPetsByStatusResponse, asEntity?: boolean): FindPetsByStatusResponse { (apiObject as any).recType = FindPetsByStatusResponseRecordProps.recType; - responseMetaRecordUtils.normalize(apiObject.meta); - if (apiObject.data) { petRecordUtils.normalizeArray(apiObject.data); } + responseMetaRecordUtils.normalize(apiObject['meta']); + if (apiObject['data']) { petRecordUtils.normalizeArray(apiObject['data']); } return apiObject; } public toApi(record: FindPetsByStatusResponseRecord): FindPetsByStatusResponse { const apiObject = super.toApi(record); - apiObject.meta = responseMetaRecordUtils.toApi(record.meta); - if (record.data) { apiObject.data = petRecordUtils.toApiArray(record.data); } + apiObject['meta'] = responseMetaRecordUtils.toApi(record['meta']); + if (record['data']) { apiObject['data'] = petRecordUtils.toApiArray(record['data']); } return apiObject; } diff --git a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/FindPetsByUserResponse.ts b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/FindPetsByUserResponse.ts index 4099b1572004..49f4d6f17560 100644 --- a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/FindPetsByUserResponse.ts +++ b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/FindPetsByUserResponse.ts @@ -50,10 +50,8 @@ export interface FindPetsByUserResponse { * Check if a given object implements the FindPetsByUserResponse interface. */ export function instanceOfFindPetsByUserResponse(value: object): boolean { - let isInstance = true; - isInstance = isInstance && "meta" in value; - - return isInstance; + if (!('meta' in value)) return false; + return true; } export function FindPetsByUserResponseFromJSON(json: any): FindPetsByUserResponse { @@ -61,7 +59,7 @@ export function FindPetsByUserResponseFromJSON(json: any): FindPetsByUserRespons } export function FindPetsByUserResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): FindPetsByUserResponse { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -80,8 +78,8 @@ export function FindPetsByUserResponseToJSON(value?: FindPetsByUserResponse | nu } return { - 'meta': ResponseMetaToJSON(value.meta), - 'data': value.data === undefined ? undefined : ((value.data as Array).map(UserToJSON)), + 'meta': ResponseMetaToJSON(value['meta']), + 'data': !exists(value, 'data') ? undefined : ((value['data'] as Array).map(UserToJSON)), }; } diff --git a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/FindPetsByUserResponseRecord.ts b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/FindPetsByUserResponseRecord.ts index b1cddadbf548..0af0862472d9 100644 --- a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/FindPetsByUserResponseRecord.ts +++ b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/FindPetsByUserResponseRecord.ts @@ -54,15 +54,15 @@ knownRecordFactories.set(FindPetsByUserResponseRecordProps.recType, FindPetsByUs class FindPetsByUserResponseRecordUtils extends ApiRecordUtils { public normalize(apiObject: FindPetsByUserResponse, asEntity?: boolean): FindPetsByUserResponse { (apiObject as any).recType = FindPetsByUserResponseRecordProps.recType; - responseMetaRecordUtils.normalize(apiObject.meta); - if (apiObject.data) { userRecordUtils.normalizeArray(apiObject.data); } + responseMetaRecordUtils.normalize(apiObject['meta']); + if (apiObject['data']) { userRecordUtils.normalizeArray(apiObject['data']); } return apiObject; } public toApi(record: FindPetsByUserResponseRecord): FindPetsByUserResponse { const apiObject = super.toApi(record); - apiObject.meta = responseMetaRecordUtils.toApi(record.meta); - if (record.data) { apiObject.data = userRecordUtils.toApiArray(record.data); } + apiObject['meta'] = responseMetaRecordUtils.toApi(record['meta']); + if (record['data']) { apiObject['data'] = userRecordUtils.toApiArray(record['data']); } return apiObject; } diff --git a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/GetBehaviorPermissionsResponse.ts b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/GetBehaviorPermissionsResponse.ts index ef11201e782a..10e2de71adc1 100644 --- a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/GetBehaviorPermissionsResponse.ts +++ b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/GetBehaviorPermissionsResponse.ts @@ -44,10 +44,8 @@ export interface GetBehaviorPermissionsResponse { * Check if a given object implements the GetBehaviorPermissionsResponse interface. */ export function instanceOfGetBehaviorPermissionsResponse(value: object): boolean { - let isInstance = true; - isInstance = isInstance && "meta" in value; - - return isInstance; + if (!('meta' in value)) return false; + return true; } export function GetBehaviorPermissionsResponseFromJSON(json: any): GetBehaviorPermissionsResponse { @@ -55,7 +53,7 @@ export function GetBehaviorPermissionsResponseFromJSON(json: any): GetBehaviorPe } export function GetBehaviorPermissionsResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): GetBehaviorPermissionsResponse { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -74,8 +72,8 @@ export function GetBehaviorPermissionsResponseToJSON(value?: GetBehaviorPermissi } return { - 'meta': ResponseMetaToJSON(value.meta), - 'data': value.data, + 'meta': ResponseMetaToJSON(value['meta']), + 'data': value['data'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/GetBehaviorPermissionsResponseRecord.ts b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/GetBehaviorPermissionsResponseRecord.ts index eb7f7fdd70f0..1769f9ba5b39 100644 --- a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/GetBehaviorPermissionsResponseRecord.ts +++ b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/GetBehaviorPermissionsResponseRecord.ts @@ -47,13 +47,13 @@ knownRecordFactories.set(GetBehaviorPermissionsResponseRecordProps.recType, GetB class GetBehaviorPermissionsResponseRecordUtils extends ApiRecordUtils { public normalize(apiObject: GetBehaviorPermissionsResponse, asEntity?: boolean): GetBehaviorPermissionsResponse { (apiObject as any).recType = GetBehaviorPermissionsResponseRecordProps.recType; - responseMetaRecordUtils.normalize(apiObject.meta); + responseMetaRecordUtils.normalize(apiObject['meta']); return apiObject; } public toApi(record: GetBehaviorPermissionsResponseRecord): GetBehaviorPermissionsResponse { const apiObject = super.toApi(record); - apiObject.meta = responseMetaRecordUtils.toApi(record.meta); + apiObject['meta'] = responseMetaRecordUtils.toApi(record['meta']); return apiObject; } diff --git a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/GetBehaviorTypeResponse.ts b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/GetBehaviorTypeResponse.ts index 214cef0177ad..d280962cf133 100644 --- a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/GetBehaviorTypeResponse.ts +++ b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/GetBehaviorTypeResponse.ts @@ -50,10 +50,8 @@ export interface GetBehaviorTypeResponse { * Check if a given object implements the GetBehaviorTypeResponse interface. */ export function instanceOfGetBehaviorTypeResponse(value: object): boolean { - let isInstance = true; - isInstance = isInstance && "meta" in value; - - return isInstance; + if (!('meta' in value)) return false; + return true; } export function GetBehaviorTypeResponseFromJSON(json: any): GetBehaviorTypeResponse { @@ -61,7 +59,7 @@ export function GetBehaviorTypeResponseFromJSON(json: any): GetBehaviorTypeRespo } export function GetBehaviorTypeResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): GetBehaviorTypeResponse { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -80,8 +78,8 @@ export function GetBehaviorTypeResponseToJSON(value?: GetBehaviorTypeResponse | } return { - 'meta': ResponseMetaToJSON(value.meta), - 'data': BehaviorTypeToJSON(value.data), + 'meta': ResponseMetaToJSON(value['meta']), + 'data': BehaviorTypeToJSON(value['data']), }; } diff --git a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/GetBehaviorTypeResponseRecord.ts b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/GetBehaviorTypeResponseRecord.ts index 7113f4a6aa24..55990ad5dcb0 100644 --- a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/GetBehaviorTypeResponseRecord.ts +++ b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/GetBehaviorTypeResponseRecord.ts @@ -50,13 +50,13 @@ knownRecordFactories.set(GetBehaviorTypeResponseRecordProps.recType, GetBehavior class GetBehaviorTypeResponseRecordUtils extends ApiRecordUtils { public normalize(apiObject: GetBehaviorTypeResponse, asEntity?: boolean): GetBehaviorTypeResponse { (apiObject as any).recType = GetBehaviorTypeResponseRecordProps.recType; - responseMetaRecordUtils.normalize(apiObject.meta); + responseMetaRecordUtils.normalize(apiObject['meta']); return apiObject; } public toApi(record: GetBehaviorTypeResponseRecord): GetBehaviorTypeResponse { const apiObject = super.toApi(record); - apiObject.meta = responseMetaRecordUtils.toApi(record.meta); + apiObject['meta'] = responseMetaRecordUtils.toApi(record['meta']); return apiObject; } diff --git a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/GetMatchingPartsResponse.ts b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/GetMatchingPartsResponse.ts index d40586e60fc6..853ac803fd01 100644 --- a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/GetMatchingPartsResponse.ts +++ b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/GetMatchingPartsResponse.ts @@ -50,10 +50,8 @@ export interface GetMatchingPartsResponse { * Check if a given object implements the GetMatchingPartsResponse interface. */ export function instanceOfGetMatchingPartsResponse(value: object): boolean { - let isInstance = true; - isInstance = isInstance && "meta" in value; - - return isInstance; + if (!('meta' in value)) return false; + return true; } export function GetMatchingPartsResponseFromJSON(json: any): GetMatchingPartsResponse { @@ -61,7 +59,7 @@ export function GetMatchingPartsResponseFromJSON(json: any): GetMatchingPartsRes } export function GetMatchingPartsResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): GetMatchingPartsResponse { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -80,8 +78,8 @@ export function GetMatchingPartsResponseToJSON(value?: GetMatchingPartsResponse } return { - 'meta': ResponseMetaToJSON(value.meta), - 'data': MatchingPartsToJSON(value.data), + 'meta': ResponseMetaToJSON(value['meta']), + 'data': MatchingPartsToJSON(value['data']), }; } diff --git a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/GetMatchingPartsResponseRecord.ts b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/GetMatchingPartsResponseRecord.ts index 6b73951b1dfa..23663535b8cc 100644 --- a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/GetMatchingPartsResponseRecord.ts +++ b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/GetMatchingPartsResponseRecord.ts @@ -54,15 +54,15 @@ knownRecordFactories.set(GetMatchingPartsResponseRecordProps.recType, GetMatchin class GetMatchingPartsResponseRecordUtils extends ApiRecordUtils { public normalize(apiObject: GetMatchingPartsResponse, asEntity?: boolean): GetMatchingPartsResponse { (apiObject as any).recType = GetMatchingPartsResponseRecordProps.recType; - responseMetaRecordUtils.normalize(apiObject.meta); - if (apiObject.data) { matchingPartsRecordUtils.normalize(apiObject.data); } + responseMetaRecordUtils.normalize(apiObject['meta']); + if (apiObject['data']) { matchingPartsRecordUtils.normalize(apiObject['data']); } return apiObject; } public toApi(record: GetMatchingPartsResponseRecord): GetMatchingPartsResponse { const apiObject = super.toApi(record); - apiObject.meta = responseMetaRecordUtils.toApi(record.meta); - if (record.data) { apiObject.data = matchingPartsRecordUtils.toApi(record.data); } + apiObject['meta'] = responseMetaRecordUtils.toApi(record['meta']); + if (record['data']) { apiObject['data'] = matchingPartsRecordUtils.toApi(record['data']); } return apiObject; } diff --git a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/GetPetPartTypeResponse.ts b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/GetPetPartTypeResponse.ts index 01927a668ec4..b39830b4601e 100644 --- a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/GetPetPartTypeResponse.ts +++ b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/GetPetPartTypeResponse.ts @@ -50,10 +50,8 @@ export interface GetPetPartTypeResponse { * Check if a given object implements the GetPetPartTypeResponse interface. */ export function instanceOfGetPetPartTypeResponse(value: object): boolean { - let isInstance = true; - isInstance = isInstance && "meta" in value; - - return isInstance; + if (!('meta' in value)) return false; + return true; } export function GetPetPartTypeResponseFromJSON(json: any): GetPetPartTypeResponse { @@ -61,7 +59,7 @@ export function GetPetPartTypeResponseFromJSON(json: any): GetPetPartTypeRespons } export function GetPetPartTypeResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): GetPetPartTypeResponse { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -80,8 +78,8 @@ export function GetPetPartTypeResponseToJSON(value?: GetPetPartTypeResponse | nu } return { - 'meta': ResponseMetaToJSON(value.meta), - 'data': PetPartTypeToJSON(value.data), + 'meta': ResponseMetaToJSON(value['meta']), + 'data': PetPartTypeToJSON(value['data']), }; } diff --git a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/GetPetPartTypeResponseRecord.ts b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/GetPetPartTypeResponseRecord.ts index 69caf5d05462..57d64200571a 100644 --- a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/GetPetPartTypeResponseRecord.ts +++ b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/GetPetPartTypeResponseRecord.ts @@ -50,13 +50,13 @@ knownRecordFactories.set(GetPetPartTypeResponseRecordProps.recType, GetPetPartTy class GetPetPartTypeResponseRecordUtils extends ApiRecordUtils { public normalize(apiObject: GetPetPartTypeResponse, asEntity?: boolean): GetPetPartTypeResponse { (apiObject as any).recType = GetPetPartTypeResponseRecordProps.recType; - responseMetaRecordUtils.normalize(apiObject.meta); + responseMetaRecordUtils.normalize(apiObject['meta']); return apiObject; } public toApi(record: GetPetPartTypeResponseRecord): GetPetPartTypeResponse { const apiObject = super.toApi(record); - apiObject.meta = responseMetaRecordUtils.toApi(record.meta); + apiObject['meta'] = responseMetaRecordUtils.toApi(record['meta']); return apiObject; } diff --git a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/ItemId.ts b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/ItemId.ts index d1ab620bef61..69621e5eb7d7 100644 --- a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/ItemId.ts +++ b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/ItemId.ts @@ -37,11 +37,9 @@ export interface ItemId { * Check if a given object implements the ItemId interface. */ export function instanceOfItemId(value: object): boolean { - let isInstance = true; - isInstance = isInstance && "id" in value; - isInstance = isInstance && "type" in value; - - return isInstance; + if (!('id' in value)) return false; + if (!('type' in value)) return false; + return true; } export function ItemIdFromJSON(json: any): ItemId { @@ -49,7 +47,7 @@ export function ItemIdFromJSON(json: any): ItemId { } export function ItemIdFromJSONTyped(json: any, ignoreDiscriminator: boolean): ItemId { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -68,8 +66,8 @@ export function ItemIdToJSON(value?: ItemId | null): any { } return { - 'id': value.id, - 'type': value.type, + 'id': value['id'], + 'type': value['type'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/MatchingParts.ts b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/MatchingParts.ts index 0845256d726a..125d78169bef 100644 --- a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/MatchingParts.ts +++ b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/MatchingParts.ts @@ -44,11 +44,9 @@ export interface MatchingParts { * Check if a given object implements the MatchingParts interface. */ export function instanceOfMatchingParts(value: object): boolean { - let isInstance = true; - isInstance = isInstance && "connected" in value; - isInstance = isInstance && "related" in value; - - return isInstance; + if (!('connected' in value)) return false; + if (!('related' in value)) return false; + return true; } export function MatchingPartsFromJSON(json: any): MatchingParts { @@ -56,7 +54,7 @@ export function MatchingPartsFromJSON(json: any): MatchingParts { } export function MatchingPartsFromJSONTyped(json: any, ignoreDiscriminator: boolean): MatchingParts { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -75,8 +73,8 @@ export function MatchingPartsToJSON(value?: MatchingParts | null): any { } return { - 'connected': ((value.connected as Array).map(PartToJSON)), - 'related': ((value.related as Array).map(PartToJSON)), + 'connected': ((value['connected'] as Array).map(PartToJSON)), + 'related': ((value['related'] as Array).map(PartToJSON)), }; } diff --git a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/MatchingPartsRecord.ts b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/MatchingPartsRecord.ts index edc7d033ebd1..4170d2f84e9e 100644 --- a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/MatchingPartsRecord.ts +++ b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/MatchingPartsRecord.ts @@ -47,15 +47,15 @@ knownRecordFactories.set(MatchingPartsRecordProps.recType, MatchingPartsRecord); class MatchingPartsRecordUtils extends ApiRecordUtils { public normalize(apiObject: MatchingParts, asEntity?: boolean): MatchingParts { (apiObject as any).recType = MatchingPartsRecordProps.recType; - partRecordUtils.normalizeArray(apiObject.connected); - partRecordUtils.normalizeArray(apiObject.related); + partRecordUtils.normalizeArray(apiObject['connected']); + partRecordUtils.normalizeArray(apiObject['related']); return apiObject; } public toApi(record: MatchingPartsRecord): MatchingParts { const apiObject = super.toApi(record); - apiObject.connected = partRecordUtils.toApiArray(record.connected); - apiObject.related = partRecordUtils.toApiArray(record.related); + apiObject['connected'] = partRecordUtils.toApiArray(record['connected']); + apiObject['related'] = partRecordUtils.toApiArray(record['related']); return apiObject; } } diff --git a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/ModelApiResponse.ts b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/ModelApiResponse.ts index bf50981fc2e2..a7fc63d81f1b 100644 --- a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/ModelApiResponse.ts +++ b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/ModelApiResponse.ts @@ -43,9 +43,7 @@ export interface ModelApiResponse { * Check if a given object implements the ModelApiResponse interface. */ export function instanceOfModelApiResponse(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function ModelApiResponseFromJSON(json: any): ModelApiResponse { @@ -53,7 +51,7 @@ export function ModelApiResponseFromJSON(json: any): ModelApiResponse { } export function ModelApiResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): ModelApiResponse { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -73,9 +71,9 @@ export function ModelApiResponseToJSON(value?: ModelApiResponse | null): any { } return { - 'code': value.code, - 'type': value.type, - 'message': value.message, + 'code': value['code'], + 'type': value['type'], + 'message': value['message'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/ModelError.ts b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/ModelError.ts index 84b2bf87bde6..166306af9663 100644 --- a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/ModelError.ts +++ b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/ModelError.ts @@ -56,10 +56,8 @@ export interface ModelError { * Check if a given object implements the ModelError interface. */ export function instanceOfModelError(value: object): boolean { - let isInstance = true; - isInstance = isInstance && "type" in value; - - return isInstance; + if (!('type' in value)) return false; + return true; } export function ModelErrorFromJSON(json: any): ModelError { @@ -67,7 +65,7 @@ export function ModelErrorFromJSON(json: any): ModelError { } export function ModelErrorFromJSONTyped(json: any, ignoreDiscriminator: boolean): ModelError { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -88,10 +86,10 @@ export function ModelErrorToJSON(value?: ModelError | null): any { } return { - 'type': value.type, - 'itemInfo': ItemIdToJSON(value.itemInfo), - 'details': value.details, - 'exception': value.exception, + 'type': value['type'], + 'itemInfo': ItemIdToJSON(value['itemInfo']), + 'details': value['details'], + 'exception': value['exception'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/ModelErrorRecord.ts b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/ModelErrorRecord.ts index 29f964f5f14b..1abeef522e2a 100644 --- a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/ModelErrorRecord.ts +++ b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/ModelErrorRecord.ts @@ -49,13 +49,13 @@ knownRecordFactories.set(ModelErrorRecordProps.recType, ModelErrorRecord); class ModelErrorRecordUtils extends ApiRecordUtils { public normalize(apiObject: ModelError, asEntity?: boolean): ModelError { (apiObject as any).recType = ModelErrorRecordProps.recType; - if (apiObject.itemInfo) { itemIdRecordUtils.normalize(apiObject.itemInfo); } + if (apiObject['itemInfo']) { itemIdRecordUtils.normalize(apiObject['itemInfo']); } return apiObject; } public toApi(record: ModelErrorRecord): ModelError { const apiObject = super.toApi(record); - if (record.itemInfo) { apiObject.itemInfo = itemIdRecordUtils.toApi(record.itemInfo); } + if (record['itemInfo']) { apiObject['itemInfo'] = itemIdRecordUtils.toApi(record['itemInfo']); } return apiObject; } } diff --git a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/Order.ts b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/Order.ts index 0d69755d4887..9e12fc242793 100644 --- a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/Order.ts +++ b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/Order.ts @@ -73,9 +73,7 @@ export type OrderStatusEnum = typeof OrderStatusEnum[keyof typeof OrderStatusEnu * Check if a given object implements the Order interface. */ export function instanceOfOrder(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function OrderFromJSON(json: any): Order { @@ -83,7 +81,7 @@ export function OrderFromJSON(json: any): Order { } export function OrderFromJSONTyped(json: any, ignoreDiscriminator: boolean): Order { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -106,12 +104,12 @@ export function OrderToJSON(value?: Order | null): any { } return { - 'id': value.id, - 'petId': value.petId, - 'quantity': value.quantity, - 'shipDate': value.shipDate === undefined ? undefined : (value.shipDate.toISOString()), - 'status': value.status, - 'complete': value.complete, + 'id': value['id'], + 'petId': value['petId'], + 'quantity': value['quantity'], + 'shipDate': !exists(value, 'shipDate') ? undefined : ((value['shipDate']).toISOString()), + 'status': value['status'], + 'complete': value['complete'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/OrderRecord.ts b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/OrderRecord.ts index 0d4f6e0b4429..a0ddf05e1ed8 100644 --- a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/OrderRecord.ts +++ b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/OrderRecord.ts @@ -55,7 +55,7 @@ knownRecordFactories.set(OrderRecordEntityProps.recType, OrderRecordEntity); class OrderRecordUtils extends ApiRecordUtils { public normalize(apiObject: Order, asEntity?: boolean): Order { (apiObject as any).recType = asEntity ? OrderRecordEntityProps.recType : OrderRecordProps.recType; - if (apiObject.id) { (apiObject as any).id = apiObject.id.toString(); } + if (apiObject['id']) { (apiObject as any)['id'] = apiObject['id'].toString(); } return apiObject; } @@ -99,7 +99,7 @@ class OrderRecordUtils extends ApiRecordUtils { public toApi(record: OrderRecord): Order { const apiObject = super.toApi(record); - if (record.id) { apiObject.id = parseFloat(record.id); } + if (record['id']) { apiObject['id'] = parseFloat(record['id']); } return apiObject; } } diff --git a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/Part.ts b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/Part.ts index bf4efc34277a..15f467e89f82 100644 --- a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/Part.ts +++ b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/Part.ts @@ -37,11 +37,9 @@ export interface Part { * Check if a given object implements the Part interface. */ export function instanceOfPart(value: object): boolean { - let isInstance = true; - isInstance = isInstance && "id" in value; - isInstance = isInstance && "name" in value; - - return isInstance; + if (!('id' in value)) return false; + if (!('name' in value)) return false; + return true; } export function PartFromJSON(json: any): Part { @@ -49,7 +47,7 @@ export function PartFromJSON(json: any): Part { } export function PartFromJSONTyped(json: any, ignoreDiscriminator: boolean): Part { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -68,8 +66,8 @@ export function PartToJSON(value?: Part | null): any { } return { - 'id': value.id, - 'name': value.name, + 'id': value['id'], + 'name': value['name'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/PartRecord.ts b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/PartRecord.ts index 0bbd36a831a9..539b8094c7a7 100644 --- a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/PartRecord.ts +++ b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/PartRecord.ts @@ -40,13 +40,13 @@ knownRecordFactories.set(PartRecordProps.recType, PartRecord); class PartRecordUtils extends ApiRecordUtils { public normalize(apiObject: Part, asEntity?: boolean): Part { (apiObject as any).recType = PartRecordProps.recType; - (apiObject as any).id = apiObject.id.toString(); + (apiObject as any)['id'] = apiObject['id'].toString(); return apiObject; } public toApi(record: PartRecord): Part { const apiObject = super.toApi(record); - apiObject.id = parseFloat(record.id); + apiObject['id'] = parseFloat(record['id']); return apiObject; } } diff --git a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/Pet.ts b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/Pet.ts index dcf617888bfd..c24da6bcb476 100644 --- a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/Pet.ts +++ b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/Pet.ts @@ -188,23 +188,21 @@ export type PetStatusEnum = typeof PetStatusEnum[keyof typeof PetStatusEnum]; * Check if a given object implements the Pet interface. */ export function instanceOfPet(value: object): boolean { - let isInstance = true; - isInstance = isInstance && "id" in value; - isInstance = isInstance && "otherFriendIds" in value; - isInstance = isInstance && "friendAge" in value; - isInstance = isInstance && "age" in value; - isInstance = isInstance && "isHappy" in value; - isInstance = isInstance && "isTall" in value; - isInstance = isInstance && "category" in value; - isInstance = isInstance && "name" in value; - isInstance = isInstance && "photoUrls" in value; - isInstance = isInstance && "warningStatus" in value; - isInstance = isInstance && "alternateStatus" in value; - isInstance = isInstance && "otherDepStatuses" in value; - isInstance = isInstance && "tags" in value; - isInstance = isInstance && "status" in value; - - return isInstance; + if (!('id' in value)) return false; + if (!('otherFriendIds' in value)) return false; + if (!('friendAge' in value)) return false; + if (!('age' in value)) return false; + if (!('isHappy' in value)) return false; + if (!('isTall' in value)) return false; + if (!('category' in value)) return false; + if (!('name' in value)) return false; + if (!('photoUrls' in value)) return false; + if (!('warningStatus' in value)) return false; + if (!('alternateStatus' in value)) return false; + if (!('otherDepStatuses' in value)) return false; + if (!('tags' in value)) return false; + if (!('status' in value)) return false; + return true; } export function PetFromJSON(json: any): Pet { @@ -212,7 +210,7 @@ export function PetFromJSON(json: any): Pet { } export function PetFromJSONTyped(json: any, ignoreDiscriminator: boolean): Pet { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -250,27 +248,27 @@ export function PetToJSON(value?: Pet | null): any { } return { - 'id': value.id, - 'friendId': value.friendId, - 'otherFriendIds': value.otherFriendIds, - 'friendAge': value.friendAge, - 'age': value.age, - 'isHappy': value.isHappy, - 'isTall': value.isTall, - 'category': CategoryToJSON(value.category), - 'optionalCategory': CategoryToJSON(value.optionalCategory), - 'name': value.name, - 'entries': value._entries === undefined ? undefined : ((value._entries as Array).map(CategoryToJSON)), - 'surname': value.surname, - 'photoUrls': value.photoUrls, - 'warningStatus': WarningCodeToJSON(value.warningStatus), - 'depStatus': DeploymentRequestStatusToJSON(value.depStatus), - 'alternateStatus': DeploymentRequestStatusToJSON(value.alternateStatus), - 'otherDepStatuses': ((value.otherDepStatuses as Array).map(DeploymentRequestStatusToJSON)), - 'tags': ((value.tags as Array).map(TagToJSON)), - 'optionalTags': value.optionalTags === undefined ? undefined : ((value.optionalTags as Array).map(TagToJSON)), - 'status': value.status, - 'regions': value.regions, + 'id': value['id'], + 'friendId': value['friendId'], + 'otherFriendIds': value['otherFriendIds'], + 'friendAge': value['friendAge'], + 'age': value['age'], + 'isHappy': value['isHappy'], + 'isTall': value['isTall'], + 'category': CategoryToJSON(value['category']), + 'optionalCategory': CategoryToJSON(value['optionalCategory']), + 'name': value['name'], + 'entries': !exists(value, '_entries') ? undefined : ((value['_entries'] as Array).map(CategoryToJSON)), + 'surname': value['surname'], + 'photoUrls': value['photoUrls'], + 'warningStatus': WarningCodeToJSON(value['warningStatus']), + 'depStatus': DeploymentRequestStatusToJSON(value['depStatus']), + 'alternateStatus': DeploymentRequestStatusToJSON(value['alternateStatus']), + 'otherDepStatuses': ((value['otherDepStatuses'] as Array).map(DeploymentRequestStatusToJSON)), + 'tags': ((value['tags'] as Array).map(TagToJSON)), + 'optionalTags': !exists(value, 'optionalTags') ? undefined : ((value['optionalTags'] as Array).map(TagToJSON)), + 'status': value['status'], + 'regions': value['regions'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/PetRecord.ts b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/PetRecord.ts index 5f5348e24546..9c114b14d0f4 100644 --- a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/PetRecord.ts +++ b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/PetRecord.ts @@ -95,15 +95,15 @@ knownRecordFactories.set(PetRecordEntityProps.recType, PetRecordEntity); class PetRecordUtils extends ApiRecordUtils { public normalize(apiObject: Pet, asEntity?: boolean): Pet { (apiObject as any).recType = asEntity ? PetRecordEntityProps.recType : PetRecordProps.recType; - (apiObject as any).id = apiObject.id.toString(); - if (apiObject.friendId) { (apiObject as any).friendId = apiObject.friendId.toString(); } - (apiObject as any).otherFriendIds = apiObject.otherFriendIds.map(item => item?.toString()); - categoryRecordUtils.normalize(apiObject.category); - if (apiObject.optionalCategory) { categoryRecordUtils.normalize(apiObject.optionalCategory); } - if (apiObject._entries) { categoryRecordUtils.normalizeArray(apiObject._entries); } - tagRecordUtils.normalizeArray(apiObject.tags); - if (apiObject.optionalTags) { tagRecordUtils.normalizeArray(apiObject.optionalTags); } - if (apiObject.regions) { (apiObject as any).regions = apiObject.regions.map(item => item.map(item2 => item2?.toString())); } + (apiObject as any)['id'] = apiObject['id'].toString(); + if (apiObject['friendId']) { (apiObject as any)['friendId'] = apiObject['friendId'].toString(); } + (apiObject as any)['otherFriendIds'] = apiObject['otherFriendIds'].map(item => item?.toString()); + categoryRecordUtils.normalize(apiObject['category']); + if (apiObject['optionalCategory']) { categoryRecordUtils.normalize(apiObject['optionalCategory']); } + if (apiObject['_entries']) { categoryRecordUtils.normalizeArray(apiObject['_entries']); } + tagRecordUtils.normalizeArray(apiObject['tags']); + if (apiObject['optionalTags']) { tagRecordUtils.normalizeArray(apiObject['optionalTags']); } + if (apiObject['regions']) { (apiObject as any)['regions'] = apiObject['regions'].map(item => item.map(item2 => item2?.toString())); } return apiObject; } @@ -135,15 +135,15 @@ class PetRecordUtils extends ApiRecordUtils { const entityProperties = { // @ts-ignore - category: yield call(categoryRecordUtils.toInlined, entity.category), + category: yield call(categoryRecordUtils.toInlined, entity['category']), // @ts-ignore - optionalCategory: entity.optionalCategory ? yield call(categoryRecordUtils.toInlined, entity.optionalCategory) : null, + optionalCategory: entity['optionalCategory'] ? yield call(categoryRecordUtils.toInlined, entity['optionalCategory']) : null, // @ts-ignore - _entries: entity._entries ? yield call(categoryRecordUtils.toInlinedArray, entity._entries) : null, + _entries: entity['_entries'] ? yield call(categoryRecordUtils.toInlinedArray, entity['_entries']) : null, // @ts-ignore - tags: yield call(tagRecordUtils.toInlinedArray, entity.tags), + tags: yield call(tagRecordUtils.toInlinedArray, entity['tags']), // @ts-ignore - optionalTags: entity.optionalTags ? yield call(tagRecordUtils.toInlinedArray, entity.optionalTags) : null, + optionalTags: entity['optionalTags'] ? yield call(tagRecordUtils.toInlinedArray, entity['optionalTags']) : null, } return PetRecord({ @@ -167,15 +167,15 @@ class PetRecordUtils extends ApiRecordUtils { public toApi(record: PetRecord): Pet { const apiObject = super.toApi(record); - apiObject.id = parseFloat(record.id); - if (record.friendId) { apiObject.friendId = parseFloat(record.friendId); } - apiObject.otherFriendIds = record.otherFriendIds.map(item => (item ? parseFloat(item) : null) as number).toArray(); - apiObject.category = categoryRecordUtils.toApi(record.category); - if (record.optionalCategory) { apiObject.optionalCategory = categoryRecordUtils.toApi(record.optionalCategory); } - if (record._entries) { apiObject._entries = categoryRecordUtils.toApiArray(record._entries); } - apiObject.tags = tagRecordUtils.toApiArray(record.tags); - if (record.optionalTags) { apiObject.optionalTags = tagRecordUtils.toApiArray(record.optionalTags); } - if (record.regions) { apiObject.regions = record.regions.map(item => item.toArray().map(item2 => (item2 ? parseFloat(item2) : null) as number)).toArray(); } + apiObject['id'] = parseFloat(record['id']); + if (record['friendId']) { apiObject['friendId'] = parseFloat(record['friendId']); } + apiObject['otherFriendIds'] = record['otherFriendIds'].map(item => (item ? parseFloat(item) : null) as number).toArray(); + apiObject['category'] = categoryRecordUtils.toApi(record['category']); + if (record['optionalCategory']) { apiObject['optionalCategory'] = categoryRecordUtils.toApi(record['optionalCategory']); } + if (record['_entries']) { apiObject['_entries'] = categoryRecordUtils.toApiArray(record['_entries']); } + apiObject['tags'] = tagRecordUtils.toApiArray(record['tags']); + if (record['optionalTags']) { apiObject['optionalTags'] = tagRecordUtils.toApiArray(record['optionalTags']); } + if (record['regions']) { apiObject['regions'] = record['regions'].map(item => item.toArray().map(item2 => (item2 ? parseFloat(item2) : null) as number)).toArray(); } return apiObject; } } diff --git a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/PetRegionsResponse.ts b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/PetRegionsResponse.ts index bca0ee3d8851..cccb23bc1c54 100644 --- a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/PetRegionsResponse.ts +++ b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/PetRegionsResponse.ts @@ -44,10 +44,8 @@ export interface PetRegionsResponse { * Check if a given object implements the PetRegionsResponse interface. */ export function instanceOfPetRegionsResponse(value: object): boolean { - let isInstance = true; - isInstance = isInstance && "meta" in value; - - return isInstance; + if (!('meta' in value)) return false; + return true; } export function PetRegionsResponseFromJSON(json: any): PetRegionsResponse { @@ -55,7 +53,7 @@ export function PetRegionsResponseFromJSON(json: any): PetRegionsResponse { } export function PetRegionsResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): PetRegionsResponse { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -74,8 +72,8 @@ export function PetRegionsResponseToJSON(value?: PetRegionsResponse | null): any } return { - 'meta': ResponseMetaToJSON(value.meta), - 'data': value.data, + 'meta': ResponseMetaToJSON(value['meta']), + 'data': value['data'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/PetRegionsResponseRecord.ts b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/PetRegionsResponseRecord.ts index a56180207a55..df2bcc6d3cb2 100644 --- a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/PetRegionsResponseRecord.ts +++ b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/PetRegionsResponseRecord.ts @@ -47,15 +47,15 @@ knownRecordFactories.set(PetRegionsResponseRecordProps.recType, PetRegionsRespon class PetRegionsResponseRecordUtils extends ApiRecordUtils { public normalize(apiObject: PetRegionsResponse, asEntity?: boolean): PetRegionsResponse { (apiObject as any).recType = PetRegionsResponseRecordProps.recType; - responseMetaRecordUtils.normalize(apiObject.meta); - if (apiObject.data) { (apiObject as any).data = apiObject.data.map(item => item.map(item2 => item2?.toString())); } + responseMetaRecordUtils.normalize(apiObject['meta']); + if (apiObject['data']) { (apiObject as any)['data'] = apiObject['data'].map(item => item.map(item2 => item2?.toString())); } return apiObject; } public toApi(record: PetRegionsResponseRecord): PetRegionsResponse { const apiObject = super.toApi(record); - apiObject.meta = responseMetaRecordUtils.toApi(record.meta); - if (record.data) { apiObject.data = record.data.map(item => item.toArray().map(item2 => (item2 ? parseFloat(item2) : null) as number)).toArray(); } + apiObject['meta'] = responseMetaRecordUtils.toApi(record['meta']); + if (record['data']) { apiObject['data'] = record['data'].map(item => item.toArray().map(item2 => (item2 ? parseFloat(item2) : null) as number)).toArray(); } return apiObject; } diff --git a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/ResponseMeta.ts b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/ResponseMeta.ts index 5ac4b74ecf52..b0049adc685f 100644 --- a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/ResponseMeta.ts +++ b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/ResponseMeta.ts @@ -100,10 +100,8 @@ export type ResponseMetaCodeEnum = typeof ResponseMetaCodeEnum[keyof typeof Resp * Check if a given object implements the ResponseMeta interface. */ export function instanceOfResponseMeta(value: object): boolean { - let isInstance = true; - isInstance = isInstance && "code" in value; - - return isInstance; + if (!('code' in value)) return false; + return true; } export function ResponseMetaFromJSON(json: any): ResponseMeta { @@ -111,7 +109,7 @@ export function ResponseMetaFromJSON(json: any): ResponseMeta { } export function ResponseMetaFromJSONTyped(json: any, ignoreDiscriminator: boolean): ResponseMeta { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -134,12 +132,12 @@ export function ResponseMetaToJSON(value?: ResponseMeta | null): any { } return { - 'code': value.code, - 'detail': value.detail, - 'exception': value.exception, - 'type': value.type, - 'errorCode': ErrorCodeToJSON(value.errorCode), - 'errors': value.errors, + 'code': value['code'], + 'detail': value['detail'], + 'exception': value['exception'], + 'type': value['type'], + 'errorCode': ErrorCodeToJSON(value['errorCode']), + 'errors': value['errors'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/Tag.ts b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/Tag.ts index e4902aa53cfd..24a25f383dba 100644 --- a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/Tag.ts +++ b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/Tag.ts @@ -37,9 +37,7 @@ export interface Tag { * Check if a given object implements the Tag interface. */ export function instanceOfTag(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function TagFromJSON(json: any): Tag { @@ -47,7 +45,7 @@ export function TagFromJSON(json: any): Tag { } export function TagFromJSONTyped(json: any, ignoreDiscriminator: boolean): Tag { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -66,8 +64,8 @@ export function TagToJSON(value?: Tag | null): any { } return { - 'id': value.id, - 'name': value.name, + 'id': value['id'], + 'name': value['name'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/TagRecord.ts b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/TagRecord.ts index 40e790f3c578..64f36c334a24 100644 --- a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/TagRecord.ts +++ b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/TagRecord.ts @@ -50,7 +50,7 @@ knownRecordFactories.set(TagRecordEntityProps.recType, TagRecordEntity); class TagRecordUtils extends ApiRecordUtils { public normalize(apiObject: Tag, asEntity?: boolean): Tag { (apiObject as any).recType = asEntity ? TagRecordEntityProps.recType : TagRecordProps.recType; - if (apiObject.id) { (apiObject as any).id = apiObject.id.toString(); } + if (apiObject['id']) { (apiObject as any)['id'] = apiObject['id'].toString(); } return apiObject; } @@ -94,7 +94,7 @@ class TagRecordUtils extends ApiRecordUtils { public toApi(record: TagRecord): Tag { const apiObject = super.toApi(record); - if (record.id) { apiObject.id = parseFloat(record.id); } + if (record['id']) { apiObject['id'] = parseFloat(record['id']); } return apiObject; } } diff --git a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/User.ts b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/User.ts index ceeea2540716..9f4c7d4d4c17 100644 --- a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/User.ts +++ b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/User.ts @@ -85,11 +85,9 @@ export interface User { * Check if a given object implements the User interface. */ export function instanceOfUser(value: object): boolean { - let isInstance = true; - isInstance = isInstance && "id" in value; - isInstance = isInstance && "subUser2" in value; - - return isInstance; + if (!('id' in value)) return false; + if (!('subUser2' in value)) return false; + return true; } export function UserFromJSON(json: any): User { @@ -97,7 +95,7 @@ export function UserFromJSON(json: any): User { } export function UserFromJSONTyped(json: any, ignoreDiscriminator: boolean): User { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -124,16 +122,16 @@ export function UserToJSON(value?: User | null): any { } return { - 'id': value.id, - 'username': value.username, - 'firstName': value.firstName, - 'lastName': value.lastName, - 'email': value.email, - 'password': value.password, - 'phone': value.phone, - 'userStatus': value.userStatus, - 'subUser': UserToJSON(value.subUser), - 'subUser2': UserToJSON(value.subUser2), + 'id': value['id'], + 'username': value['username'], + 'firstName': value['firstName'], + 'lastName': value['lastName'], + 'email': value['email'], + 'password': value['password'], + 'phone': value['phone'], + 'userStatus': value['userStatus'], + 'subUser': UserToJSON(value['subUser']), + 'subUser2': UserToJSON(value['subUser2']), }; } diff --git a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/UserRecord.ts b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/UserRecord.ts index 59d9cba4b3ec..399720f55ea7 100644 --- a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/UserRecord.ts +++ b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/models/UserRecord.ts @@ -58,7 +58,7 @@ knownRecordFactories.set(UserRecordEntityProps.recType, UserRecordEntity); class UserRecordUtils extends ApiRecordUtils { public normalize(apiObject: User, asEntity?: boolean): User { (apiObject as any).recType = asEntity ? UserRecordEntityProps.recType : UserRecordProps.recType; - (apiObject as any).id = apiObject.id.toString(); + (apiObject as any)['id'] = apiObject['id'].toString(); return apiObject; } @@ -102,7 +102,7 @@ class UserRecordUtils extends ApiRecordUtils { public toApi(record: UserRecord): User { const apiObject = super.toApi(record); - apiObject.id = parseFloat(record.id); + apiObject['id'] = parseFloat(record['id']); return apiObject; } } diff --git a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/runtime.ts b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/runtime.ts index 71ecdb875d14..813bf0fb4dfe 100644 --- a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/runtime.ts @@ -310,9 +310,9 @@ export interface RequestOpts { body?: HTTPBody; } -export function exists(json: any, key: string) { +export function exists(json: any, key: string): boolean { const value = json[key]; - return value !== null && value !== undefined; + return value !== undefined && value !== null; } export function querystring(params: HTTPQuery, prefix: string = ''): string { diff --git a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/apis/AnotherFakeApi.ts b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/apis/AnotherFakeApi.ts index 4248cc6d062e..cec7e569d020 100644 --- a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/apis/AnotherFakeApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/apis/AnotherFakeApi.ts @@ -36,8 +36,11 @@ export class AnotherFakeApi extends runtime.BaseAPI { * To test special tags */ async _123testSpecialTagsRaw(requestParameters: 123testSpecialTagsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.client === null || requestParameters.client === undefined) { - throw new runtime.RequiredError('client','Required parameter requestParameters.client was null or undefined when calling _123testSpecialTags.'); + if (!runtime.exists(requestParameters, 'client')) { + throw new runtime.RequiredError( + 'client', + 'Required parameter "client" was null or undefined when calling _123testSpecialTags().' + ); } const queryParameters: any = {}; @@ -51,7 +54,7 @@ export class AnotherFakeApi extends runtime.BaseAPI { method: 'PATCH', headers: headerParameters, query: queryParameters, - body: ClientToJSON(requestParameters.client), + body: ClientToJSON(requestParameters['client']), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => ClientFromJSON(jsonValue)); diff --git a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/apis/FakeApi.ts b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/apis/FakeApi.ts index 0d9ea6361d7c..db35c115a6ff 100644 --- a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/apis/FakeApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/apis/FakeApi.ts @@ -207,22 +207,25 @@ export class FakeApi extends runtime.BaseAPI { * test http signature authentication */ async fakeHttpSignatureTestRaw(requestParameters: FakeHttpSignatureTestRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.pet === null || requestParameters.pet === undefined) { - throw new runtime.RequiredError('pet','Required parameter requestParameters.pet was null or undefined when calling fakeHttpSignatureTest.'); + if (!runtime.exists(requestParameters, 'pet')) { + throw new runtime.RequiredError( + 'pet', + 'Required parameter "pet" was null or undefined when calling fakeHttpSignatureTest().' + ); } const queryParameters: any = {}; - if (requestParameters.query1 !== undefined) { - queryParameters['query_1'] = requestParameters.query1; + if (runtime.exists(requestParameters, 'query1')) { + queryParameters['query_1'] = requestParameters['query1']; } const headerParameters: runtime.HTTPHeaders = {}; headerParameters['Content-Type'] = 'application/json'; - if (requestParameters.header1 !== undefined && requestParameters.header1 !== null) { - headerParameters['header_1'] = String(requestParameters.header1); + if (runtime.exists(requestParameters, 'header1')) { + headerParameters['header_1'] = String(requestParameters['header1']); } const response = await this.request({ @@ -230,7 +233,7 @@ export class FakeApi extends runtime.BaseAPI { method: 'GET', headers: headerParameters, query: queryParameters, - body: PetToJSON(requestParameters.pet), + body: PetToJSON(requestParameters['pet']), }, initOverrides); return new runtime.VoidApiResponse(response); @@ -258,7 +261,7 @@ export class FakeApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, - body: requestParameters.body as any, + body: requestParameters['body'] as any, }, initOverrides); if (this.isJsonMime(response.headers.get('content-type'))) { @@ -291,7 +294,7 @@ export class FakeApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, - body: OuterCompositeToJSON(requestParameters.outerComposite), + body: OuterCompositeToJSON(requestParameters['outerComposite']), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => OuterCompositeFromJSON(jsonValue)); @@ -320,7 +323,7 @@ export class FakeApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, - body: requestParameters.body as any, + body: requestParameters['body'] as any, }, initOverrides); if (this.isJsonMime(response.headers.get('content-type'))) { @@ -353,7 +356,7 @@ export class FakeApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, - body: requestParameters.body as any, + body: requestParameters['body'] as any, }, initOverrides); if (this.isJsonMime(response.headers.get('content-type'))) { @@ -375,8 +378,11 @@ export class FakeApi extends runtime.BaseAPI { * Test serialization of enum (int) properties with examples */ async fakePropertyEnumIntegerSerializeRaw(requestParameters: FakePropertyEnumIntegerSerializeRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.outerObjectWithEnumProperty === null || requestParameters.outerObjectWithEnumProperty === undefined) { - throw new runtime.RequiredError('outerObjectWithEnumProperty','Required parameter requestParameters.outerObjectWithEnumProperty was null or undefined when calling fakePropertyEnumIntegerSerialize.'); + if (!runtime.exists(requestParameters, 'outerObjectWithEnumProperty')) { + throw new runtime.RequiredError( + 'outerObjectWithEnumProperty', + 'Required parameter "outerObjectWithEnumProperty" was null or undefined when calling fakePropertyEnumIntegerSerialize().' + ); } const queryParameters: any = {}; @@ -390,7 +396,7 @@ export class FakeApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, - body: OuterObjectWithEnumPropertyToJSON(requestParameters.outerObjectWithEnumProperty), + body: OuterObjectWithEnumPropertyToJSON(requestParameters['outerObjectWithEnumProperty']), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => OuterObjectWithEnumPropertyFromJSON(jsonValue)); @@ -408,8 +414,11 @@ export class FakeApi extends runtime.BaseAPI { * For this test, the body has to be a binary file. */ async testBodyWithBinaryRaw(requestParameters: TestBodyWithBinaryRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.body === null || requestParameters.body === undefined) { - throw new runtime.RequiredError('body','Required parameter requestParameters.body was null or undefined when calling testBodyWithBinary.'); + if (!runtime.exists(requestParameters, 'body')) { + throw new runtime.RequiredError( + 'body', + 'Required parameter "body" was null or undefined when calling testBodyWithBinary().' + ); } const queryParameters: any = {}; @@ -423,7 +432,7 @@ export class FakeApi extends runtime.BaseAPI { method: 'PUT', headers: headerParameters, query: queryParameters, - body: requestParameters.body as any, + body: requestParameters['body'] as any, }, initOverrides); return new runtime.VoidApiResponse(response); @@ -440,8 +449,11 @@ export class FakeApi extends runtime.BaseAPI { * For this test, the body for this request must reference a schema named `File`. */ async testBodyWithFileSchemaRaw(requestParameters: TestBodyWithFileSchemaRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.fileSchemaTestClass === null || requestParameters.fileSchemaTestClass === undefined) { - throw new runtime.RequiredError('fileSchemaTestClass','Required parameter requestParameters.fileSchemaTestClass was null or undefined when calling testBodyWithFileSchema.'); + if (!runtime.exists(requestParameters, 'fileSchemaTestClass')) { + throw new runtime.RequiredError( + 'fileSchemaTestClass', + 'Required parameter "fileSchemaTestClass" was null or undefined when calling testBodyWithFileSchema().' + ); } const queryParameters: any = {}; @@ -455,7 +467,7 @@ export class FakeApi extends runtime.BaseAPI { method: 'PUT', headers: headerParameters, query: queryParameters, - body: FileSchemaTestClassToJSON(requestParameters.fileSchemaTestClass), + body: FileSchemaTestClassToJSON(requestParameters['fileSchemaTestClass']), }, initOverrides); return new runtime.VoidApiResponse(response); @@ -471,18 +483,24 @@ export class FakeApi extends runtime.BaseAPI { /** */ async testBodyWithQueryParamsRaw(requestParameters: TestBodyWithQueryParamsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.query === null || requestParameters.query === undefined) { - throw new runtime.RequiredError('query','Required parameter requestParameters.query was null or undefined when calling testBodyWithQueryParams.'); + if (!runtime.exists(requestParameters, 'query')) { + throw new runtime.RequiredError( + 'query', + 'Required parameter "query" was null or undefined when calling testBodyWithQueryParams().' + ); } - if (requestParameters.user === null || requestParameters.user === undefined) { - throw new runtime.RequiredError('user','Required parameter requestParameters.user was null or undefined when calling testBodyWithQueryParams.'); + if (!runtime.exists(requestParameters, 'user')) { + throw new runtime.RequiredError( + 'user', + 'Required parameter "user" was null or undefined when calling testBodyWithQueryParams().' + ); } const queryParameters: any = {}; - if (requestParameters.query !== undefined) { - queryParameters['query'] = requestParameters.query; + if (runtime.exists(requestParameters, 'query')) { + queryParameters['query'] = requestParameters['query']; } const headerParameters: runtime.HTTPHeaders = {}; @@ -494,7 +512,7 @@ export class FakeApi extends runtime.BaseAPI { method: 'PUT', headers: headerParameters, query: queryParameters, - body: UserToJSON(requestParameters.user), + body: UserToJSON(requestParameters['user']), }, initOverrides); return new runtime.VoidApiResponse(response); @@ -511,8 +529,11 @@ export class FakeApi extends runtime.BaseAPI { * To test \"client\" model */ async testClientModelRaw(requestParameters: TestClientModelRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.client === null || requestParameters.client === undefined) { - throw new runtime.RequiredError('client','Required parameter requestParameters.client was null or undefined when calling testClientModel.'); + if (!runtime.exists(requestParameters, 'client')) { + throw new runtime.RequiredError( + 'client', + 'Required parameter "client" was null or undefined when calling testClientModel().' + ); } const queryParameters: any = {}; @@ -526,7 +547,7 @@ export class FakeApi extends runtime.BaseAPI { method: 'PATCH', headers: headerParameters, query: queryParameters, - body: ClientToJSON(requestParameters.client), + body: ClientToJSON(requestParameters['client']), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => ClientFromJSON(jsonValue)); @@ -546,20 +567,32 @@ export class FakeApi extends runtime.BaseAPI { * Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 */ async testEndpointParametersRaw(requestParameters: TestEndpointParametersRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.number === null || requestParameters.number === undefined) { - throw new runtime.RequiredError('number','Required parameter requestParameters.number was null or undefined when calling testEndpointParameters.'); + if (!runtime.exists(requestParameters, 'number')) { + throw new runtime.RequiredError( + 'number', + 'Required parameter "number" was null or undefined when calling testEndpointParameters().' + ); } - if (requestParameters._double === null || requestParameters._double === undefined) { - throw new runtime.RequiredError('_double','Required parameter requestParameters._double was null or undefined when calling testEndpointParameters.'); + if (!runtime.exists(requestParameters, '_double')) { + throw new runtime.RequiredError( + '_double', + 'Required parameter "_double" was null or undefined when calling testEndpointParameters().' + ); } - if (requestParameters.patternWithoutDelimiter === null || requestParameters.patternWithoutDelimiter === undefined) { - throw new runtime.RequiredError('patternWithoutDelimiter','Required parameter requestParameters.patternWithoutDelimiter was null or undefined when calling testEndpointParameters.'); + if (!runtime.exists(requestParameters, 'patternWithoutDelimiter')) { + throw new runtime.RequiredError( + 'patternWithoutDelimiter', + 'Required parameter "patternWithoutDelimiter" was null or undefined when calling testEndpointParameters().' + ); } - if (requestParameters._byte === null || requestParameters._byte === undefined) { - throw new runtime.RequiredError('_byte','Required parameter requestParameters._byte was null or undefined when calling testEndpointParameters.'); + if (!runtime.exists(requestParameters, '_byte')) { + throw new runtime.RequiredError( + '_byte', + 'Required parameter "_byte" was null or undefined when calling testEndpointParameters().' + ); } const queryParameters: any = {}; @@ -585,60 +618,60 @@ export class FakeApi extends runtime.BaseAPI { formParams = new URLSearchParams(); } - if (requestParameters.integer !== undefined) { - formParams.append('integer', requestParameters.integer as any); + if (runtime.exists(requestParameters, 'integer')) { + formParams.append('integer', requestParameters['integer'] as any); } - if (requestParameters.int32 !== undefined) { - formParams.append('int32', requestParameters.int32 as any); + if (runtime.exists(requestParameters, 'int32')) { + formParams.append('int32', requestParameters['int32'] as any); } - if (requestParameters.int64 !== undefined) { - formParams.append('int64', requestParameters.int64 as any); + if (runtime.exists(requestParameters, 'int64')) { + formParams.append('int64', requestParameters['int64'] as any); } - if (requestParameters.number !== undefined) { - formParams.append('number', requestParameters.number as any); + if (runtime.exists(requestParameters, 'number')) { + formParams.append('number', requestParameters['number'] as any); } - if (requestParameters._float !== undefined) { - formParams.append('float', requestParameters._float as any); + if (runtime.exists(requestParameters, '_float')) { + formParams.append('float', requestParameters['_float'] as any); } - if (requestParameters._double !== undefined) { - formParams.append('double', requestParameters._double as any); + if (runtime.exists(requestParameters, '_double')) { + formParams.append('double', requestParameters['_double'] as any); } - if (requestParameters.string !== undefined) { - formParams.append('string', requestParameters.string as any); + if (runtime.exists(requestParameters, 'string')) { + formParams.append('string', requestParameters['string'] as any); } - if (requestParameters.patternWithoutDelimiter !== undefined) { - formParams.append('pattern_without_delimiter', requestParameters.patternWithoutDelimiter as any); + if (runtime.exists(requestParameters, 'patternWithoutDelimiter')) { + formParams.append('pattern_without_delimiter', requestParameters['patternWithoutDelimiter'] as any); } - if (requestParameters._byte !== undefined) { - formParams.append('byte', requestParameters._byte as any); + if (runtime.exists(requestParameters, '_byte')) { + formParams.append('byte', requestParameters['_byte'] as any); } - if (requestParameters.binary !== undefined) { - formParams.append('binary', requestParameters.binary as any); + if (runtime.exists(requestParameters, 'binary')) { + formParams.append('binary', requestParameters['binary'] as any); } - if (requestParameters.date !== undefined) { - formParams.append('date', requestParameters.date as any); + if (runtime.exists(requestParameters, 'date')) { + formParams.append('date', requestParameters['date'] as any); } - if (requestParameters.dateTime !== undefined) { - formParams.append('dateTime', requestParameters.dateTime as any); + if (runtime.exists(requestParameters, 'dateTime')) { + formParams.append('dateTime', requestParameters['dateTime'] as any); } - if (requestParameters.password !== undefined) { - formParams.append('password', requestParameters.password as any); + if (runtime.exists(requestParameters, 'password')) { + formParams.append('password', requestParameters['password'] as any); } - if (requestParameters.callback !== undefined) { - formParams.append('callback', requestParameters.callback as any); + if (runtime.exists(requestParameters, 'callback')) { + formParams.append('callback', requestParameters['callback'] as any); } const response = await this.request({ @@ -667,34 +700,34 @@ export class FakeApi extends runtime.BaseAPI { async testEnumParametersRaw(requestParameters: TestEnumParametersRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { const queryParameters: any = {}; - if (requestParameters.enumQueryStringArray) { - queryParameters['enum_query_string_array'] = requestParameters.enumQueryStringArray; + if (runtime.exists(requestParameters, 'enumQueryStringArray')) { + queryParameters['enum_query_string_array'] = requestParameters['enumQueryStringArray']; } - if (requestParameters.enumQueryString !== undefined) { - queryParameters['enum_query_string'] = requestParameters.enumQueryString; + if (runtime.exists(requestParameters, 'enumQueryString')) { + queryParameters['enum_query_string'] = requestParameters['enumQueryString']; } - if (requestParameters.enumQueryInteger !== undefined) { - queryParameters['enum_query_integer'] = requestParameters.enumQueryInteger; + if (runtime.exists(requestParameters, 'enumQueryInteger')) { + queryParameters['enum_query_integer'] = requestParameters['enumQueryInteger']; } - if (requestParameters.enumQueryDouble !== undefined) { - queryParameters['enum_query_double'] = requestParameters.enumQueryDouble; + if (runtime.exists(requestParameters, 'enumQueryDouble')) { + queryParameters['enum_query_double'] = requestParameters['enumQueryDouble']; } - if (requestParameters.enumQueryModelArray) { - queryParameters['enum_query_model_array'] = requestParameters.enumQueryModelArray; + if (runtime.exists(requestParameters, 'enumQueryModelArray')) { + queryParameters['enum_query_model_array'] = requestParameters['enumQueryModelArray']; } const headerParameters: runtime.HTTPHeaders = {}; - if (requestParameters.enumHeaderStringArray) { - headerParameters['enum_header_string_array'] = requestParameters.enumHeaderStringArray.join(runtime.COLLECTION_FORMATS["csv"]); + if (runtime.exists(requestParameters, 'enumHeaderStringArray')) { + headerParameters['enum_header_string_array'] = requestParameters['enumHeaderStringArray']!.join(runtime.COLLECTION_FORMATS["csv"]); } - if (requestParameters.enumHeaderString !== undefined && requestParameters.enumHeaderString !== null) { - headerParameters['enum_header_string'] = String(requestParameters.enumHeaderString); + if (runtime.exists(requestParameters, 'enumHeaderString')) { + headerParameters['enum_header_string'] = String(requestParameters['enumHeaderString']); } const consumes: runtime.Consume[] = [ @@ -711,12 +744,12 @@ export class FakeApi extends runtime.BaseAPI { formParams = new URLSearchParams(); } - if (requestParameters.enumFormStringArray) { - formParams.append('enum_form_string_array', requestParameters.enumFormStringArray.join(runtime.COLLECTION_FORMATS["csv"])); + if (runtime.exists(requestParameters, 'enumFormStringArray')) { + formParams.append('enum_form_string_array', requestParameters['enumFormStringArray']!.join(runtime.COLLECTION_FORMATS["csv"])); } - if (requestParameters.enumFormString !== undefined) { - formParams.append('enum_form_string', requestParameters.enumFormString as any); + if (runtime.exists(requestParameters, 'enumFormString')) { + formParams.append('enum_form_string', requestParameters['enumFormString'] as any); } const response = await this.request({ @@ -743,44 +776,53 @@ export class FakeApi extends runtime.BaseAPI { * Fake endpoint to test group parameters (optional) */ async testGroupParametersRaw(requestParameters: TestGroupParametersRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.requiredStringGroup === null || requestParameters.requiredStringGroup === undefined) { - throw new runtime.RequiredError('requiredStringGroup','Required parameter requestParameters.requiredStringGroup was null or undefined when calling testGroupParameters.'); + if (!runtime.exists(requestParameters, 'requiredStringGroup')) { + throw new runtime.RequiredError( + 'requiredStringGroup', + 'Required parameter "requiredStringGroup" was null or undefined when calling testGroupParameters().' + ); } - if (requestParameters.requiredBooleanGroup === null || requestParameters.requiredBooleanGroup === undefined) { - throw new runtime.RequiredError('requiredBooleanGroup','Required parameter requestParameters.requiredBooleanGroup was null or undefined when calling testGroupParameters.'); + if (!runtime.exists(requestParameters, 'requiredBooleanGroup')) { + throw new runtime.RequiredError( + 'requiredBooleanGroup', + 'Required parameter "requiredBooleanGroup" was null or undefined when calling testGroupParameters().' + ); } - if (requestParameters.requiredInt64Group === null || requestParameters.requiredInt64Group === undefined) { - throw new runtime.RequiredError('requiredInt64Group','Required parameter requestParameters.requiredInt64Group was null or undefined when calling testGroupParameters.'); + if (!runtime.exists(requestParameters, 'requiredInt64Group')) { + throw new runtime.RequiredError( + 'requiredInt64Group', + 'Required parameter "requiredInt64Group" was null or undefined when calling testGroupParameters().' + ); } const queryParameters: any = {}; - if (requestParameters.requiredStringGroup !== undefined) { - queryParameters['required_string_group'] = requestParameters.requiredStringGroup; + if (runtime.exists(requestParameters, 'requiredStringGroup')) { + queryParameters['required_string_group'] = requestParameters['requiredStringGroup']; } - if (requestParameters.requiredInt64Group !== undefined) { - queryParameters['required_int64_group'] = requestParameters.requiredInt64Group; + if (runtime.exists(requestParameters, 'requiredInt64Group')) { + queryParameters['required_int64_group'] = requestParameters['requiredInt64Group']; } - if (requestParameters.stringGroup !== undefined) { - queryParameters['string_group'] = requestParameters.stringGroup; + if (runtime.exists(requestParameters, 'stringGroup')) { + queryParameters['string_group'] = requestParameters['stringGroup']; } - if (requestParameters.int64Group !== undefined) { - queryParameters['int64_group'] = requestParameters.int64Group; + if (runtime.exists(requestParameters, 'int64Group')) { + queryParameters['int64_group'] = requestParameters['int64Group']; } const headerParameters: runtime.HTTPHeaders = {}; - if (requestParameters.requiredBooleanGroup !== undefined && requestParameters.requiredBooleanGroup !== null) { - headerParameters['required_boolean_group'] = String(requestParameters.requiredBooleanGroup); + if (runtime.exists(requestParameters, 'requiredBooleanGroup')) { + headerParameters['required_boolean_group'] = String(requestParameters['requiredBooleanGroup']); } - if (requestParameters.booleanGroup !== undefined && requestParameters.booleanGroup !== null) { - headerParameters['boolean_group'] = String(requestParameters.booleanGroup); + if (runtime.exists(requestParameters, 'booleanGroup')) { + headerParameters['boolean_group'] = String(requestParameters['booleanGroup']); } if (this.configuration && this.configuration.accessToken) { @@ -814,8 +856,11 @@ export class FakeApi extends runtime.BaseAPI { * test inline additionalProperties */ async testInlineAdditionalPropertiesRaw(requestParameters: TestInlineAdditionalPropertiesRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.requestBody === null || requestParameters.requestBody === undefined) { - throw new runtime.RequiredError('requestBody','Required parameter requestParameters.requestBody was null or undefined when calling testInlineAdditionalProperties.'); + if (!runtime.exists(requestParameters, 'requestBody')) { + throw new runtime.RequiredError( + 'requestBody', + 'Required parameter "requestBody" was null or undefined when calling testInlineAdditionalProperties().' + ); } const queryParameters: any = {}; @@ -829,7 +874,7 @@ export class FakeApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, - body: requestParameters.requestBody, + body: requestParameters['requestBody'], }, initOverrides); return new runtime.VoidApiResponse(response); @@ -848,12 +893,18 @@ export class FakeApi extends runtime.BaseAPI { * test json serialization of form data */ async testJsonFormDataRaw(requestParameters: TestJsonFormDataRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.param === null || requestParameters.param === undefined) { - throw new runtime.RequiredError('param','Required parameter requestParameters.param was null or undefined when calling testJsonFormData.'); + if (!runtime.exists(requestParameters, 'param')) { + throw new runtime.RequiredError( + 'param', + 'Required parameter "param" was null or undefined when calling testJsonFormData().' + ); } - if (requestParameters.param2 === null || requestParameters.param2 === undefined) { - throw new runtime.RequiredError('param2','Required parameter requestParameters.param2 was null or undefined when calling testJsonFormData.'); + if (!runtime.exists(requestParameters, 'param2')) { + throw new runtime.RequiredError( + 'param2', + 'Required parameter "param2" was null or undefined when calling testJsonFormData().' + ); } const queryParameters: any = {}; @@ -874,12 +925,12 @@ export class FakeApi extends runtime.BaseAPI { formParams = new URLSearchParams(); } - if (requestParameters.param !== undefined) { - formParams.append('param', requestParameters.param as any); + if (runtime.exists(requestParameters, 'param')) { + formParams.append('param', requestParameters['param'] as any); } - if (requestParameters.param2 !== undefined) { - formParams.append('param2', requestParameters.param2 as any); + if (runtime.exists(requestParameters, 'param2')) { + formParams.append('param2', requestParameters['param2'] as any); } const response = await this.request({ @@ -905,58 +956,76 @@ export class FakeApi extends runtime.BaseAPI { * To test the collection format in query parameters */ async testQueryParameterCollectionFormatRaw(requestParameters: TestQueryParameterCollectionFormatRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.pipe === null || requestParameters.pipe === undefined) { - throw new runtime.RequiredError('pipe','Required parameter requestParameters.pipe was null or undefined when calling testQueryParameterCollectionFormat.'); + if (!runtime.exists(requestParameters, 'pipe')) { + throw new runtime.RequiredError( + 'pipe', + 'Required parameter "pipe" was null or undefined when calling testQueryParameterCollectionFormat().' + ); } - if (requestParameters.ioutil === null || requestParameters.ioutil === undefined) { - throw new runtime.RequiredError('ioutil','Required parameter requestParameters.ioutil was null or undefined when calling testQueryParameterCollectionFormat.'); + if (!runtime.exists(requestParameters, 'ioutil')) { + throw new runtime.RequiredError( + 'ioutil', + 'Required parameter "ioutil" was null or undefined when calling testQueryParameterCollectionFormat().' + ); } - if (requestParameters.http === null || requestParameters.http === undefined) { - throw new runtime.RequiredError('http','Required parameter requestParameters.http was null or undefined when calling testQueryParameterCollectionFormat.'); + if (!runtime.exists(requestParameters, 'http')) { + throw new runtime.RequiredError( + 'http', + 'Required parameter "http" was null or undefined when calling testQueryParameterCollectionFormat().' + ); } - if (requestParameters.url === null || requestParameters.url === undefined) { - throw new runtime.RequiredError('url','Required parameter requestParameters.url was null or undefined when calling testQueryParameterCollectionFormat.'); + if (!runtime.exists(requestParameters, 'url')) { + throw new runtime.RequiredError( + 'url', + 'Required parameter "url" was null or undefined when calling testQueryParameterCollectionFormat().' + ); } - if (requestParameters.context === null || requestParameters.context === undefined) { - throw new runtime.RequiredError('context','Required parameter requestParameters.context was null or undefined when calling testQueryParameterCollectionFormat.'); + if (!runtime.exists(requestParameters, 'context')) { + throw new runtime.RequiredError( + 'context', + 'Required parameter "context" was null or undefined when calling testQueryParameterCollectionFormat().' + ); } - if (requestParameters.allowEmpty === null || requestParameters.allowEmpty === undefined) { - throw new runtime.RequiredError('allowEmpty','Required parameter requestParameters.allowEmpty was null or undefined when calling testQueryParameterCollectionFormat.'); + if (!runtime.exists(requestParameters, 'allowEmpty')) { + throw new runtime.RequiredError( + 'allowEmpty', + 'Required parameter "allowEmpty" was null or undefined when calling testQueryParameterCollectionFormat().' + ); } const queryParameters: any = {}; - if (requestParameters.pipe) { - queryParameters['pipe'] = requestParameters.pipe.join(runtime.COLLECTION_FORMATS["pipes"]); + if (runtime.exists(requestParameters, 'pipe')) { + queryParameters['pipe'] = requestParameters['pipe']!.join(runtime.COLLECTION_FORMATS["pipes"]); } - if (requestParameters.ioutil) { - queryParameters['ioutil'] = requestParameters.ioutil.join(runtime.COLLECTION_FORMATS["csv"]); + if (runtime.exists(requestParameters, 'ioutil')) { + queryParameters['ioutil'] = requestParameters['ioutil']!.join(runtime.COLLECTION_FORMATS["csv"]); } - if (requestParameters.http) { - queryParameters['http'] = requestParameters.http.join(runtime.COLLECTION_FORMATS["ssv"]); + if (runtime.exists(requestParameters, 'http')) { + queryParameters['http'] = requestParameters['http']!.join(runtime.COLLECTION_FORMATS["ssv"]); } - if (requestParameters.url) { - queryParameters['url'] = requestParameters.url.join(runtime.COLLECTION_FORMATS["csv"]); + if (runtime.exists(requestParameters, 'url')) { + queryParameters['url'] = requestParameters['url']!.join(runtime.COLLECTION_FORMATS["csv"]); } - if (requestParameters.context) { - queryParameters['context'] = requestParameters.context; + if (runtime.exists(requestParameters, 'context')) { + queryParameters['context'] = requestParameters['context']; } - if (requestParameters.language !== undefined) { - queryParameters['language'] = requestParameters.language; + if (runtime.exists(requestParameters, 'language')) { + queryParameters['language'] = requestParameters['language']; } - if (requestParameters.allowEmpty !== undefined) { - queryParameters['allowEmpty'] = requestParameters.allowEmpty; + if (runtime.exists(requestParameters, 'allowEmpty')) { + queryParameters['allowEmpty'] = requestParameters['allowEmpty']; } const headerParameters: runtime.HTTPHeaders = {}; diff --git a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/apis/FakeClassnameTags123Api.ts b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/apis/FakeClassnameTags123Api.ts index e6f3fd1f0b96..ce9f567a5324 100644 --- a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/apis/FakeClassnameTags123Api.ts +++ b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/apis/FakeClassnameTags123Api.ts @@ -36,8 +36,11 @@ export class FakeClassnameTags123Api extends runtime.BaseAPI { * To test class name in snake case */ async testClassnameRaw(requestParameters: TestClassnameRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.client === null || requestParameters.client === undefined) { - throw new runtime.RequiredError('client','Required parameter requestParameters.client was null or undefined when calling testClassname.'); + if (!runtime.exists(requestParameters, 'client')) { + throw new runtime.RequiredError( + 'client', + 'Required parameter "client" was null or undefined when calling testClassname().' + ); } const queryParameters: any = {}; @@ -55,7 +58,7 @@ export class FakeClassnameTags123Api extends runtime.BaseAPI { method: 'PATCH', headers: headerParameters, query: queryParameters, - body: ClientToJSON(requestParameters.client), + body: ClientToJSON(requestParameters['client']), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => ClientFromJSON(jsonValue)); diff --git a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/apis/PetApi.ts b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/apis/PetApi.ts index 354aac42bbf8..389f7d7077f3 100644 --- a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/apis/PetApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/apis/PetApi.ts @@ -78,8 +78,11 @@ export class PetApi extends runtime.BaseAPI { * Add a new pet to the store */ async addPetRaw(requestParameters: AddPetRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.pet === null || requestParameters.pet === undefined) { - throw new runtime.RequiredError('pet','Required parameter requestParameters.pet was null or undefined when calling addPet.'); + if (!runtime.exists(requestParameters, 'pet')) { + throw new runtime.RequiredError( + 'pet', + 'Required parameter "pet" was null or undefined when calling addPet().' + ); } const queryParameters: any = {}; @@ -98,7 +101,7 @@ export class PetApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, - body: PetToJSON(requestParameters.pet), + body: PetToJSON(requestParameters['pet']), }, initOverrides); return new runtime.VoidApiResponse(response); @@ -117,16 +120,19 @@ export class PetApi extends runtime.BaseAPI { * Deletes a pet */ async deletePetRaw(requestParameters: DeletePetRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.petId === null || requestParameters.petId === undefined) { - throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling deletePet.'); + if (!runtime.exists(requestParameters, 'petId')) { + throw new runtime.RequiredError( + 'petId', + 'Required parameter "petId" was null or undefined when calling deletePet().' + ); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; - if (requestParameters.apiKey !== undefined && requestParameters.apiKey !== null) { - headerParameters['api_key'] = String(requestParameters.apiKey); + if (runtime.exists(requestParameters, 'apiKey')) { + headerParameters['api_key'] = String(requestParameters['apiKey']); } if (this.configuration && this.configuration.accessToken) { @@ -135,7 +141,7 @@ export class PetApi extends runtime.BaseAPI { } const response = await this.request({ - path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), + path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters['petId']))), method: 'DELETE', headers: headerParameters, query: queryParameters, @@ -157,14 +163,17 @@ export class PetApi extends runtime.BaseAPI { * Finds Pets by status */ async findPetsByStatusRaw(requestParameters: FindPetsByStatusRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>> { - if (requestParameters.status === null || requestParameters.status === undefined) { - throw new runtime.RequiredError('status','Required parameter requestParameters.status was null or undefined when calling findPetsByStatus.'); + if (!runtime.exists(requestParameters, 'status')) { + throw new runtime.RequiredError( + 'status', + 'Required parameter "status" was null or undefined when calling findPetsByStatus().' + ); } const queryParameters: any = {}; - if (requestParameters.status) { - queryParameters['status'] = requestParameters.status.join(runtime.COLLECTION_FORMATS["csv"]); + if (runtime.exists(requestParameters, 'status')) { + queryParameters['status'] = requestParameters['status']!.join(runtime.COLLECTION_FORMATS["csv"]); } const headerParameters: runtime.HTTPHeaders = {}; @@ -199,14 +208,17 @@ export class PetApi extends runtime.BaseAPI { * @deprecated */ async findPetsByTagsRaw(requestParameters: FindPetsByTagsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>> { - if (requestParameters.tags === null || requestParameters.tags === undefined) { - throw new runtime.RequiredError('tags','Required parameter requestParameters.tags was null or undefined when calling findPetsByTags.'); + if (!runtime.exists(requestParameters, 'tags')) { + throw new runtime.RequiredError( + 'tags', + 'Required parameter "tags" was null or undefined when calling findPetsByTags().' + ); } const queryParameters: any = {}; - if (requestParameters.tags) { - queryParameters['tags'] = Array.from(requestParameters.tags).join(runtime.COLLECTION_FORMATS["csv"]); + if (runtime.exists(requestParameters, 'tags')) { + queryParameters['tags'] = Array.from(requestParameters['tags'])!.join(runtime.COLLECTION_FORMATS["csv"]); } const headerParameters: runtime.HTTPHeaders = {}; @@ -241,8 +253,11 @@ export class PetApi extends runtime.BaseAPI { * Find pet by ID */ async getPetByIdRaw(requestParameters: GetPetByIdRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.petId === null || requestParameters.petId === undefined) { - throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling getPetById.'); + if (!runtime.exists(requestParameters, 'petId')) { + throw new runtime.RequiredError( + 'petId', + 'Required parameter "petId" was null or undefined when calling getPetById().' + ); } const queryParameters: any = {}; @@ -254,7 +269,7 @@ export class PetApi extends runtime.BaseAPI { } const response = await this.request({ - path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), + path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters['petId']))), method: 'GET', headers: headerParameters, query: queryParameters, @@ -277,8 +292,11 @@ export class PetApi extends runtime.BaseAPI { * Update an existing pet */ async updatePetRaw(requestParameters: UpdatePetRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.pet === null || requestParameters.pet === undefined) { - throw new runtime.RequiredError('pet','Required parameter requestParameters.pet was null or undefined when calling updatePet.'); + if (!runtime.exists(requestParameters, 'pet')) { + throw new runtime.RequiredError( + 'pet', + 'Required parameter "pet" was null or undefined when calling updatePet().' + ); } const queryParameters: any = {}; @@ -297,7 +315,7 @@ export class PetApi extends runtime.BaseAPI { method: 'PUT', headers: headerParameters, query: queryParameters, - body: PetToJSON(requestParameters.pet), + body: PetToJSON(requestParameters['pet']), }, initOverrides); return new runtime.VoidApiResponse(response); @@ -316,8 +334,11 @@ export class PetApi extends runtime.BaseAPI { * Updates a pet in the store with form data */ async updatePetWithFormRaw(requestParameters: UpdatePetWithFormRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.petId === null || requestParameters.petId === undefined) { - throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling updatePetWithForm.'); + if (!runtime.exists(requestParameters, 'petId')) { + throw new runtime.RequiredError( + 'petId', + 'Required parameter "petId" was null or undefined when calling updatePetWithForm().' + ); } const queryParameters: any = {}; @@ -343,16 +364,16 @@ export class PetApi extends runtime.BaseAPI { formParams = new URLSearchParams(); } - if (requestParameters.name !== undefined) { - formParams.append('name', requestParameters.name as any); + if (runtime.exists(requestParameters, 'name')) { + formParams.append('name', requestParameters['name'] as any); } - if (requestParameters.status !== undefined) { - formParams.append('status', requestParameters.status as any); + if (runtime.exists(requestParameters, 'status')) { + formParams.append('status', requestParameters['status'] as any); } const response = await this.request({ - path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), + path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters['petId']))), method: 'POST', headers: headerParameters, query: queryParameters, @@ -375,8 +396,11 @@ export class PetApi extends runtime.BaseAPI { * uploads an image */ async uploadFileRaw(requestParameters: UploadFileRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.petId === null || requestParameters.petId === undefined) { - throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling uploadFile.'); + if (!runtime.exists(requestParameters, 'petId')) { + throw new runtime.RequiredError( + 'petId', + 'Required parameter "petId" was null or undefined when calling uploadFile().' + ); } const queryParameters: any = {}; @@ -404,16 +428,16 @@ export class PetApi extends runtime.BaseAPI { formParams = new URLSearchParams(); } - if (requestParameters.additionalMetadata !== undefined) { - formParams.append('additionalMetadata', requestParameters.additionalMetadata as any); + if (runtime.exists(requestParameters, 'additionalMetadata')) { + formParams.append('additionalMetadata', requestParameters['additionalMetadata'] as any); } - if (requestParameters.file !== undefined) { - formParams.append('file', requestParameters.file as any); + if (runtime.exists(requestParameters, 'file')) { + formParams.append('file', requestParameters['file'] as any); } const response = await this.request({ - path: `/pet/{petId}/uploadImage`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), + path: `/pet/{petId}/uploadImage`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters['petId']))), method: 'POST', headers: headerParameters, query: queryParameters, @@ -437,12 +461,18 @@ export class PetApi extends runtime.BaseAPI { * uploads an image (required) */ async uploadFileWithRequiredFileRaw(requestParameters: UploadFileWithRequiredFileRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.petId === null || requestParameters.petId === undefined) { - throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling uploadFileWithRequiredFile.'); + if (!runtime.exists(requestParameters, 'petId')) { + throw new runtime.RequiredError( + 'petId', + 'Required parameter "petId" was null or undefined when calling uploadFileWithRequiredFile().' + ); } - if (requestParameters.requiredFile === null || requestParameters.requiredFile === undefined) { - throw new runtime.RequiredError('requiredFile','Required parameter requestParameters.requiredFile was null or undefined when calling uploadFileWithRequiredFile.'); + if (!runtime.exists(requestParameters, 'requiredFile')) { + throw new runtime.RequiredError( + 'requiredFile', + 'Required parameter "requiredFile" was null or undefined when calling uploadFileWithRequiredFile().' + ); } const queryParameters: any = {}; @@ -470,16 +500,16 @@ export class PetApi extends runtime.BaseAPI { formParams = new URLSearchParams(); } - if (requestParameters.additionalMetadata !== undefined) { - formParams.append('additionalMetadata', requestParameters.additionalMetadata as any); + if (runtime.exists(requestParameters, 'additionalMetadata')) { + formParams.append('additionalMetadata', requestParameters['additionalMetadata'] as any); } - if (requestParameters.requiredFile !== undefined) { - formParams.append('requiredFile', requestParameters.requiredFile as any); + if (runtime.exists(requestParameters, 'requiredFile')) { + formParams.append('requiredFile', requestParameters['requiredFile'] as any); } const response = await this.request({ - path: `/fake/{petId}/uploadImageWithRequiredFile`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), + path: `/fake/{petId}/uploadImageWithRequiredFile`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters['petId']))), method: 'POST', headers: headerParameters, query: queryParameters, diff --git a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/apis/StoreApi.ts b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/apis/StoreApi.ts index 3b17a1d7bb0d..4444f71d4cd0 100644 --- a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/apis/StoreApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/apis/StoreApi.ts @@ -44,8 +44,11 @@ export class StoreApi extends runtime.BaseAPI { * Delete purchase order by ID */ async deleteOrderRaw(requestParameters: DeleteOrderRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.orderId === null || requestParameters.orderId === undefined) { - throw new runtime.RequiredError('orderId','Required parameter requestParameters.orderId was null or undefined when calling deleteOrder.'); + if (!runtime.exists(requestParameters, 'orderId')) { + throw new runtime.RequiredError( + 'orderId', + 'Required parameter "orderId" was null or undefined when calling deleteOrder().' + ); } const queryParameters: any = {}; @@ -53,7 +56,7 @@ export class StoreApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; const response = await this.request({ - path: `/store/order/{order_id}`.replace(`{${"order_id"}}`, encodeURIComponent(String(requestParameters.orderId))), + path: `/store/order/{order_id}`.replace(`{${"order_id"}}`, encodeURIComponent(String(requestParameters['orderId']))), method: 'DELETE', headers: headerParameters, query: queryParameters, @@ -107,8 +110,11 @@ export class StoreApi extends runtime.BaseAPI { * Find purchase order by ID */ async getOrderByIdRaw(requestParameters: GetOrderByIdRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.orderId === null || requestParameters.orderId === undefined) { - throw new runtime.RequiredError('orderId','Required parameter requestParameters.orderId was null or undefined when calling getOrderById.'); + if (!runtime.exists(requestParameters, 'orderId')) { + throw new runtime.RequiredError( + 'orderId', + 'Required parameter "orderId" was null or undefined when calling getOrderById().' + ); } const queryParameters: any = {}; @@ -116,7 +122,7 @@ export class StoreApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; const response = await this.request({ - path: `/store/order/{order_id}`.replace(`{${"order_id"}}`, encodeURIComponent(String(requestParameters.orderId))), + path: `/store/order/{order_id}`.replace(`{${"order_id"}}`, encodeURIComponent(String(requestParameters['orderId']))), method: 'GET', headers: headerParameters, query: queryParameters, @@ -139,8 +145,11 @@ export class StoreApi extends runtime.BaseAPI { * Place an order for a pet */ async placeOrderRaw(requestParameters: PlaceOrderRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.order === null || requestParameters.order === undefined) { - throw new runtime.RequiredError('order','Required parameter requestParameters.order was null or undefined when calling placeOrder.'); + if (!runtime.exists(requestParameters, 'order')) { + throw new runtime.RequiredError( + 'order', + 'Required parameter "order" was null or undefined when calling placeOrder().' + ); } const queryParameters: any = {}; @@ -154,7 +163,7 @@ export class StoreApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, - body: OrderToJSON(requestParameters.order), + body: OrderToJSON(requestParameters['order']), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => OrderFromJSON(jsonValue)); diff --git a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/apis/UserApi.ts b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/apis/UserApi.ts index df5c8f4efcd4..36114480012f 100644 --- a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/apis/UserApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/apis/UserApi.ts @@ -62,8 +62,11 @@ export class UserApi extends runtime.BaseAPI { * Create user */ async createUserRaw(requestParameters: CreateUserRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.user === null || requestParameters.user === undefined) { - throw new runtime.RequiredError('user','Required parameter requestParameters.user was null or undefined when calling createUser.'); + if (!runtime.exists(requestParameters, 'user')) { + throw new runtime.RequiredError( + 'user', + 'Required parameter "user" was null or undefined when calling createUser().' + ); } const queryParameters: any = {}; @@ -77,7 +80,7 @@ export class UserApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, - body: UserToJSON(requestParameters.user), + body: UserToJSON(requestParameters['user']), }, initOverrides); return new runtime.VoidApiResponse(response); @@ -96,8 +99,11 @@ export class UserApi extends runtime.BaseAPI { * Creates list of users with given input array */ async createUsersWithArrayInputRaw(requestParameters: CreateUsersWithArrayInputRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.user === null || requestParameters.user === undefined) { - throw new runtime.RequiredError('user','Required parameter requestParameters.user was null or undefined when calling createUsersWithArrayInput.'); + if (!runtime.exists(requestParameters, 'user')) { + throw new runtime.RequiredError( + 'user', + 'Required parameter "user" was null or undefined when calling createUsersWithArrayInput().' + ); } const queryParameters: any = {}; @@ -111,7 +117,7 @@ export class UserApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, - body: requestParameters.user.map(UserToJSON), + body: requestParameters['user']!.map(UserToJSON), }, initOverrides); return new runtime.VoidApiResponse(response); @@ -130,8 +136,11 @@ export class UserApi extends runtime.BaseAPI { * Creates list of users with given input array */ async createUsersWithListInputRaw(requestParameters: CreateUsersWithListInputRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.user === null || requestParameters.user === undefined) { - throw new runtime.RequiredError('user','Required parameter requestParameters.user was null or undefined when calling createUsersWithListInput.'); + if (!runtime.exists(requestParameters, 'user')) { + throw new runtime.RequiredError( + 'user', + 'Required parameter "user" was null or undefined when calling createUsersWithListInput().' + ); } const queryParameters: any = {}; @@ -145,7 +154,7 @@ export class UserApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, - body: requestParameters.user.map(UserToJSON), + body: requestParameters['user']!.map(UserToJSON), }, initOverrides); return new runtime.VoidApiResponse(response); @@ -164,8 +173,11 @@ export class UserApi extends runtime.BaseAPI { * Delete user */ async deleteUserRaw(requestParameters: DeleteUserRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.username === null || requestParameters.username === undefined) { - throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling deleteUser.'); + if (!runtime.exists(requestParameters, 'username')) { + throw new runtime.RequiredError( + 'username', + 'Required parameter "username" was null or undefined when calling deleteUser().' + ); } const queryParameters: any = {}; @@ -173,7 +185,7 @@ export class UserApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; const response = await this.request({ - path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), + path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters['username']))), method: 'DELETE', headers: headerParameters, query: queryParameters, @@ -195,8 +207,11 @@ export class UserApi extends runtime.BaseAPI { * Get user by user name */ async getUserByNameRaw(requestParameters: GetUserByNameRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.username === null || requestParameters.username === undefined) { - throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling getUserByName.'); + if (!runtime.exists(requestParameters, 'username')) { + throw new runtime.RequiredError( + 'username', + 'Required parameter "username" was null or undefined when calling getUserByName().' + ); } const queryParameters: any = {}; @@ -204,7 +219,7 @@ export class UserApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; const response = await this.request({ - path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), + path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters['username']))), method: 'GET', headers: headerParameters, query: queryParameters, @@ -227,22 +242,28 @@ export class UserApi extends runtime.BaseAPI { * Logs user into the system */ async loginUserRaw(requestParameters: LoginUserRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.username === null || requestParameters.username === undefined) { - throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling loginUser.'); + if (!runtime.exists(requestParameters, 'username')) { + throw new runtime.RequiredError( + 'username', + 'Required parameter "username" was null or undefined when calling loginUser().' + ); } - if (requestParameters.password === null || requestParameters.password === undefined) { - throw new runtime.RequiredError('password','Required parameter requestParameters.password was null or undefined when calling loginUser.'); + if (!runtime.exists(requestParameters, 'password')) { + throw new runtime.RequiredError( + 'password', + 'Required parameter "password" was null or undefined when calling loginUser().' + ); } const queryParameters: any = {}; - if (requestParameters.username !== undefined) { - queryParameters['username'] = requestParameters.username; + if (runtime.exists(requestParameters, 'username')) { + queryParameters['username'] = requestParameters['username']; } - if (requestParameters.password !== undefined) { - queryParameters['password'] = requestParameters.password; + if (runtime.exists(requestParameters, 'password')) { + queryParameters['password'] = requestParameters['password']; } const headerParameters: runtime.HTTPHeaders = {}; @@ -302,12 +323,18 @@ export class UserApi extends runtime.BaseAPI { * Updated user */ async updateUserRaw(requestParameters: UpdateUserRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.username === null || requestParameters.username === undefined) { - throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling updateUser.'); + if (!runtime.exists(requestParameters, 'username')) { + throw new runtime.RequiredError( + 'username', + 'Required parameter "username" was null or undefined when calling updateUser().' + ); } - if (requestParameters.user === null || requestParameters.user === undefined) { - throw new runtime.RequiredError('user','Required parameter requestParameters.user was null or undefined when calling updateUser.'); + if (!runtime.exists(requestParameters, 'user')) { + throw new runtime.RequiredError( + 'user', + 'Required parameter "user" was null or undefined when calling updateUser().' + ); } const queryParameters: any = {}; @@ -317,11 +344,11 @@ export class UserApi extends runtime.BaseAPI { headerParameters['Content-Type'] = 'application/json'; const response = await this.request({ - path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), + path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters['username']))), method: 'PUT', headers: headerParameters, query: queryParameters, - body: UserToJSON(requestParameters.user), + body: UserToJSON(requestParameters['user']), }, initOverrides); return new runtime.VoidApiResponse(response); diff --git a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/AdditionalPropertiesClass.ts b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/AdditionalPropertiesClass.ts index ae1161178dbc..429a86538cd1 100644 --- a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/AdditionalPropertiesClass.ts +++ b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/AdditionalPropertiesClass.ts @@ -37,9 +37,7 @@ export interface AdditionalPropertiesClass { * Check if a given object implements the AdditionalPropertiesClass interface. */ export function instanceOfAdditionalPropertiesClass(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function AdditionalPropertiesClassFromJSON(json: any): AdditionalPropertiesClass { @@ -47,7 +45,7 @@ export function AdditionalPropertiesClassFromJSON(json: any): AdditionalProperti } export function AdditionalPropertiesClassFromJSONTyped(json: any, ignoreDiscriminator: boolean): AdditionalPropertiesClass { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -66,8 +64,8 @@ export function AdditionalPropertiesClassToJSON(value?: AdditionalPropertiesClas } return { - 'map_property': value.mapProperty, - 'map_of_map_property': value.mapOfMapProperty, + 'map_property': value['mapProperty'], + 'map_of_map_property': value['mapOfMapProperty'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/AllOfWithSingleRef.ts b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/AllOfWithSingleRef.ts index 13958e2ab77f..5fc70179d079 100644 --- a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/AllOfWithSingleRef.ts +++ b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/AllOfWithSingleRef.ts @@ -44,9 +44,7 @@ export interface AllOfWithSingleRef { * Check if a given object implements the AllOfWithSingleRef interface. */ export function instanceOfAllOfWithSingleRef(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function AllOfWithSingleRefFromJSON(json: any): AllOfWithSingleRef { @@ -54,7 +52,7 @@ export function AllOfWithSingleRefFromJSON(json: any): AllOfWithSingleRef { } export function AllOfWithSingleRefFromJSONTyped(json: any, ignoreDiscriminator: boolean): AllOfWithSingleRef { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -73,8 +71,8 @@ export function AllOfWithSingleRefToJSON(value?: AllOfWithSingleRef | null): any } return { - 'username': value.username, - 'SingleRefType': SingleRefTypeToJSON(value.singleRefType), + 'username': value['username'], + 'SingleRefType': SingleRefTypeToJSON(value['singleRefType']), }; } diff --git a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/Animal.ts b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/Animal.ts index cb830e10d30f..30313f92a07b 100644 --- a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/Animal.ts +++ b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/Animal.ts @@ -42,10 +42,8 @@ export interface Animal { * Check if a given object implements the Animal interface. */ export function instanceOfAnimal(value: object): boolean { - let isInstance = true; - isInstance = isInstance && "className" in value; - - return isInstance; + if (!('className' in value)) return false; + return true; } export function AnimalFromJSON(json: any): Animal { @@ -53,7 +51,7 @@ export function AnimalFromJSON(json: any): Animal { } export function AnimalFromJSONTyped(json: any, ignoreDiscriminator: boolean): Animal { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } if (!ignoreDiscriminator) { @@ -80,8 +78,8 @@ export function AnimalToJSON(value?: Animal | null): any { } return { - 'class_name': value.className, - 'color': value.color, + 'class_name': value['className'], + 'color': value['color'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/ArrayOfArrayOfNumberOnly.ts b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/ArrayOfArrayOfNumberOnly.ts index 7ab12458982f..6aca52358716 100644 --- a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/ArrayOfArrayOfNumberOnly.ts +++ b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/ArrayOfArrayOfNumberOnly.ts @@ -31,9 +31,7 @@ export interface ArrayOfArrayOfNumberOnly { * Check if a given object implements the ArrayOfArrayOfNumberOnly interface. */ export function instanceOfArrayOfArrayOfNumberOnly(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function ArrayOfArrayOfNumberOnlyFromJSON(json: any): ArrayOfArrayOfNumberOnly { @@ -41,7 +39,7 @@ export function ArrayOfArrayOfNumberOnlyFromJSON(json: any): ArrayOfArrayOfNumbe } export function ArrayOfArrayOfNumberOnlyFromJSONTyped(json: any, ignoreDiscriminator: boolean): ArrayOfArrayOfNumberOnly { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -59,7 +57,7 @@ export function ArrayOfArrayOfNumberOnlyToJSON(value?: ArrayOfArrayOfNumberOnly } return { - 'ArrayArrayNumber': value.arrayArrayNumber, + 'ArrayArrayNumber': value['arrayArrayNumber'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/ArrayOfNumberOnly.ts b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/ArrayOfNumberOnly.ts index e0bdb81203b7..b39a628ed121 100644 --- a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/ArrayOfNumberOnly.ts +++ b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/ArrayOfNumberOnly.ts @@ -31,9 +31,7 @@ export interface ArrayOfNumberOnly { * Check if a given object implements the ArrayOfNumberOnly interface. */ export function instanceOfArrayOfNumberOnly(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function ArrayOfNumberOnlyFromJSON(json: any): ArrayOfNumberOnly { @@ -41,7 +39,7 @@ export function ArrayOfNumberOnlyFromJSON(json: any): ArrayOfNumberOnly { } export function ArrayOfNumberOnlyFromJSONTyped(json: any, ignoreDiscriminator: boolean): ArrayOfNumberOnly { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -59,7 +57,7 @@ export function ArrayOfNumberOnlyToJSON(value?: ArrayOfNumberOnly | null): any { } return { - 'ArrayNumber': value.arrayNumber, + 'ArrayNumber': value['arrayNumber'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/ArrayTest.ts b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/ArrayTest.ts index 30473cdc6562..2396708971fa 100644 --- a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/ArrayTest.ts +++ b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/ArrayTest.ts @@ -50,9 +50,7 @@ export interface ArrayTest { * Check if a given object implements the ArrayTest interface. */ export function instanceOfArrayTest(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function ArrayTestFromJSON(json: any): ArrayTest { @@ -60,7 +58,7 @@ export function ArrayTestFromJSON(json: any): ArrayTest { } export function ArrayTestFromJSONTyped(json: any, ignoreDiscriminator: boolean): ArrayTest { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -80,9 +78,9 @@ export function ArrayTestToJSON(value?: ArrayTest | null): any { } return { - 'array_of_string': value.arrayOfString, - 'array_array_of_integer': value.arrayArrayOfInteger, - 'array_array_of_model': value.arrayArrayOfModel, + 'array_of_string': value['arrayOfString'], + 'array_array_of_integer': value['arrayArrayOfInteger'], + 'array_array_of_model': value['arrayArrayOfModel'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/Capitalization.ts b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/Capitalization.ts index 53fec91847d2..30a6a48dfde4 100644 --- a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/Capitalization.ts +++ b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/Capitalization.ts @@ -62,9 +62,7 @@ export interface Capitalization { * Check if a given object implements the Capitalization interface. */ export function instanceOfCapitalization(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function CapitalizationFromJSON(json: any): Capitalization { @@ -72,7 +70,7 @@ export function CapitalizationFromJSON(json: any): Capitalization { } export function CapitalizationFromJSONTyped(json: any, ignoreDiscriminator: boolean): Capitalization { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -95,12 +93,12 @@ export function CapitalizationToJSON(value?: Capitalization | null): any { } return { - 'smallCamel': value.smallCamel, - 'CapitalCamel': value.capitalCamel, - 'small_Snake': value.smallSnake, - 'Capital_Snake': value.capitalSnake, - 'SCA_ETH_Flow_Points': value.sCAETHFlowPoints, - 'ATT_NAME': value.aTTNAME, + 'smallCamel': value['smallCamel'], + 'CapitalCamel': value['capitalCamel'], + 'small_Snake': value['smallSnake'], + 'Capital_Snake': value['capitalSnake'], + 'SCA_ETH_Flow_Points': value['sCAETHFlowPoints'], + 'ATT_NAME': value['aTTNAME'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/Cat.ts b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/Cat.ts index dabeedf26255..94507ba96b1f 100644 --- a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/Cat.ts +++ b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/Cat.ts @@ -38,9 +38,7 @@ export interface Cat extends Animal { * Check if a given object implements the Cat interface. */ export function instanceOfCat(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function CatFromJSON(json: any): Cat { @@ -48,7 +46,7 @@ export function CatFromJSON(json: any): Cat { } export function CatFromJSONTyped(json: any, ignoreDiscriminator: boolean): Cat { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -66,7 +64,7 @@ export function CatToJSON(value?: Cat | null): any { } return { ...AnimalToJSON(value), - 'declawed': value.declawed, + 'declawed': value['declawed'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/Category.ts b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/Category.ts index d1e2e3f8ac8e..3b4d927fb025 100644 --- a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/Category.ts +++ b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/Category.ts @@ -37,10 +37,8 @@ export interface Category { * Check if a given object implements the Category interface. */ export function instanceOfCategory(value: object): boolean { - let isInstance = true; - isInstance = isInstance && "name" in value; - - return isInstance; + if (!('name' in value)) return false; + return true; } export function CategoryFromJSON(json: any): Category { @@ -48,7 +46,7 @@ export function CategoryFromJSON(json: any): Category { } export function CategoryFromJSONTyped(json: any, ignoreDiscriminator: boolean): Category { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -67,8 +65,8 @@ export function CategoryToJSON(value?: Category | null): any { } return { - 'id': value.id, - 'name': value.name, + 'id': value['id'], + 'name': value['name'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/ClassModel.ts b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/ClassModel.ts index 0f01d81b15a6..6309f0dfce81 100644 --- a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/ClassModel.ts +++ b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/ClassModel.ts @@ -31,9 +31,7 @@ export interface ClassModel { * Check if a given object implements the ClassModel interface. */ export function instanceOfClassModel(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function ClassModelFromJSON(json: any): ClassModel { @@ -41,7 +39,7 @@ export function ClassModelFromJSON(json: any): ClassModel { } export function ClassModelFromJSONTyped(json: any, ignoreDiscriminator: boolean): ClassModel { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -59,7 +57,7 @@ export function ClassModelToJSON(value?: ClassModel | null): any { } return { - '_class': value._class, + '_class': value['_class'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/Client.ts b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/Client.ts index a9fd27b4f464..96e2993ca963 100644 --- a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/Client.ts +++ b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/Client.ts @@ -31,9 +31,7 @@ export interface Client { * Check if a given object implements the Client interface. */ export function instanceOfClient(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function ClientFromJSON(json: any): Client { @@ -41,7 +39,7 @@ export function ClientFromJSON(json: any): Client { } export function ClientFromJSONTyped(json: any, ignoreDiscriminator: boolean): Client { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -59,7 +57,7 @@ export function ClientToJSON(value?: Client | null): any { } return { - 'client': value.client, + 'client': value['client'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/DeprecatedObject.ts b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/DeprecatedObject.ts index 0cec2d09297d..c8113b4c9a39 100644 --- a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/DeprecatedObject.ts +++ b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/DeprecatedObject.ts @@ -31,9 +31,7 @@ export interface DeprecatedObject { * Check if a given object implements the DeprecatedObject interface. */ export function instanceOfDeprecatedObject(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function DeprecatedObjectFromJSON(json: any): DeprecatedObject { @@ -41,7 +39,7 @@ export function DeprecatedObjectFromJSON(json: any): DeprecatedObject { } export function DeprecatedObjectFromJSONTyped(json: any, ignoreDiscriminator: boolean): DeprecatedObject { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -59,7 +57,7 @@ export function DeprecatedObjectToJSON(value?: DeprecatedObject | null): any { } return { - 'name': value.name, + 'name': value['name'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/Dog.ts b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/Dog.ts index 65cd613eae03..fec18e3e484c 100644 --- a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/Dog.ts +++ b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/Dog.ts @@ -38,9 +38,7 @@ export interface Dog extends Animal { * Check if a given object implements the Dog interface. */ export function instanceOfDog(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function DogFromJSON(json: any): Dog { @@ -48,7 +46,7 @@ export function DogFromJSON(json: any): Dog { } export function DogFromJSONTyped(json: any, ignoreDiscriminator: boolean): Dog { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -66,7 +64,7 @@ export function DogToJSON(value?: Dog | null): any { } return { ...AnimalToJSON(value), - 'breed': value.breed, + 'breed': value['breed'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/EnumArrays.ts b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/EnumArrays.ts index 9603be51cd51..0c93a179655a 100644 --- a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/EnumArrays.ts +++ b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/EnumArrays.ts @@ -57,9 +57,7 @@ export type EnumArraysArrayEnumEnum = typeof EnumArraysArrayEnumEnum[keyof typeo * Check if a given object implements the EnumArrays interface. */ export function instanceOfEnumArrays(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function EnumArraysFromJSON(json: any): EnumArrays { @@ -67,7 +65,7 @@ export function EnumArraysFromJSON(json: any): EnumArrays { } export function EnumArraysFromJSONTyped(json: any, ignoreDiscriminator: boolean): EnumArrays { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -86,8 +84,8 @@ export function EnumArraysToJSON(value?: EnumArrays | null): any { } return { - 'just_symbol': value.justSymbol, - 'array_enum': value.arrayEnum, + 'just_symbol': value['justSymbol'], + 'array_enum': value['arrayEnum'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/EnumTest.ts b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/EnumTest.ts index 69e7d4c0217c..9a8b5051c321 100644 --- a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/EnumTest.ts +++ b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/EnumTest.ts @@ -73,7 +73,7 @@ export interface EnumTest { * @type {OuterEnum} * @memberof EnumTest */ - outerEnum?: OuterEnum | null; + outerEnum?: OuterEnum; /** * * @type {OuterEnumInteger} @@ -138,10 +138,8 @@ export type EnumTestEnumNumberEnum = typeof EnumTestEnumNumberEnum[keyof typeof * Check if a given object implements the EnumTest interface. */ export function instanceOfEnumTest(value: object): boolean { - let isInstance = true; - isInstance = isInstance && "enumStringRequired" in value; - - return isInstance; + if (!('enumStringRequired' in value)) return false; + return true; } export function EnumTestFromJSON(json: any): EnumTest { @@ -149,7 +147,7 @@ export function EnumTestFromJSON(json: any): EnumTest { } export function EnumTestFromJSONTyped(json: any, ignoreDiscriminator: boolean): EnumTest { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -174,14 +172,14 @@ export function EnumTestToJSON(value?: EnumTest | null): any { } return { - 'enum_string': value.enumString, - 'enum_string_required': value.enumStringRequired, - 'enum_integer': value.enumInteger, - 'enum_number': value.enumNumber, - 'outerEnum': OuterEnumToJSON(value.outerEnum), - 'outerEnumInteger': OuterEnumIntegerToJSON(value.outerEnumInteger), - 'outerEnumDefaultValue': OuterEnumDefaultValueToJSON(value.outerEnumDefaultValue), - 'outerEnumIntegerDefaultValue': OuterEnumIntegerDefaultValueToJSON(value.outerEnumIntegerDefaultValue), + 'enum_string': value['enumString'], + 'enum_string_required': value['enumStringRequired'], + 'enum_integer': value['enumInteger'], + 'enum_number': value['enumNumber'], + 'outerEnum': OuterEnumToJSON(value['outerEnum']), + 'outerEnumInteger': OuterEnumIntegerToJSON(value['outerEnumInteger']), + 'outerEnumDefaultValue': OuterEnumDefaultValueToJSON(value['outerEnumDefaultValue']), + 'outerEnumIntegerDefaultValue': OuterEnumIntegerDefaultValueToJSON(value['outerEnumIntegerDefaultValue']), }; } diff --git a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/FakeBigDecimalMap200Response.ts b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/FakeBigDecimalMap200Response.ts index 32154096ade4..bf4371a93c1e 100644 --- a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/FakeBigDecimalMap200Response.ts +++ b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/FakeBigDecimalMap200Response.ts @@ -37,9 +37,7 @@ export interface FakeBigDecimalMap200Response { * Check if a given object implements the FakeBigDecimalMap200Response interface. */ export function instanceOfFakeBigDecimalMap200Response(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function FakeBigDecimalMap200ResponseFromJSON(json: any): FakeBigDecimalMap200Response { @@ -47,7 +45,7 @@ export function FakeBigDecimalMap200ResponseFromJSON(json: any): FakeBigDecimalM } export function FakeBigDecimalMap200ResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): FakeBigDecimalMap200Response { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -66,8 +64,8 @@ export function FakeBigDecimalMap200ResponseToJSON(value?: FakeBigDecimalMap200R } return { - 'someId': value.someId, - 'someMap': value.someMap, + 'someId': value['someId'], + 'someMap': value['someMap'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/FileSchemaTestClass.ts b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/FileSchemaTestClass.ts index 71f887cf3271..10e7e77f8f87 100644 --- a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/FileSchemaTestClass.ts +++ b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/FileSchemaTestClass.ts @@ -37,9 +37,7 @@ export interface FileSchemaTestClass { * Check if a given object implements the FileSchemaTestClass interface. */ export function instanceOfFileSchemaTestClass(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function FileSchemaTestClassFromJSON(json: any): FileSchemaTestClass { @@ -47,7 +45,7 @@ export function FileSchemaTestClassFromJSON(json: any): FileSchemaTestClass { } export function FileSchemaTestClassFromJSONTyped(json: any, ignoreDiscriminator: boolean): FileSchemaTestClass { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -66,8 +64,8 @@ export function FileSchemaTestClassToJSON(value?: FileSchemaTestClass | null): a } return { - 'file': value.file, - 'files': value.files, + 'file': value['file'], + 'files': value['files'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/Foo.ts b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/Foo.ts index aa5b331c3b68..ec179ce581b5 100644 --- a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/Foo.ts +++ b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/Foo.ts @@ -31,9 +31,7 @@ export interface Foo { * Check if a given object implements the Foo interface. */ export function instanceOfFoo(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function FooFromJSON(json: any): Foo { @@ -41,7 +39,7 @@ export function FooFromJSON(json: any): Foo { } export function FooFromJSONTyped(json: any, ignoreDiscriminator: boolean): Foo { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -59,7 +57,7 @@ export function FooToJSON(value?: Foo | null): any { } return { - 'bar': value.bar, + 'bar': value['bar'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/FooGetDefaultResponse.ts b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/FooGetDefaultResponse.ts index 3d49ed834fc6..ffd3e185c760 100644 --- a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/FooGetDefaultResponse.ts +++ b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/FooGetDefaultResponse.ts @@ -38,9 +38,7 @@ export interface FooGetDefaultResponse { * Check if a given object implements the FooGetDefaultResponse interface. */ export function instanceOfFooGetDefaultResponse(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function FooGetDefaultResponseFromJSON(json: any): FooGetDefaultResponse { @@ -48,7 +46,7 @@ export function FooGetDefaultResponseFromJSON(json: any): FooGetDefaultResponse } export function FooGetDefaultResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): FooGetDefaultResponse { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -66,7 +64,7 @@ export function FooGetDefaultResponseToJSON(value?: FooGetDefaultResponse | null } return { - 'string': FooToJSON(value.string), + 'string': FooToJSON(value['string']), }; } diff --git a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/FormatTest.ts b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/FormatTest.ts index f095016dd22f..b509f3575a2f 100644 --- a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/FormatTest.ts +++ b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/FormatTest.ts @@ -128,13 +128,11 @@ export interface FormatTest { * Check if a given object implements the FormatTest interface. */ export function instanceOfFormatTest(value: object): boolean { - let isInstance = true; - isInstance = isInstance && "number" in value; - isInstance = isInstance && "_byte" in value; - isInstance = isInstance && "date" in value; - isInstance = isInstance && "password" in value; - - return isInstance; + if (!('number' in value)) return false; + if (!('_byte' in value)) return false; + if (!('date' in value)) return false; + if (!('password' in value)) return false; + return true; } export function FormatTestFromJSON(json: any): FormatTest { @@ -142,7 +140,7 @@ export function FormatTestFromJSON(json: any): FormatTest { } export function FormatTestFromJSONTyped(json: any, ignoreDiscriminator: boolean): FormatTest { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -175,22 +173,22 @@ export function FormatTestToJSON(value?: FormatTest | null): any { } return { - 'integer': value.integer, - 'int32': value.int32, - 'int64': value.int64, - 'number': value.number, - 'float': value._float, - 'double': value._double, - 'decimal': DecimalToJSON(value.decimal), - 'string': value.string, - 'byte': value._byte, - 'binary': value.binary, - 'date': (value.date.toISOString().substring(0,10)), - 'dateTime': value.dateTime === undefined ? undefined : (value.dateTime.toISOString()), - 'uuid': value.uuid, - 'password': value.password, - 'pattern_with_digits': value.patternWithDigits, - 'pattern_with_digits_and_delimiter': value.patternWithDigitsAndDelimiter, + 'integer': value['integer'], + 'int32': value['int32'], + 'int64': value['int64'], + 'number': value['number'], + 'float': value['_float'], + 'double': value['_double'], + 'decimal': DecimalToJSON(value['decimal']), + 'string': value['string'], + 'byte': value['_byte'], + 'binary': value['binary'], + 'date': ((value['date']).toISOString().substring(0,10)), + 'dateTime': !exists(value, 'dateTime') ? undefined : ((value['dateTime']).toISOString()), + 'uuid': value['uuid'], + 'password': value['password'], + 'pattern_with_digits': value['patternWithDigits'], + 'pattern_with_digits_and_delimiter': value['patternWithDigitsAndDelimiter'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/HasOnlyReadOnly.ts b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/HasOnlyReadOnly.ts index d3dc4be6767e..e59842cd3e2f 100644 --- a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/HasOnlyReadOnly.ts +++ b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/HasOnlyReadOnly.ts @@ -37,9 +37,7 @@ export interface HasOnlyReadOnly { * Check if a given object implements the HasOnlyReadOnly interface. */ export function instanceOfHasOnlyReadOnly(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function HasOnlyReadOnlyFromJSON(json: any): HasOnlyReadOnly { @@ -47,7 +45,7 @@ export function HasOnlyReadOnlyFromJSON(json: any): HasOnlyReadOnly { } export function HasOnlyReadOnlyFromJSONTyped(json: any, ignoreDiscriminator: boolean): HasOnlyReadOnly { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { diff --git a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/HealthCheckResult.ts b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/HealthCheckResult.ts index d62e1f09b823..6d58f178cdcb 100644 --- a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/HealthCheckResult.ts +++ b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/HealthCheckResult.ts @@ -24,16 +24,14 @@ export interface HealthCheckResult { * @type {string} * @memberof HealthCheckResult */ - nullableMessage?: string | null; + nullableMessage?: string; } /** * Check if a given object implements the HealthCheckResult interface. */ export function instanceOfHealthCheckResult(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function HealthCheckResultFromJSON(json: any): HealthCheckResult { @@ -41,7 +39,7 @@ export function HealthCheckResultFromJSON(json: any): HealthCheckResult { } export function HealthCheckResultFromJSONTyped(json: any, ignoreDiscriminator: boolean): HealthCheckResult { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -59,7 +57,7 @@ export function HealthCheckResultToJSON(value?: HealthCheckResult | null): any { } return { - 'NullableMessage': value.nullableMessage, + 'NullableMessage': value['nullableMessage'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/List.ts b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/List.ts index 1334322e823a..c4afb61a4de4 100644 --- a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/List.ts +++ b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/List.ts @@ -31,9 +31,7 @@ export interface List { * Check if a given object implements the List interface. */ export function instanceOfList(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function ListFromJSON(json: any): List { @@ -41,7 +39,7 @@ export function ListFromJSON(json: any): List { } export function ListFromJSONTyped(json: any, ignoreDiscriminator: boolean): List { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -59,7 +57,7 @@ export function ListToJSON(value?: List | null): any { } return { - '123-list': value._123list, + '123-list': value['_123list'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/MapTest.ts b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/MapTest.ts index 2ae39dd903f1..b36dfda98d88 100644 --- a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/MapTest.ts +++ b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/MapTest.ts @@ -60,9 +60,7 @@ export type MapTestMapOfEnumStringEnum = typeof MapTestMapOfEnumStringEnum[keyof * Check if a given object implements the MapTest interface. */ export function instanceOfMapTest(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function MapTestFromJSON(json: any): MapTest { @@ -70,7 +68,7 @@ export function MapTestFromJSON(json: any): MapTest { } export function MapTestFromJSONTyped(json: any, ignoreDiscriminator: boolean): MapTest { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -91,10 +89,10 @@ export function MapTestToJSON(value?: MapTest | null): any { } return { - 'map_map_of_string': value.mapMapOfString, - 'map_of_enum_string': value.mapOfEnumString, - 'direct_map': value.directMap, - 'indirect_map': value.indirectMap, + 'map_map_of_string': value['mapMapOfString'], + 'map_of_enum_string': value['mapOfEnumString'], + 'direct_map': value['directMap'], + 'indirect_map': value['indirectMap'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/MixedPropertiesAndAdditionalPropertiesClass.ts b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/MixedPropertiesAndAdditionalPropertiesClass.ts index 56e0a29e437d..f22b2b72a221 100644 --- a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/MixedPropertiesAndAdditionalPropertiesClass.ts +++ b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/MixedPropertiesAndAdditionalPropertiesClass.ts @@ -50,9 +50,7 @@ export interface MixedPropertiesAndAdditionalPropertiesClass { * Check if a given object implements the MixedPropertiesAndAdditionalPropertiesClass interface. */ export function instanceOfMixedPropertiesAndAdditionalPropertiesClass(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function MixedPropertiesAndAdditionalPropertiesClassFromJSON(json: any): MixedPropertiesAndAdditionalPropertiesClass { @@ -60,7 +58,7 @@ export function MixedPropertiesAndAdditionalPropertiesClassFromJSON(json: any): } export function MixedPropertiesAndAdditionalPropertiesClassFromJSONTyped(json: any, ignoreDiscriminator: boolean): MixedPropertiesAndAdditionalPropertiesClass { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -80,9 +78,9 @@ export function MixedPropertiesAndAdditionalPropertiesClassToJSON(value?: MixedP } return { - 'uuid': value.uuid, - 'dateTime': value.dateTime === undefined ? undefined : (value.dateTime.toISOString()), - 'map': value.map === undefined ? undefined : (mapValues(value.map, AnimalToJSON)), + 'uuid': value['uuid'], + 'dateTime': !exists(value, 'dateTime') ? undefined : ((value['dateTime']).toISOString()), + 'map': !exists(value, 'map') ? undefined : (mapValues(value['map'], AnimalToJSON)), }; } diff --git a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/Model200Response.ts b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/Model200Response.ts index 8b32d414747a..8cabcd2d4b3e 100644 --- a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/Model200Response.ts +++ b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/Model200Response.ts @@ -37,9 +37,7 @@ export interface Model200Response { * Check if a given object implements the Model200Response interface. */ export function instanceOfModel200Response(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function Model200ResponseFromJSON(json: any): Model200Response { @@ -47,7 +45,7 @@ export function Model200ResponseFromJSON(json: any): Model200Response { } export function Model200ResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): Model200Response { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -66,8 +64,8 @@ export function Model200ResponseToJSON(value?: Model200Response | null): any { } return { - 'name': value.name, - 'class': value._class, + 'name': value['name'], + 'class': value['_class'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/ModelApiResponse.ts b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/ModelApiResponse.ts index 8001d49c55bf..b3685aea30ad 100644 --- a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/ModelApiResponse.ts +++ b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/ModelApiResponse.ts @@ -43,9 +43,7 @@ export interface ModelApiResponse { * Check if a given object implements the ModelApiResponse interface. */ export function instanceOfModelApiResponse(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function ModelApiResponseFromJSON(json: any): ModelApiResponse { @@ -53,7 +51,7 @@ export function ModelApiResponseFromJSON(json: any): ModelApiResponse { } export function ModelApiResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): ModelApiResponse { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -73,9 +71,9 @@ export function ModelApiResponseToJSON(value?: ModelApiResponse | null): any { } return { - 'code': value.code, - 'type': value.type, - 'message': value.message, + 'code': value['code'], + 'type': value['type'], + 'message': value['message'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/ModelFile.ts b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/ModelFile.ts index 9d269ea77a1c..0611bad737d6 100644 --- a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/ModelFile.ts +++ b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/ModelFile.ts @@ -31,9 +31,7 @@ export interface ModelFile { * Check if a given object implements the ModelFile interface. */ export function instanceOfModelFile(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function ModelFileFromJSON(json: any): ModelFile { @@ -41,7 +39,7 @@ export function ModelFileFromJSON(json: any): ModelFile { } export function ModelFileFromJSONTyped(json: any, ignoreDiscriminator: boolean): ModelFile { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -59,7 +57,7 @@ export function ModelFileToJSON(value?: ModelFile | null): any { } return { - 'sourceURI': value.sourceURI, + 'sourceURI': value['sourceURI'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/Name.ts b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/Name.ts index f58a563b8b5f..4ba736c85a45 100644 --- a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/Name.ts +++ b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/Name.ts @@ -49,10 +49,8 @@ export interface Name { * Check if a given object implements the Name interface. */ export function instanceOfName(value: object): boolean { - let isInstance = true; - isInstance = isInstance && "name" in value; - - return isInstance; + if (!('name' in value)) return false; + return true; } export function NameFromJSON(json: any): Name { @@ -60,7 +58,7 @@ export function NameFromJSON(json: any): Name { } export function NameFromJSONTyped(json: any, ignoreDiscriminator: boolean): Name { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -81,8 +79,8 @@ export function NameToJSON(value?: Name | null): any { } return { - 'name': value.name, - 'property': value.property, + 'name': value['name'], + 'property': value['property'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/NullableClass.ts b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/NullableClass.ts index 52e1a2171642..de25ab3382a4 100644 --- a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/NullableClass.ts +++ b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/NullableClass.ts @@ -25,49 +25,49 @@ export interface NullableClass { * @type {number} * @memberof NullableClass */ - integerProp?: number | null; + integerProp?: number; /** * * @type {number} * @memberof NullableClass */ - numberProp?: number | null; + numberProp?: number; /** * * @type {boolean} * @memberof NullableClass */ - booleanProp?: boolean | null; + booleanProp?: boolean; /** * * @type {string} * @memberof NullableClass */ - stringProp?: string | null; + stringProp?: string; /** * * @type {Date} * @memberof NullableClass */ - dateProp?: Date | null; + dateProp?: Date; /** * * @type {Date} * @memberof NullableClass */ - datetimeProp?: Date | null; + datetimeProp?: Date; /** * * @type {Array} * @memberof NullableClass */ - arrayNullableProp?: Array | null; + arrayNullableProp?: Array; /** * * @type {Array} * @memberof NullableClass */ - arrayAndItemsNullableProp?: Array | null; + arrayAndItemsNullableProp?: Array; /** * * @type {Array} @@ -79,13 +79,13 @@ export interface NullableClass { * @type {{ [key: string]: object; }} * @memberof NullableClass */ - objectNullableProp?: { [key: string]: object; } | null; + objectNullableProp?: { [key: string]: object; }; /** * * @type {{ [key: string]: object | null; }} * @memberof NullableClass */ - objectAndItemsNullableProp?: { [key: string]: object | null; } | null; + objectAndItemsNullableProp?: { [key: string]: object | null; }; /** * * @type {{ [key: string]: object | null; }} @@ -98,9 +98,7 @@ export interface NullableClass { * Check if a given object implements the NullableClass interface. */ export function instanceOfNullableClass(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function NullableClassFromJSON(json: any): NullableClass { @@ -108,7 +106,7 @@ export function NullableClassFromJSON(json: any): NullableClass { } export function NullableClassFromJSONTyped(json: any, ignoreDiscriminator: boolean): NullableClass { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -118,8 +116,8 @@ export function NullableClassFromJSONTyped(json: any, ignoreDiscriminator: boole 'numberProp': !exists(json, 'number_prop') ? undefined : json['number_prop'], 'booleanProp': !exists(json, 'boolean_prop') ? undefined : json['boolean_prop'], 'stringProp': !exists(json, 'string_prop') ? undefined : json['string_prop'], - 'dateProp': !exists(json, 'date_prop') ? undefined : (json['date_prop'] === null ? null : new Date(json['date_prop'])), - 'datetimeProp': !exists(json, 'datetime_prop') ? undefined : (json['datetime_prop'] === null ? null : new Date(json['datetime_prop'])), + 'dateProp': !exists(json, 'date_prop') ? undefined : (new Date(json['date_prop'])), + 'datetimeProp': !exists(json, 'datetime_prop') ? undefined : (new Date(json['datetime_prop'])), 'arrayNullableProp': !exists(json, 'array_nullable_prop') ? undefined : json['array_nullable_prop'], 'arrayAndItemsNullableProp': !exists(json, 'array_and_items_nullable_prop') ? undefined : json['array_and_items_nullable_prop'], 'arrayItemsNullable': !exists(json, 'array_items_nullable') ? undefined : json['array_items_nullable'], @@ -139,18 +137,18 @@ export function NullableClassToJSON(value?: NullableClass | null): any { return { ...value, - 'integer_prop': value.integerProp, - 'number_prop': value.numberProp, - 'boolean_prop': value.booleanProp, - 'string_prop': value.stringProp, - 'date_prop': value.dateProp === undefined ? undefined : (value.dateProp === null ? null : value.dateProp.toISOString().substring(0,10)), - 'datetime_prop': value.datetimeProp === undefined ? undefined : (value.datetimeProp === null ? null : value.datetimeProp.toISOString()), - 'array_nullable_prop': value.arrayNullableProp, - 'array_and_items_nullable_prop': value.arrayAndItemsNullableProp, - 'array_items_nullable': value.arrayItemsNullable, - 'object_nullable_prop': value.objectNullableProp, - 'object_and_items_nullable_prop': value.objectAndItemsNullableProp, - 'object_items_nullable': value.objectItemsNullable, + 'integer_prop': value['integerProp'], + 'number_prop': value['numberProp'], + 'boolean_prop': value['booleanProp'], + 'string_prop': value['stringProp'], + 'date_prop': !exists(value, 'dateProp') ? undefined : ((value['dateProp'] as any).toISOString().substring(0,10)), + 'datetime_prop': !exists(value, 'datetimeProp') ? undefined : ((value['datetimeProp'] as any).toISOString()), + 'array_nullable_prop': value['arrayNullableProp'], + 'array_and_items_nullable_prop': value['arrayAndItemsNullableProp'], + 'array_items_nullable': value['arrayItemsNullable'], + 'object_nullable_prop': value['objectNullableProp'], + 'object_and_items_nullable_prop': value['objectAndItemsNullableProp'], + 'object_items_nullable': value['objectItemsNullable'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/NumberOnly.ts b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/NumberOnly.ts index f8d62e3fce5e..7a25240d3537 100644 --- a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/NumberOnly.ts +++ b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/NumberOnly.ts @@ -31,9 +31,7 @@ export interface NumberOnly { * Check if a given object implements the NumberOnly interface. */ export function instanceOfNumberOnly(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function NumberOnlyFromJSON(json: any): NumberOnly { @@ -41,7 +39,7 @@ export function NumberOnlyFromJSON(json: any): NumberOnly { } export function NumberOnlyFromJSONTyped(json: any, ignoreDiscriminator: boolean): NumberOnly { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -59,7 +57,7 @@ export function NumberOnlyToJSON(value?: NumberOnly | null): any { } return { - 'JustNumber': value.justNumber, + 'JustNumber': value['justNumber'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/ObjectWithDeprecatedFields.ts b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/ObjectWithDeprecatedFields.ts index 335d6d726df7..4a921582669f 100644 --- a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/ObjectWithDeprecatedFields.ts +++ b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/ObjectWithDeprecatedFields.ts @@ -59,9 +59,7 @@ export interface ObjectWithDeprecatedFields { * Check if a given object implements the ObjectWithDeprecatedFields interface. */ export function instanceOfObjectWithDeprecatedFields(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function ObjectWithDeprecatedFieldsFromJSON(json: any): ObjectWithDeprecatedFields { @@ -69,7 +67,7 @@ export function ObjectWithDeprecatedFieldsFromJSON(json: any): ObjectWithDepreca } export function ObjectWithDeprecatedFieldsFromJSONTyped(json: any, ignoreDiscriminator: boolean): ObjectWithDeprecatedFields { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -90,10 +88,10 @@ export function ObjectWithDeprecatedFieldsToJSON(value?: ObjectWithDeprecatedFie } return { - 'uuid': value.uuid, - 'id': value.id, - 'deprecatedRef': DeprecatedObjectToJSON(value.deprecatedRef), - 'bars': value.bars, + 'uuid': value['uuid'], + 'id': value['id'], + 'deprecatedRef': DeprecatedObjectToJSON(value['deprecatedRef']), + 'bars': value['bars'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/Order.ts b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/Order.ts index cd72c59ea5c3..6f2b79b5c85b 100644 --- a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/Order.ts +++ b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/Order.ts @@ -73,9 +73,7 @@ export type OrderStatusEnum = typeof OrderStatusEnum[keyof typeof OrderStatusEnu * Check if a given object implements the Order interface. */ export function instanceOfOrder(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function OrderFromJSON(json: any): Order { @@ -83,7 +81,7 @@ export function OrderFromJSON(json: any): Order { } export function OrderFromJSONTyped(json: any, ignoreDiscriminator: boolean): Order { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -106,12 +104,12 @@ export function OrderToJSON(value?: Order | null): any { } return { - 'id': value.id, - 'petId': value.petId, - 'quantity': value.quantity, - 'shipDate': value.shipDate === undefined ? undefined : (value.shipDate.toISOString()), - 'status': value.status, - 'complete': value.complete, + 'id': value['id'], + 'petId': value['petId'], + 'quantity': value['quantity'], + 'shipDate': !exists(value, 'shipDate') ? undefined : ((value['shipDate']).toISOString()), + 'status': value['status'], + 'complete': value['complete'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/OuterComposite.ts b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/OuterComposite.ts index 41434f59f308..14b4e4542fab 100644 --- a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/OuterComposite.ts +++ b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/OuterComposite.ts @@ -43,9 +43,7 @@ export interface OuterComposite { * Check if a given object implements the OuterComposite interface. */ export function instanceOfOuterComposite(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function OuterCompositeFromJSON(json: any): OuterComposite { @@ -53,7 +51,7 @@ export function OuterCompositeFromJSON(json: any): OuterComposite { } export function OuterCompositeFromJSONTyped(json: any, ignoreDiscriminator: boolean): OuterComposite { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -73,9 +71,9 @@ export function OuterCompositeToJSON(value?: OuterComposite | null): any { } return { - 'my_number': value.myNumber, - 'my_string': value.myString, - 'my_boolean': value.myBoolean, + 'my_number': value['myNumber'], + 'my_string': value['myString'], + 'my_boolean': value['myBoolean'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/OuterObjectWithEnumProperty.ts b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/OuterObjectWithEnumProperty.ts index d9626d5a0d2c..1182b747df28 100644 --- a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/OuterObjectWithEnumProperty.ts +++ b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/OuterObjectWithEnumProperty.ts @@ -38,10 +38,8 @@ export interface OuterObjectWithEnumProperty { * Check if a given object implements the OuterObjectWithEnumProperty interface. */ export function instanceOfOuterObjectWithEnumProperty(value: object): boolean { - let isInstance = true; - isInstance = isInstance && "value" in value; - - return isInstance; + if (!('value' in value)) return false; + return true; } export function OuterObjectWithEnumPropertyFromJSON(json: any): OuterObjectWithEnumProperty { @@ -49,7 +47,7 @@ export function OuterObjectWithEnumPropertyFromJSON(json: any): OuterObjectWithE } export function OuterObjectWithEnumPropertyFromJSONTyped(json: any, ignoreDiscriminator: boolean): OuterObjectWithEnumProperty { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -67,7 +65,7 @@ export function OuterObjectWithEnumPropertyToJSON(value?: OuterObjectWithEnumPro } return { - 'value': OuterEnumIntegerToJSON(value.value), + 'value': OuterEnumIntegerToJSON(value['value']), }; } diff --git a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/Pet.ts b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/Pet.ts index 33e2b6db7973..e53a44fc33f5 100644 --- a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/Pet.ts +++ b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/Pet.ts @@ -86,11 +86,9 @@ export type PetStatusEnum = typeof PetStatusEnum[keyof typeof PetStatusEnum]; * Check if a given object implements the Pet interface. */ export function instanceOfPet(value: object): boolean { - let isInstance = true; - isInstance = isInstance && "name" in value; - isInstance = isInstance && "photoUrls" in value; - - return isInstance; + if (!('name' in value)) return false; + if (!('photoUrls' in value)) return false; + return true; } export function PetFromJSON(json: any): Pet { @@ -98,7 +96,7 @@ export function PetFromJSON(json: any): Pet { } export function PetFromJSONTyped(json: any, ignoreDiscriminator: boolean): Pet { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -121,12 +119,12 @@ export function PetToJSON(value?: Pet | null): any { } return { - 'id': value.id, - 'category': CategoryToJSON(value.category), - 'name': value.name, - 'photoUrls': Array.from(value.photoUrls as Set), - 'tags': value.tags === undefined ? undefined : ((value.tags as Array).map(TagToJSON)), - 'status': value.status, + 'id': value['id'], + 'category': CategoryToJSON(value['category']), + 'name': value['name'], + 'photoUrls': Array.from(value['photoUrls'] as Set), + 'tags': !exists(value, 'tags') ? undefined : ((value['tags'] as Array).map(TagToJSON)), + 'status': value['status'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/ReadOnlyFirst.ts b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/ReadOnlyFirst.ts index 66d83cff7846..97c192be7826 100644 --- a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/ReadOnlyFirst.ts +++ b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/ReadOnlyFirst.ts @@ -37,9 +37,7 @@ export interface ReadOnlyFirst { * Check if a given object implements the ReadOnlyFirst interface. */ export function instanceOfReadOnlyFirst(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function ReadOnlyFirstFromJSON(json: any): ReadOnlyFirst { @@ -47,7 +45,7 @@ export function ReadOnlyFirstFromJSON(json: any): ReadOnlyFirst { } export function ReadOnlyFirstFromJSONTyped(json: any, ignoreDiscriminator: boolean): ReadOnlyFirst { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -66,7 +64,7 @@ export function ReadOnlyFirstToJSON(value?: ReadOnlyFirst | null): any { } return { - 'baz': value.baz, + 'baz': value['baz'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/Return.ts b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/Return.ts index 64d125505b16..9d2a3787c26d 100644 --- a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/Return.ts +++ b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/Return.ts @@ -31,9 +31,7 @@ export interface Return { * Check if a given object implements the Return interface. */ export function instanceOfReturn(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function ReturnFromJSON(json: any): Return { @@ -41,7 +39,7 @@ export function ReturnFromJSON(json: any): Return { } export function ReturnFromJSONTyped(json: any, ignoreDiscriminator: boolean): Return { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -59,7 +57,7 @@ export function ReturnToJSON(value?: Return | null): any { } return { - 'return': value._return, + 'return': value['_return'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/SpecialModelName.ts b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/SpecialModelName.ts index aa9065c48671..414fcb168909 100644 --- a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/SpecialModelName.ts +++ b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/SpecialModelName.ts @@ -31,9 +31,7 @@ export interface SpecialModelName { * Check if a given object implements the SpecialModelName interface. */ export function instanceOfSpecialModelName(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function SpecialModelNameFromJSON(json: any): SpecialModelName { @@ -41,7 +39,7 @@ export function SpecialModelNameFromJSON(json: any): SpecialModelName { } export function SpecialModelNameFromJSONTyped(json: any, ignoreDiscriminator: boolean): SpecialModelName { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -59,7 +57,7 @@ export function SpecialModelNameToJSON(value?: SpecialModelName | null): any { } return { - '$special[property.name]': value.$specialPropertyName, + '$special[property.name]': value['$specialPropertyName'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/Tag.ts b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/Tag.ts index b52383c07ea4..446a1d0da769 100644 --- a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/Tag.ts +++ b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/Tag.ts @@ -37,9 +37,7 @@ export interface Tag { * Check if a given object implements the Tag interface. */ export function instanceOfTag(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function TagFromJSON(json: any): Tag { @@ -47,7 +45,7 @@ export function TagFromJSON(json: any): Tag { } export function TagFromJSONTyped(json: any, ignoreDiscriminator: boolean): Tag { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -66,8 +64,8 @@ export function TagToJSON(value?: Tag | null): any { } return { - 'id': value.id, - 'name': value.name, + 'id': value['id'], + 'name': value['name'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/User.ts b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/User.ts index daa30cd6783f..ed2c73a101e7 100644 --- a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/User.ts +++ b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/User.ts @@ -73,9 +73,7 @@ export interface User { * Check if a given object implements the User interface. */ export function instanceOfUser(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function UserFromJSON(json: any): User { @@ -83,7 +81,7 @@ export function UserFromJSON(json: any): User { } export function UserFromJSONTyped(json: any, ignoreDiscriminator: boolean): User { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -108,14 +106,14 @@ export function UserToJSON(value?: User | null): any { } return { - 'id': value.id, - 'username': value.username, - 'firstName': value.firstName, - 'lastName': value.lastName, - 'email': value.email, - 'password': value.password, - 'phone': value.phone, - 'userStatus': value.userStatus, + 'id': value['id'], + 'username': value['username'], + 'firstName': value['firstName'], + 'lastName': value['lastName'], + 'email': value['email'], + 'password': value['password'], + 'phone': value['phone'], + 'userStatus': value['userStatus'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/runtime.ts b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/runtime.ts index 62bff92142aa..11b3fb68ebf9 100644 --- a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/runtime.ts @@ -310,9 +310,9 @@ export interface RequestOpts { body?: HTTPBody; } -export function exists(json: any, key: string) { +export function exists(json: any, key: string): boolean { const value = json[key]; - return value !== null && value !== undefined; + return value !== undefined && value !== null; } export function querystring(params: HTTPQuery, prefix: string = ''): string { diff --git a/samples/client/petstore/typescript-fetch/builds/with-interfaces/apis/PetApi.ts b/samples/client/petstore/typescript-fetch/builds/with-interfaces/apis/PetApi.ts index 945aa959ca08..5e23cca93b1a 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-interfaces/apis/PetApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-interfaces/apis/PetApi.ts @@ -210,8 +210,11 @@ export class PetApi extends runtime.BaseAPI implements PetApiInterface { * Add a new pet to the store */ async addPetRaw(requestParameters: AddPetRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.body === null || requestParameters.body === undefined) { - throw new runtime.RequiredError('body','Required parameter requestParameters.body was null or undefined when calling addPet.'); + if (!runtime.exists(requestParameters, 'body')) { + throw new runtime.RequiredError( + 'body', + 'Required parameter "body" was null or undefined when calling addPet().' + ); } const queryParameters: any = {}; @@ -230,7 +233,7 @@ export class PetApi extends runtime.BaseAPI implements PetApiInterface { method: 'POST', headers: headerParameters, query: queryParameters, - body: PetToJSON(requestParameters.body), + body: PetToJSON(requestParameters['body']), }, initOverrides); return new runtime.VoidApiResponse(response); @@ -247,16 +250,19 @@ export class PetApi extends runtime.BaseAPI implements PetApiInterface { * Deletes a pet */ async deletePetRaw(requestParameters: DeletePetRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.petId === null || requestParameters.petId === undefined) { - throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling deletePet.'); + if (!runtime.exists(requestParameters, 'petId')) { + throw new runtime.RequiredError( + 'petId', + 'Required parameter "petId" was null or undefined when calling deletePet().' + ); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; - if (requestParameters.apiKey !== undefined && requestParameters.apiKey !== null) { - headerParameters['api_key'] = String(requestParameters.apiKey); + if (runtime.exists(requestParameters, 'apiKey')) { + headerParameters['api_key'] = String(requestParameters['apiKey']); } if (this.configuration && this.configuration.accessToken) { @@ -265,7 +271,7 @@ export class PetApi extends runtime.BaseAPI implements PetApiInterface { } const response = await this.request({ - path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), + path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters['petId']))), method: 'DELETE', headers: headerParameters, query: queryParameters, @@ -286,14 +292,17 @@ export class PetApi extends runtime.BaseAPI implements PetApiInterface { * Finds Pets by status */ async findPetsByStatusRaw(requestParameters: FindPetsByStatusRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>> { - if (requestParameters.status === null || requestParameters.status === undefined) { - throw new runtime.RequiredError('status','Required parameter requestParameters.status was null or undefined when calling findPetsByStatus.'); + if (!runtime.exists(requestParameters, 'status')) { + throw new runtime.RequiredError( + 'status', + 'Required parameter "status" was null or undefined when calling findPetsByStatus().' + ); } const queryParameters: any = {}; - if (requestParameters.status) { - queryParameters['status'] = requestParameters.status.join(runtime.COLLECTION_FORMATS["csv"]); + if (runtime.exists(requestParameters, 'status')) { + queryParameters['status'] = requestParameters['status']!.join(runtime.COLLECTION_FORMATS["csv"]); } const headerParameters: runtime.HTTPHeaders = {}; @@ -328,14 +337,17 @@ export class PetApi extends runtime.BaseAPI implements PetApiInterface { * @deprecated */ async findPetsByTagsRaw(requestParameters: FindPetsByTagsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>> { - if (requestParameters.tags === null || requestParameters.tags === undefined) { - throw new runtime.RequiredError('tags','Required parameter requestParameters.tags was null or undefined when calling findPetsByTags.'); + if (!runtime.exists(requestParameters, 'tags')) { + throw new runtime.RequiredError( + 'tags', + 'Required parameter "tags" was null or undefined when calling findPetsByTags().' + ); } const queryParameters: any = {}; - if (requestParameters.tags) { - queryParameters['tags'] = requestParameters.tags.join(runtime.COLLECTION_FORMATS["csv"]); + if (runtime.exists(requestParameters, 'tags')) { + queryParameters['tags'] = requestParameters['tags']!.join(runtime.COLLECTION_FORMATS["csv"]); } const headerParameters: runtime.HTTPHeaders = {}; @@ -370,8 +382,11 @@ export class PetApi extends runtime.BaseAPI implements PetApiInterface { * Find pet by ID */ async getPetByIdRaw(requestParameters: GetPetByIdRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.petId === null || requestParameters.petId === undefined) { - throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling getPetById.'); + if (!runtime.exists(requestParameters, 'petId')) { + throw new runtime.RequiredError( + 'petId', + 'Required parameter "petId" was null or undefined when calling getPetById().' + ); } const queryParameters: any = {}; @@ -383,7 +398,7 @@ export class PetApi extends runtime.BaseAPI implements PetApiInterface { } const response = await this.request({ - path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), + path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters['petId']))), method: 'GET', headers: headerParameters, query: queryParameters, @@ -405,8 +420,11 @@ export class PetApi extends runtime.BaseAPI implements PetApiInterface { * Update an existing pet */ async updatePetRaw(requestParameters: UpdatePetRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.body === null || requestParameters.body === undefined) { - throw new runtime.RequiredError('body','Required parameter requestParameters.body was null or undefined when calling updatePet.'); + if (!runtime.exists(requestParameters, 'body')) { + throw new runtime.RequiredError( + 'body', + 'Required parameter "body" was null or undefined when calling updatePet().' + ); } const queryParameters: any = {}; @@ -425,7 +443,7 @@ export class PetApi extends runtime.BaseAPI implements PetApiInterface { method: 'PUT', headers: headerParameters, query: queryParameters, - body: PetToJSON(requestParameters.body), + body: PetToJSON(requestParameters['body']), }, initOverrides); return new runtime.VoidApiResponse(response); @@ -442,8 +460,11 @@ export class PetApi extends runtime.BaseAPI implements PetApiInterface { * Updates a pet in the store with form data */ async updatePetWithFormRaw(requestParameters: UpdatePetWithFormRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.petId === null || requestParameters.petId === undefined) { - throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling updatePetWithForm.'); + if (!runtime.exists(requestParameters, 'petId')) { + throw new runtime.RequiredError( + 'petId', + 'Required parameter "petId" was null or undefined when calling updatePetWithForm().' + ); } const queryParameters: any = {}; @@ -469,16 +490,16 @@ export class PetApi extends runtime.BaseAPI implements PetApiInterface { formParams = new URLSearchParams(); } - if (requestParameters.name !== undefined) { - formParams.append('name', requestParameters.name as any); + if (runtime.exists(requestParameters, 'name')) { + formParams.append('name', requestParameters['name'] as any); } - if (requestParameters.status !== undefined) { - formParams.append('status', requestParameters.status as any); + if (runtime.exists(requestParameters, 'status')) { + formParams.append('status', requestParameters['status'] as any); } const response = await this.request({ - path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), + path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters['petId']))), method: 'POST', headers: headerParameters, query: queryParameters, @@ -499,8 +520,11 @@ export class PetApi extends runtime.BaseAPI implements PetApiInterface { * uploads an image */ async uploadFileRaw(requestParameters: UploadFileRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.petId === null || requestParameters.petId === undefined) { - throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling uploadFile.'); + if (!runtime.exists(requestParameters, 'petId')) { + throw new runtime.RequiredError( + 'petId', + 'Required parameter "petId" was null or undefined when calling uploadFile().' + ); } const queryParameters: any = {}; @@ -528,16 +552,16 @@ export class PetApi extends runtime.BaseAPI implements PetApiInterface { formParams = new URLSearchParams(); } - if (requestParameters.additionalMetadata !== undefined) { - formParams.append('additionalMetadata', requestParameters.additionalMetadata as any); + if (runtime.exists(requestParameters, 'additionalMetadata')) { + formParams.append('additionalMetadata', requestParameters['additionalMetadata'] as any); } - if (requestParameters.file !== undefined) { - formParams.append('file', requestParameters.file as any); + if (runtime.exists(requestParameters, 'file')) { + formParams.append('file', requestParameters['file'] as any); } const response = await this.request({ - path: `/pet/{petId}/uploadImage`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), + path: `/pet/{petId}/uploadImage`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters['petId']))), method: 'POST', headers: headerParameters, query: queryParameters, diff --git a/samples/client/petstore/typescript-fetch/builds/with-interfaces/apis/StoreApi.ts b/samples/client/petstore/typescript-fetch/builds/with-interfaces/apis/StoreApi.ts index cf68a43acd3c..3b01cbdee12c 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-interfaces/apis/StoreApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-interfaces/apis/StoreApi.ts @@ -115,8 +115,11 @@ export class StoreApi extends runtime.BaseAPI implements StoreApiInterface { * Delete purchase order by ID */ async deleteOrderRaw(requestParameters: DeleteOrderRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.orderId === null || requestParameters.orderId === undefined) { - throw new runtime.RequiredError('orderId','Required parameter requestParameters.orderId was null or undefined when calling deleteOrder.'); + if (!runtime.exists(requestParameters, 'orderId')) { + throw new runtime.RequiredError( + 'orderId', + 'Required parameter "orderId" was null or undefined when calling deleteOrder().' + ); } const queryParameters: any = {}; @@ -124,7 +127,7 @@ export class StoreApi extends runtime.BaseAPI implements StoreApiInterface { const headerParameters: runtime.HTTPHeaders = {}; const response = await this.request({ - path: `/store/order/{orderId}`.replace(`{${"orderId"}}`, encodeURIComponent(String(requestParameters.orderId))), + path: `/store/order/{orderId}`.replace(`{${"orderId"}}`, encodeURIComponent(String(requestParameters['orderId']))), method: 'DELETE', headers: headerParameters, query: queryParameters, @@ -178,8 +181,11 @@ export class StoreApi extends runtime.BaseAPI implements StoreApiInterface { * Find purchase order by ID */ async getOrderByIdRaw(requestParameters: GetOrderByIdRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.orderId === null || requestParameters.orderId === undefined) { - throw new runtime.RequiredError('orderId','Required parameter requestParameters.orderId was null or undefined when calling getOrderById.'); + if (!runtime.exists(requestParameters, 'orderId')) { + throw new runtime.RequiredError( + 'orderId', + 'Required parameter "orderId" was null or undefined when calling getOrderById().' + ); } const queryParameters: any = {}; @@ -187,7 +193,7 @@ export class StoreApi extends runtime.BaseAPI implements StoreApiInterface { const headerParameters: runtime.HTTPHeaders = {}; const response = await this.request({ - path: `/store/order/{orderId}`.replace(`{${"orderId"}}`, encodeURIComponent(String(requestParameters.orderId))), + path: `/store/order/{orderId}`.replace(`{${"orderId"}}`, encodeURIComponent(String(requestParameters['orderId']))), method: 'GET', headers: headerParameters, query: queryParameters, @@ -209,8 +215,11 @@ export class StoreApi extends runtime.BaseAPI implements StoreApiInterface { * Place an order for a pet */ async placeOrderRaw(requestParameters: PlaceOrderRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.body === null || requestParameters.body === undefined) { - throw new runtime.RequiredError('body','Required parameter requestParameters.body was null or undefined when calling placeOrder.'); + if (!runtime.exists(requestParameters, 'body')) { + throw new runtime.RequiredError( + 'body', + 'Required parameter "body" was null or undefined when calling placeOrder().' + ); } const queryParameters: any = {}; @@ -224,7 +233,7 @@ export class StoreApi extends runtime.BaseAPI implements StoreApiInterface { method: 'POST', headers: headerParameters, query: queryParameters, - body: OrderToJSON(requestParameters.body), + body: OrderToJSON(requestParameters['body']), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => OrderFromJSON(jsonValue)); diff --git a/samples/client/petstore/typescript-fetch/builds/with-interfaces/apis/UserApi.ts b/samples/client/petstore/typescript-fetch/builds/with-interfaces/apis/UserApi.ts index a55ab1d48f5c..fcd1170d4fa8 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-interfaces/apis/UserApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-interfaces/apis/UserApi.ts @@ -195,8 +195,11 @@ export class UserApi extends runtime.BaseAPI implements UserApiInterface { * Create user */ async createUserRaw(requestParameters: CreateUserRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.body === null || requestParameters.body === undefined) { - throw new runtime.RequiredError('body','Required parameter requestParameters.body was null or undefined when calling createUser.'); + if (!runtime.exists(requestParameters, 'body')) { + throw new runtime.RequiredError( + 'body', + 'Required parameter "body" was null or undefined when calling createUser().' + ); } const queryParameters: any = {}; @@ -210,7 +213,7 @@ export class UserApi extends runtime.BaseAPI implements UserApiInterface { method: 'POST', headers: headerParameters, query: queryParameters, - body: UserToJSON(requestParameters.body), + body: UserToJSON(requestParameters['body']), }, initOverrides); return new runtime.VoidApiResponse(response); @@ -228,8 +231,11 @@ export class UserApi extends runtime.BaseAPI implements UserApiInterface { * Creates list of users with given input array */ async createUsersWithArrayInputRaw(requestParameters: CreateUsersWithArrayInputRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.body === null || requestParameters.body === undefined) { - throw new runtime.RequiredError('body','Required parameter requestParameters.body was null or undefined when calling createUsersWithArrayInput.'); + if (!runtime.exists(requestParameters, 'body')) { + throw new runtime.RequiredError( + 'body', + 'Required parameter "body" was null or undefined when calling createUsersWithArrayInput().' + ); } const queryParameters: any = {}; @@ -243,7 +249,7 @@ export class UserApi extends runtime.BaseAPI implements UserApiInterface { method: 'POST', headers: headerParameters, query: queryParameters, - body: requestParameters.body.map(UserToJSON), + body: requestParameters['body']!.map(UserToJSON), }, initOverrides); return new runtime.VoidApiResponse(response); @@ -260,8 +266,11 @@ export class UserApi extends runtime.BaseAPI implements UserApiInterface { * Creates list of users with given input array */ async createUsersWithListInputRaw(requestParameters: CreateUsersWithListInputRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.body === null || requestParameters.body === undefined) { - throw new runtime.RequiredError('body','Required parameter requestParameters.body was null or undefined when calling createUsersWithListInput.'); + if (!runtime.exists(requestParameters, 'body')) { + throw new runtime.RequiredError( + 'body', + 'Required parameter "body" was null or undefined when calling createUsersWithListInput().' + ); } const queryParameters: any = {}; @@ -275,7 +284,7 @@ export class UserApi extends runtime.BaseAPI implements UserApiInterface { method: 'POST', headers: headerParameters, query: queryParameters, - body: requestParameters.body.map(UserToJSON), + body: requestParameters['body']!.map(UserToJSON), }, initOverrides); return new runtime.VoidApiResponse(response); @@ -293,8 +302,11 @@ export class UserApi extends runtime.BaseAPI implements UserApiInterface { * Delete user */ async deleteUserRaw(requestParameters: DeleteUserRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.username === null || requestParameters.username === undefined) { - throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling deleteUser.'); + if (!runtime.exists(requestParameters, 'username')) { + throw new runtime.RequiredError( + 'username', + 'Required parameter "username" was null or undefined when calling deleteUser().' + ); } const queryParameters: any = {}; @@ -302,7 +314,7 @@ export class UserApi extends runtime.BaseAPI implements UserApiInterface { const headerParameters: runtime.HTTPHeaders = {}; const response = await this.request({ - path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), + path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters['username']))), method: 'DELETE', headers: headerParameters, query: queryParameters, @@ -323,8 +335,11 @@ export class UserApi extends runtime.BaseAPI implements UserApiInterface { * Get user by user name */ async getUserByNameRaw(requestParameters: GetUserByNameRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.username === null || requestParameters.username === undefined) { - throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling getUserByName.'); + if (!runtime.exists(requestParameters, 'username')) { + throw new runtime.RequiredError( + 'username', + 'Required parameter "username" was null or undefined when calling getUserByName().' + ); } const queryParameters: any = {}; @@ -332,7 +347,7 @@ export class UserApi extends runtime.BaseAPI implements UserApiInterface { const headerParameters: runtime.HTTPHeaders = {}; const response = await this.request({ - path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), + path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters['username']))), method: 'GET', headers: headerParameters, query: queryParameters, @@ -353,22 +368,28 @@ export class UserApi extends runtime.BaseAPI implements UserApiInterface { * Logs user into the system */ async loginUserRaw(requestParameters: LoginUserRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.username === null || requestParameters.username === undefined) { - throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling loginUser.'); + if (!runtime.exists(requestParameters, 'username')) { + throw new runtime.RequiredError( + 'username', + 'Required parameter "username" was null or undefined when calling loginUser().' + ); } - if (requestParameters.password === null || requestParameters.password === undefined) { - throw new runtime.RequiredError('password','Required parameter requestParameters.password was null or undefined when calling loginUser.'); + if (!runtime.exists(requestParameters, 'password')) { + throw new runtime.RequiredError( + 'password', + 'Required parameter "password" was null or undefined when calling loginUser().' + ); } const queryParameters: any = {}; - if (requestParameters.username !== undefined) { - queryParameters['username'] = requestParameters.username; + if (runtime.exists(requestParameters, 'username')) { + queryParameters['username'] = requestParameters['username']; } - if (requestParameters.password !== undefined) { - queryParameters['password'] = requestParameters.password; + if (runtime.exists(requestParameters, 'password')) { + queryParameters['password'] = requestParameters['password']; } const headerParameters: runtime.HTTPHeaders = {}; @@ -425,12 +446,18 @@ export class UserApi extends runtime.BaseAPI implements UserApiInterface { * Updated user */ async updateUserRaw(requestParameters: UpdateUserRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.username === null || requestParameters.username === undefined) { - throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling updateUser.'); + if (!runtime.exists(requestParameters, 'username')) { + throw new runtime.RequiredError( + 'username', + 'Required parameter "username" was null or undefined when calling updateUser().' + ); } - if (requestParameters.body === null || requestParameters.body === undefined) { - throw new runtime.RequiredError('body','Required parameter requestParameters.body was null or undefined when calling updateUser.'); + if (!runtime.exists(requestParameters, 'body')) { + throw new runtime.RequiredError( + 'body', + 'Required parameter "body" was null or undefined when calling updateUser().' + ); } const queryParameters: any = {}; @@ -440,11 +467,11 @@ export class UserApi extends runtime.BaseAPI implements UserApiInterface { headerParameters['Content-Type'] = 'application/json'; const response = await this.request({ - path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), + path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters['username']))), method: 'PUT', headers: headerParameters, query: queryParameters, - body: UserToJSON(requestParameters.body), + body: UserToJSON(requestParameters['body']), }, initOverrides); return new runtime.VoidApiResponse(response); diff --git a/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Category.ts b/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Category.ts index 882567387201..001bc135bb96 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Category.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Category.ts @@ -37,9 +37,7 @@ export interface Category { * Check if a given object implements the Category interface. */ export function instanceOfCategory(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function CategoryFromJSON(json: any): Category { @@ -47,7 +45,7 @@ export function CategoryFromJSON(json: any): Category { } export function CategoryFromJSONTyped(json: any, ignoreDiscriminator: boolean): Category { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -66,8 +64,8 @@ export function CategoryToJSON(value?: Category | null): any { } return { - 'id': value.id, - 'name': value.name, + 'id': value['id'], + 'name': value['name'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/ModelApiResponse.ts b/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/ModelApiResponse.ts index bf50981fc2e2..a7fc63d81f1b 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/ModelApiResponse.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/ModelApiResponse.ts @@ -43,9 +43,7 @@ export interface ModelApiResponse { * Check if a given object implements the ModelApiResponse interface. */ export function instanceOfModelApiResponse(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function ModelApiResponseFromJSON(json: any): ModelApiResponse { @@ -53,7 +51,7 @@ export function ModelApiResponseFromJSON(json: any): ModelApiResponse { } export function ModelApiResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): ModelApiResponse { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -73,9 +71,9 @@ export function ModelApiResponseToJSON(value?: ModelApiResponse | null): any { } return { - 'code': value.code, - 'type': value.type, - 'message': value.message, + 'code': value['code'], + 'type': value['type'], + 'message': value['message'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Order.ts b/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Order.ts index 0d69755d4887..9e12fc242793 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Order.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Order.ts @@ -73,9 +73,7 @@ export type OrderStatusEnum = typeof OrderStatusEnum[keyof typeof OrderStatusEnu * Check if a given object implements the Order interface. */ export function instanceOfOrder(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function OrderFromJSON(json: any): Order { @@ -83,7 +81,7 @@ export function OrderFromJSON(json: any): Order { } export function OrderFromJSONTyped(json: any, ignoreDiscriminator: boolean): Order { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -106,12 +104,12 @@ export function OrderToJSON(value?: Order | null): any { } return { - 'id': value.id, - 'petId': value.petId, - 'quantity': value.quantity, - 'shipDate': value.shipDate === undefined ? undefined : (value.shipDate.toISOString()), - 'status': value.status, - 'complete': value.complete, + 'id': value['id'], + 'petId': value['petId'], + 'quantity': value['quantity'], + 'shipDate': !exists(value, 'shipDate') ? undefined : ((value['shipDate']).toISOString()), + 'status': value['status'], + 'complete': value['complete'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Pet.ts b/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Pet.ts index 73c70f03a3e5..8906602f6f4b 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Pet.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Pet.ts @@ -86,11 +86,9 @@ export type PetStatusEnum = typeof PetStatusEnum[keyof typeof PetStatusEnum]; * Check if a given object implements the Pet interface. */ export function instanceOfPet(value: object): boolean { - let isInstance = true; - isInstance = isInstance && "name" in value; - isInstance = isInstance && "photoUrls" in value; - - return isInstance; + if (!('name' in value)) return false; + if (!('photoUrls' in value)) return false; + return true; } export function PetFromJSON(json: any): Pet { @@ -98,7 +96,7 @@ export function PetFromJSON(json: any): Pet { } export function PetFromJSONTyped(json: any, ignoreDiscriminator: boolean): Pet { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -121,12 +119,12 @@ export function PetToJSON(value?: Pet | null): any { } return { - 'id': value.id, - 'category': CategoryToJSON(value.category), - 'name': value.name, - 'photoUrls': value.photoUrls, - 'tags': value.tags === undefined ? undefined : ((value.tags as Array).map(TagToJSON)), - 'status': value.status, + 'id': value['id'], + 'category': CategoryToJSON(value['category']), + 'name': value['name'], + 'photoUrls': value['photoUrls'], + 'tags': !exists(value, 'tags') ? undefined : ((value['tags'] as Array).map(TagToJSON)), + 'status': value['status'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Tag.ts b/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Tag.ts index e4902aa53cfd..24a25f383dba 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Tag.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/Tag.ts @@ -37,9 +37,7 @@ export interface Tag { * Check if a given object implements the Tag interface. */ export function instanceOfTag(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function TagFromJSON(json: any): Tag { @@ -47,7 +45,7 @@ export function TagFromJSON(json: any): Tag { } export function TagFromJSONTyped(json: any, ignoreDiscriminator: boolean): Tag { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -66,8 +64,8 @@ export function TagToJSON(value?: Tag | null): any { } return { - 'id': value.id, - 'name': value.name, + 'id': value['id'], + 'name': value['name'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/User.ts b/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/User.ts index f22da928907c..00ab35b80563 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/User.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-interfaces/models/User.ts @@ -73,9 +73,7 @@ export interface User { * Check if a given object implements the User interface. */ export function instanceOfUser(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function UserFromJSON(json: any): User { @@ -83,7 +81,7 @@ export function UserFromJSON(json: any): User { } export function UserFromJSONTyped(json: any, ignoreDiscriminator: boolean): User { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -108,14 +106,14 @@ export function UserToJSON(value?: User | null): any { } return { - 'id': value.id, - 'username': value.username, - 'firstName': value.firstName, - 'lastName': value.lastName, - 'email': value.email, - 'password': value.password, - 'phone': value.phone, - 'userStatus': value.userStatus, + 'id': value['id'], + 'username': value['username'], + 'firstName': value['firstName'], + 'lastName': value['lastName'], + 'email': value['email'], + 'password': value['password'], + 'phone': value['phone'], + 'userStatus': value['userStatus'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/with-interfaces/runtime.ts b/samples/client/petstore/typescript-fetch/builds/with-interfaces/runtime.ts index 71ecdb875d14..813bf0fb4dfe 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-interfaces/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-interfaces/runtime.ts @@ -310,9 +310,9 @@ export interface RequestOpts { body?: HTTPBody; } -export function exists(json: any, key: string) { +export function exists(json: any, key: string): boolean { const value = json[key]; - return value !== null && value !== undefined; + return value !== undefined && value !== null; } export function querystring(params: HTTPQuery, prefix: string = ''): string { diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/src/apis/PetApi.ts b/samples/client/petstore/typescript-fetch/builds/with-npm-version/src/apis/PetApi.ts index 5f507bceb566..87cab8f993a2 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-npm-version/src/apis/PetApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/src/apis/PetApi.ts @@ -71,8 +71,11 @@ export class PetApi extends runtime.BaseAPI { * Add a new pet to the store */ async addPetRaw(requestParameters: AddPetRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.body === null || requestParameters.body === undefined) { - throw new runtime.RequiredError('body','Required parameter requestParameters.body was null or undefined when calling addPet.'); + if (!runtime.exists(requestParameters, 'body')) { + throw new runtime.RequiredError( + 'body', + 'Required parameter "body" was null or undefined when calling addPet().' + ); } const queryParameters: any = {}; @@ -91,7 +94,7 @@ export class PetApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, - body: PetToJSON(requestParameters.body), + body: PetToJSON(requestParameters['body']), }, initOverrides); return new runtime.VoidApiResponse(response); @@ -108,16 +111,19 @@ export class PetApi extends runtime.BaseAPI { * Deletes a pet */ async deletePetRaw(requestParameters: DeletePetRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.petId === null || requestParameters.petId === undefined) { - throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling deletePet.'); + if (!runtime.exists(requestParameters, 'petId')) { + throw new runtime.RequiredError( + 'petId', + 'Required parameter "petId" was null or undefined when calling deletePet().' + ); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; - if (requestParameters.apiKey !== undefined && requestParameters.apiKey !== null) { - headerParameters['api_key'] = String(requestParameters.apiKey); + if (runtime.exists(requestParameters, 'apiKey')) { + headerParameters['api_key'] = String(requestParameters['apiKey']); } if (this.configuration && this.configuration.accessToken) { @@ -126,7 +132,7 @@ export class PetApi extends runtime.BaseAPI { } const response = await this.request({ - path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), + path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters['petId']))), method: 'DELETE', headers: headerParameters, query: queryParameters, @@ -147,14 +153,17 @@ export class PetApi extends runtime.BaseAPI { * Finds Pets by status */ async findPetsByStatusRaw(requestParameters: FindPetsByStatusRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>> { - if (requestParameters.status === null || requestParameters.status === undefined) { - throw new runtime.RequiredError('status','Required parameter requestParameters.status was null or undefined when calling findPetsByStatus.'); + if (!runtime.exists(requestParameters, 'status')) { + throw new runtime.RequiredError( + 'status', + 'Required parameter "status" was null or undefined when calling findPetsByStatus().' + ); } const queryParameters: any = {}; - if (requestParameters.status) { - queryParameters['status'] = requestParameters.status.join(runtime.COLLECTION_FORMATS["csv"]); + if (runtime.exists(requestParameters, 'status')) { + queryParameters['status'] = requestParameters['status']!.join(runtime.COLLECTION_FORMATS["csv"]); } const headerParameters: runtime.HTTPHeaders = {}; @@ -189,14 +198,17 @@ export class PetApi extends runtime.BaseAPI { * @deprecated */ async findPetsByTagsRaw(requestParameters: FindPetsByTagsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>> { - if (requestParameters.tags === null || requestParameters.tags === undefined) { - throw new runtime.RequiredError('tags','Required parameter requestParameters.tags was null or undefined when calling findPetsByTags.'); + if (!runtime.exists(requestParameters, 'tags')) { + throw new runtime.RequiredError( + 'tags', + 'Required parameter "tags" was null or undefined when calling findPetsByTags().' + ); } const queryParameters: any = {}; - if (requestParameters.tags) { - queryParameters['tags'] = requestParameters.tags.join(runtime.COLLECTION_FORMATS["csv"]); + if (runtime.exists(requestParameters, 'tags')) { + queryParameters['tags'] = requestParameters['tags']!.join(runtime.COLLECTION_FORMATS["csv"]); } const headerParameters: runtime.HTTPHeaders = {}; @@ -231,8 +243,11 @@ export class PetApi extends runtime.BaseAPI { * Find pet by ID */ async getPetByIdRaw(requestParameters: GetPetByIdRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.petId === null || requestParameters.petId === undefined) { - throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling getPetById.'); + if (!runtime.exists(requestParameters, 'petId')) { + throw new runtime.RequiredError( + 'petId', + 'Required parameter "petId" was null or undefined when calling getPetById().' + ); } const queryParameters: any = {}; @@ -244,7 +259,7 @@ export class PetApi extends runtime.BaseAPI { } const response = await this.request({ - path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), + path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters['petId']))), method: 'GET', headers: headerParameters, query: queryParameters, @@ -266,8 +281,11 @@ export class PetApi extends runtime.BaseAPI { * Update an existing pet */ async updatePetRaw(requestParameters: UpdatePetRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.body === null || requestParameters.body === undefined) { - throw new runtime.RequiredError('body','Required parameter requestParameters.body was null or undefined when calling updatePet.'); + if (!runtime.exists(requestParameters, 'body')) { + throw new runtime.RequiredError( + 'body', + 'Required parameter "body" was null or undefined when calling updatePet().' + ); } const queryParameters: any = {}; @@ -286,7 +304,7 @@ export class PetApi extends runtime.BaseAPI { method: 'PUT', headers: headerParameters, query: queryParameters, - body: PetToJSON(requestParameters.body), + body: PetToJSON(requestParameters['body']), }, initOverrides); return new runtime.VoidApiResponse(response); @@ -303,8 +321,11 @@ export class PetApi extends runtime.BaseAPI { * Updates a pet in the store with form data */ async updatePetWithFormRaw(requestParameters: UpdatePetWithFormRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.petId === null || requestParameters.petId === undefined) { - throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling updatePetWithForm.'); + if (!runtime.exists(requestParameters, 'petId')) { + throw new runtime.RequiredError( + 'petId', + 'Required parameter "petId" was null or undefined when calling updatePetWithForm().' + ); } const queryParameters: any = {}; @@ -330,16 +351,16 @@ export class PetApi extends runtime.BaseAPI { formParams = new URLSearchParams(); } - if (requestParameters.name !== undefined) { - formParams.append('name', requestParameters.name as any); + if (runtime.exists(requestParameters, 'name')) { + formParams.append('name', requestParameters['name'] as any); } - if (requestParameters.status !== undefined) { - formParams.append('status', requestParameters.status as any); + if (runtime.exists(requestParameters, 'status')) { + formParams.append('status', requestParameters['status'] as any); } const response = await this.request({ - path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), + path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters['petId']))), method: 'POST', headers: headerParameters, query: queryParameters, @@ -360,8 +381,11 @@ export class PetApi extends runtime.BaseAPI { * uploads an image */ async uploadFileRaw(requestParameters: UploadFileRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.petId === null || requestParameters.petId === undefined) { - throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling uploadFile.'); + if (!runtime.exists(requestParameters, 'petId')) { + throw new runtime.RequiredError( + 'petId', + 'Required parameter "petId" was null or undefined when calling uploadFile().' + ); } const queryParameters: any = {}; @@ -389,16 +413,16 @@ export class PetApi extends runtime.BaseAPI { formParams = new URLSearchParams(); } - if (requestParameters.additionalMetadata !== undefined) { - formParams.append('additionalMetadata', requestParameters.additionalMetadata as any); + if (runtime.exists(requestParameters, 'additionalMetadata')) { + formParams.append('additionalMetadata', requestParameters['additionalMetadata'] as any); } - if (requestParameters.file !== undefined) { - formParams.append('file', requestParameters.file as any); + if (runtime.exists(requestParameters, 'file')) { + formParams.append('file', requestParameters['file'] as any); } const response = await this.request({ - path: `/pet/{petId}/uploadImage`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), + path: `/pet/{petId}/uploadImage`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters['petId']))), method: 'POST', headers: headerParameters, query: queryParameters, diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/src/apis/StoreApi.ts b/samples/client/petstore/typescript-fetch/builds/with-npm-version/src/apis/StoreApi.ts index eda5a23e9a8f..74fc267af7da 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-npm-version/src/apis/StoreApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/src/apis/StoreApi.ts @@ -44,8 +44,11 @@ export class StoreApi extends runtime.BaseAPI { * Delete purchase order by ID */ async deleteOrderRaw(requestParameters: DeleteOrderRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.orderId === null || requestParameters.orderId === undefined) { - throw new runtime.RequiredError('orderId','Required parameter requestParameters.orderId was null or undefined when calling deleteOrder.'); + if (!runtime.exists(requestParameters, 'orderId')) { + throw new runtime.RequiredError( + 'orderId', + 'Required parameter "orderId" was null or undefined when calling deleteOrder().' + ); } const queryParameters: any = {}; @@ -53,7 +56,7 @@ export class StoreApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; const response = await this.request({ - path: `/store/order/{orderId}`.replace(`{${"orderId"}}`, encodeURIComponent(String(requestParameters.orderId))), + path: `/store/order/{orderId}`.replace(`{${"orderId"}}`, encodeURIComponent(String(requestParameters['orderId']))), method: 'DELETE', headers: headerParameters, query: queryParameters, @@ -107,8 +110,11 @@ export class StoreApi extends runtime.BaseAPI { * Find purchase order by ID */ async getOrderByIdRaw(requestParameters: GetOrderByIdRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.orderId === null || requestParameters.orderId === undefined) { - throw new runtime.RequiredError('orderId','Required parameter requestParameters.orderId was null or undefined when calling getOrderById.'); + if (!runtime.exists(requestParameters, 'orderId')) { + throw new runtime.RequiredError( + 'orderId', + 'Required parameter "orderId" was null or undefined when calling getOrderById().' + ); } const queryParameters: any = {}; @@ -116,7 +122,7 @@ export class StoreApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; const response = await this.request({ - path: `/store/order/{orderId}`.replace(`{${"orderId"}}`, encodeURIComponent(String(requestParameters.orderId))), + path: `/store/order/{orderId}`.replace(`{${"orderId"}}`, encodeURIComponent(String(requestParameters['orderId']))), method: 'GET', headers: headerParameters, query: queryParameters, @@ -138,8 +144,11 @@ export class StoreApi extends runtime.BaseAPI { * Place an order for a pet */ async placeOrderRaw(requestParameters: PlaceOrderRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.body === null || requestParameters.body === undefined) { - throw new runtime.RequiredError('body','Required parameter requestParameters.body was null or undefined when calling placeOrder.'); + if (!runtime.exists(requestParameters, 'body')) { + throw new runtime.RequiredError( + 'body', + 'Required parameter "body" was null or undefined when calling placeOrder().' + ); } const queryParameters: any = {}; @@ -153,7 +162,7 @@ export class StoreApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, - body: OrderToJSON(requestParameters.body), + body: OrderToJSON(requestParameters['body']), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => OrderFromJSON(jsonValue)); diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/src/apis/UserApi.ts b/samples/client/petstore/typescript-fetch/builds/with-npm-version/src/apis/UserApi.ts index 58f6a7e5d3af..565ceefcaab9 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-npm-version/src/apis/UserApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/src/apis/UserApi.ts @@ -62,8 +62,11 @@ export class UserApi extends runtime.BaseAPI { * Create user */ async createUserRaw(requestParameters: CreateUserRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.body === null || requestParameters.body === undefined) { - throw new runtime.RequiredError('body','Required parameter requestParameters.body was null or undefined when calling createUser.'); + if (!runtime.exists(requestParameters, 'body')) { + throw new runtime.RequiredError( + 'body', + 'Required parameter "body" was null or undefined when calling createUser().' + ); } const queryParameters: any = {}; @@ -77,7 +80,7 @@ export class UserApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, - body: UserToJSON(requestParameters.body), + body: UserToJSON(requestParameters['body']), }, initOverrides); return new runtime.VoidApiResponse(response); @@ -95,8 +98,11 @@ export class UserApi extends runtime.BaseAPI { * Creates list of users with given input array */ async createUsersWithArrayInputRaw(requestParameters: CreateUsersWithArrayInputRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.body === null || requestParameters.body === undefined) { - throw new runtime.RequiredError('body','Required parameter requestParameters.body was null or undefined when calling createUsersWithArrayInput.'); + if (!runtime.exists(requestParameters, 'body')) { + throw new runtime.RequiredError( + 'body', + 'Required parameter "body" was null or undefined when calling createUsersWithArrayInput().' + ); } const queryParameters: any = {}; @@ -110,7 +116,7 @@ export class UserApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, - body: requestParameters.body.map(UserToJSON), + body: requestParameters['body']!.map(UserToJSON), }, initOverrides); return new runtime.VoidApiResponse(response); @@ -127,8 +133,11 @@ export class UserApi extends runtime.BaseAPI { * Creates list of users with given input array */ async createUsersWithListInputRaw(requestParameters: CreateUsersWithListInputRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.body === null || requestParameters.body === undefined) { - throw new runtime.RequiredError('body','Required parameter requestParameters.body was null or undefined when calling createUsersWithListInput.'); + if (!runtime.exists(requestParameters, 'body')) { + throw new runtime.RequiredError( + 'body', + 'Required parameter "body" was null or undefined when calling createUsersWithListInput().' + ); } const queryParameters: any = {}; @@ -142,7 +151,7 @@ export class UserApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, - body: requestParameters.body.map(UserToJSON), + body: requestParameters['body']!.map(UserToJSON), }, initOverrides); return new runtime.VoidApiResponse(response); @@ -160,8 +169,11 @@ export class UserApi extends runtime.BaseAPI { * Delete user */ async deleteUserRaw(requestParameters: DeleteUserRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.username === null || requestParameters.username === undefined) { - throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling deleteUser.'); + if (!runtime.exists(requestParameters, 'username')) { + throw new runtime.RequiredError( + 'username', + 'Required parameter "username" was null or undefined when calling deleteUser().' + ); } const queryParameters: any = {}; @@ -169,7 +181,7 @@ export class UserApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; const response = await this.request({ - path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), + path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters['username']))), method: 'DELETE', headers: headerParameters, query: queryParameters, @@ -190,8 +202,11 @@ export class UserApi extends runtime.BaseAPI { * Get user by user name */ async getUserByNameRaw(requestParameters: GetUserByNameRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.username === null || requestParameters.username === undefined) { - throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling getUserByName.'); + if (!runtime.exists(requestParameters, 'username')) { + throw new runtime.RequiredError( + 'username', + 'Required parameter "username" was null or undefined when calling getUserByName().' + ); } const queryParameters: any = {}; @@ -199,7 +214,7 @@ export class UserApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; const response = await this.request({ - path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), + path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters['username']))), method: 'GET', headers: headerParameters, query: queryParameters, @@ -220,22 +235,28 @@ export class UserApi extends runtime.BaseAPI { * Logs user into the system */ async loginUserRaw(requestParameters: LoginUserRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.username === null || requestParameters.username === undefined) { - throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling loginUser.'); + if (!runtime.exists(requestParameters, 'username')) { + throw new runtime.RequiredError( + 'username', + 'Required parameter "username" was null or undefined when calling loginUser().' + ); } - if (requestParameters.password === null || requestParameters.password === undefined) { - throw new runtime.RequiredError('password','Required parameter requestParameters.password was null or undefined when calling loginUser.'); + if (!runtime.exists(requestParameters, 'password')) { + throw new runtime.RequiredError( + 'password', + 'Required parameter "password" was null or undefined when calling loginUser().' + ); } const queryParameters: any = {}; - if (requestParameters.username !== undefined) { - queryParameters['username'] = requestParameters.username; + if (runtime.exists(requestParameters, 'username')) { + queryParameters['username'] = requestParameters['username']; } - if (requestParameters.password !== undefined) { - queryParameters['password'] = requestParameters.password; + if (runtime.exists(requestParameters, 'password')) { + queryParameters['password'] = requestParameters['password']; } const headerParameters: runtime.HTTPHeaders = {}; @@ -292,12 +313,18 @@ export class UserApi extends runtime.BaseAPI { * Updated user */ async updateUserRaw(requestParameters: UpdateUserRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.username === null || requestParameters.username === undefined) { - throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling updateUser.'); + if (!runtime.exists(requestParameters, 'username')) { + throw new runtime.RequiredError( + 'username', + 'Required parameter "username" was null or undefined when calling updateUser().' + ); } - if (requestParameters.body === null || requestParameters.body === undefined) { - throw new runtime.RequiredError('body','Required parameter requestParameters.body was null or undefined when calling updateUser.'); + if (!runtime.exists(requestParameters, 'body')) { + throw new runtime.RequiredError( + 'body', + 'Required parameter "body" was null or undefined when calling updateUser().' + ); } const queryParameters: any = {}; @@ -307,11 +334,11 @@ export class UserApi extends runtime.BaseAPI { headerParameters['Content-Type'] = 'application/json'; const response = await this.request({ - path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), + path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters['username']))), method: 'PUT', headers: headerParameters, query: queryParameters, - body: UserToJSON(requestParameters.body), + body: UserToJSON(requestParameters['body']), }, initOverrides); return new runtime.VoidApiResponse(response); 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 882567387201..001bc135bb96 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 @@ -37,9 +37,7 @@ export interface Category { * Check if a given object implements the Category interface. */ export function instanceOfCategory(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function CategoryFromJSON(json: any): Category { @@ -47,7 +45,7 @@ export function CategoryFromJSON(json: any): Category { } export function CategoryFromJSONTyped(json: any, ignoreDiscriminator: boolean): Category { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -66,8 +64,8 @@ export function CategoryToJSON(value?: Category | null): any { } return { - 'id': value.id, - 'name': value.name, + '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 bf50981fc2e2..a7fc63d81f1b 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 @@ -43,9 +43,7 @@ export interface ModelApiResponse { * Check if a given object implements the ModelApiResponse interface. */ export function instanceOfModelApiResponse(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function ModelApiResponseFromJSON(json: any): ModelApiResponse { @@ -53,7 +51,7 @@ export function ModelApiResponseFromJSON(json: any): ModelApiResponse { } export function ModelApiResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): ModelApiResponse { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -73,9 +71,9 @@ export function ModelApiResponseToJSON(value?: ModelApiResponse | null): any { } return { - 'code': value.code, - 'type': value.type, - 'message': value.message, + '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 0d69755d4887..9e12fc242793 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 @@ -73,9 +73,7 @@ export type OrderStatusEnum = typeof OrderStatusEnum[keyof typeof OrderStatusEnu * Check if a given object implements the Order interface. */ export function instanceOfOrder(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function OrderFromJSON(json: any): Order { @@ -83,7 +81,7 @@ export function OrderFromJSON(json: any): Order { } export function OrderFromJSONTyped(json: any, ignoreDiscriminator: boolean): Order { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -106,12 +104,12 @@ export function OrderToJSON(value?: Order | null): any { } return { - 'id': value.id, - 'petId': value.petId, - 'quantity': value.quantity, - 'shipDate': value.shipDate === undefined ? undefined : (value.shipDate.toISOString()), - 'status': value.status, - 'complete': value.complete, + 'id': value['id'], + 'petId': value['petId'], + 'quantity': value['quantity'], + 'shipDate': !exists(value, 'shipDate') ? undefined : ((value['shipDate']).toISOString()), + 'status': value['status'], + 'complete': value['complete'], }; } 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 73c70f03a3e5..8906602f6f4b 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 @@ -86,11 +86,9 @@ export type PetStatusEnum = typeof PetStatusEnum[keyof typeof PetStatusEnum]; * Check if a given object implements the Pet interface. */ export function instanceOfPet(value: object): boolean { - let isInstance = true; - isInstance = isInstance && "name" in value; - isInstance = isInstance && "photoUrls" in value; - - return isInstance; + if (!('name' in value)) return false; + if (!('photoUrls' in value)) return false; + return true; } export function PetFromJSON(json: any): Pet { @@ -98,7 +96,7 @@ export function PetFromJSON(json: any): Pet { } export function PetFromJSONTyped(json: any, ignoreDiscriminator: boolean): Pet { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -121,12 +119,12 @@ export function PetToJSON(value?: Pet | null): any { } return { - 'id': value.id, - 'category': CategoryToJSON(value.category), - 'name': value.name, - 'photoUrls': value.photoUrls, - 'tags': value.tags === undefined ? undefined : ((value.tags as Array).map(TagToJSON)), - 'status': value.status, + 'id': value['id'], + 'category': CategoryToJSON(value['category']), + 'name': value['name'], + 'photoUrls': value['photoUrls'], + 'tags': !exists(value, 'tags') ? undefined : ((value['tags'] as Array).map(TagToJSON)), + 'status': value['status'], }; } 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 e4902aa53cfd..24a25f383dba 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 @@ -37,9 +37,7 @@ export interface Tag { * Check if a given object implements the Tag interface. */ export function instanceOfTag(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function TagFromJSON(json: any): Tag { @@ -47,7 +45,7 @@ export function TagFromJSON(json: any): Tag { } export function TagFromJSONTyped(json: any, ignoreDiscriminator: boolean): Tag { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -66,8 +64,8 @@ export function TagToJSON(value?: Tag | null): any { } return { - 'id': value.id, - 'name': value.name, + '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 f22da928907c..00ab35b80563 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 @@ -73,9 +73,7 @@ export interface User { * Check if a given object implements the User interface. */ export function instanceOfUser(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function UserFromJSON(json: any): User { @@ -83,7 +81,7 @@ export function UserFromJSON(json: any): User { } export function UserFromJSONTyped(json: any, ignoreDiscriminator: boolean): User { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -108,14 +106,14 @@ export function UserToJSON(value?: User | null): any { } return { - 'id': value.id, - 'username': value.username, - 'firstName': value.firstName, - 'lastName': value.lastName, - 'email': value.email, - 'password': value.password, - 'phone': value.phone, - 'userStatus': value.userStatus, + 'id': value['id'], + 'username': value['username'], + 'firstName': value['firstName'], + 'lastName': value['lastName'], + 'email': value['email'], + 'password': value['password'], + 'phone': value['phone'], + 'userStatus': value['userStatus'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/src/runtime.ts b/samples/client/petstore/typescript-fetch/builds/with-npm-version/src/runtime.ts index 71ecdb875d14..813bf0fb4dfe 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-npm-version/src/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/src/runtime.ts @@ -310,9 +310,9 @@ export interface RequestOpts { body?: HTTPBody; } -export function exists(json: any, key: string) { +export function exists(json: any, key: string): boolean { const value = json[key]; - return value !== null && value !== undefined; + return value !== undefined && value !== null; } export function querystring(params: HTTPQuery, prefix: string = ''): string { diff --git a/samples/client/petstore/typescript-fetch/builds/with-string-enums/apis/DefaultApi.ts b/samples/client/petstore/typescript-fetch/builds/with-string-enums/apis/DefaultApi.ts index 09bc772a5856..8cefb3e075cd 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-string-enums/apis/DefaultApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-string-enums/apis/DefaultApi.ts @@ -40,9 +40,9 @@ export interface FakeEnumRequestGetInlineRequest { export interface FakeEnumRequestGetRefRequest { stringEnum?: StringEnum; - nullableStringEnum?: StringEnum | null; + nullableStringEnum?: StringEnum; numberEnum?: NumberEnum; - nullableNumberEnum?: NumberEnum | null; + nullableNumberEnum?: NumberEnum; } export interface FakeEnumRequestPostInlineRequest { @@ -63,20 +63,20 @@ export class DefaultApi extends runtime.BaseAPI { async fakeEnumRequestGetInlineRaw(requestParameters: FakeEnumRequestGetInlineRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { const queryParameters: any = {}; - if (requestParameters.stringEnum !== undefined) { - queryParameters['string-enum'] = requestParameters.stringEnum; + if (runtime.exists(requestParameters, 'stringEnum')) { + queryParameters['string-enum'] = requestParameters['stringEnum']; } - if (requestParameters.nullableStringEnum !== undefined) { - queryParameters['nullable-string-enum'] = requestParameters.nullableStringEnum; + if (runtime.exists(requestParameters, 'nullableStringEnum')) { + queryParameters['nullable-string-enum'] = requestParameters['nullableStringEnum']; } - if (requestParameters.numberEnum !== undefined) { - queryParameters['number-enum'] = requestParameters.numberEnum; + if (runtime.exists(requestParameters, 'numberEnum')) { + queryParameters['number-enum'] = requestParameters['numberEnum']; } - if (requestParameters.nullableNumberEnum !== undefined) { - queryParameters['nullable-number-enum'] = requestParameters.nullableNumberEnum; + if (runtime.exists(requestParameters, 'nullableNumberEnum')) { + queryParameters['nullable-number-enum'] = requestParameters['nullableNumberEnum']; } const headerParameters: runtime.HTTPHeaders = {}; @@ -103,20 +103,20 @@ export class DefaultApi extends runtime.BaseAPI { async fakeEnumRequestGetRefRaw(requestParameters: FakeEnumRequestGetRefRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { const queryParameters: any = {}; - if (requestParameters.stringEnum !== undefined) { - queryParameters['string-enum'] = requestParameters.stringEnum; + if (runtime.exists(requestParameters, 'stringEnum')) { + queryParameters['string-enum'] = requestParameters['stringEnum']; } - if (requestParameters.nullableStringEnum !== undefined) { - queryParameters['nullable-string-enum'] = requestParameters.nullableStringEnum; + if (runtime.exists(requestParameters, 'nullableStringEnum')) { + queryParameters['nullable-string-enum'] = requestParameters['nullableStringEnum']; } - if (requestParameters.numberEnum !== undefined) { - queryParameters['number-enum'] = requestParameters.numberEnum; + if (runtime.exists(requestParameters, 'numberEnum')) { + queryParameters['number-enum'] = requestParameters['numberEnum']; } - if (requestParameters.nullableNumberEnum !== undefined) { - queryParameters['nullable-number-enum'] = requestParameters.nullableNumberEnum; + if (runtime.exists(requestParameters, 'nullableNumberEnum')) { + queryParameters['nullable-number-enum'] = requestParameters['nullableNumberEnum']; } const headerParameters: runtime.HTTPHeaders = {}; @@ -152,7 +152,7 @@ export class DefaultApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, - body: FakeEnumRequestGetInline200ResponseToJSON(requestParameters.fakeEnumRequestGetInline200Response), + body: FakeEnumRequestGetInline200ResponseToJSON(requestParameters['fakeEnumRequestGetInline200Response']), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => FakeEnumRequestGetInline200ResponseFromJSON(jsonValue)); @@ -179,7 +179,7 @@ export class DefaultApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, - body: EnumPatternObjectToJSON(requestParameters.enumPatternObject), + body: EnumPatternObjectToJSON(requestParameters['enumPatternObject']), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => EnumPatternObjectFromJSON(jsonValue)); diff --git a/samples/client/petstore/typescript-fetch/builds/with-string-enums/models/EnumPatternObject.ts b/samples/client/petstore/typescript-fetch/builds/with-string-enums/models/EnumPatternObject.ts index ebee6ba47f7d..38d190ba0f39 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-string-enums/models/EnumPatternObject.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-string-enums/models/EnumPatternObject.ts @@ -43,7 +43,7 @@ export interface EnumPatternObject { * @type {StringEnum} * @memberof EnumPatternObject */ - nullableStringEnum?: StringEnum | null; + nullableStringEnum?: StringEnum; /** * * @type {NumberEnum} @@ -55,16 +55,14 @@ export interface EnumPatternObject { * @type {NumberEnum} * @memberof EnumPatternObject */ - nullableNumberEnum?: NumberEnum | null; + nullableNumberEnum?: NumberEnum; } /** * Check if a given object implements the EnumPatternObject interface. */ export function instanceOfEnumPatternObject(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function EnumPatternObjectFromJSON(json: any): EnumPatternObject { @@ -72,7 +70,7 @@ export function EnumPatternObjectFromJSON(json: any): EnumPatternObject { } export function EnumPatternObjectFromJSONTyped(json: any, ignoreDiscriminator: boolean): EnumPatternObject { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -93,10 +91,10 @@ export function EnumPatternObjectToJSON(value?: EnumPatternObject | null): any { } return { - 'string-enum': StringEnumToJSON(value.stringEnum), - 'nullable-string-enum': StringEnumToJSON(value.nullableStringEnum), - 'number-enum': NumberEnumToJSON(value.numberEnum), - 'nullable-number-enum': NumberEnumToJSON(value.nullableNumberEnum), + 'string-enum': StringEnumToJSON(value['stringEnum']), + 'nullable-string-enum': StringEnumToJSON(value['nullableStringEnum']), + 'number-enum': NumberEnumToJSON(value['numberEnum']), + 'nullable-number-enum': NumberEnumToJSON(value['nullableNumberEnum']), }; } diff --git a/samples/client/petstore/typescript-fetch/builds/with-string-enums/models/FakeEnumRequestGetInline200Response.ts b/samples/client/petstore/typescript-fetch/builds/with-string-enums/models/FakeEnumRequestGetInline200Response.ts index 103f45f57d94..cdacb3338c5c 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-string-enums/models/FakeEnumRequestGetInline200Response.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-string-enums/models/FakeEnumRequestGetInline200Response.ts @@ -87,9 +87,7 @@ export enum FakeEnumRequestGetInline200ResponseNullableNumberEnumEnum { * Check if a given object implements the FakeEnumRequestGetInline200Response interface. */ export function instanceOfFakeEnumRequestGetInline200Response(value: object): boolean { - let isInstance = true; - - return isInstance; + return true; } export function FakeEnumRequestGetInline200ResponseFromJSON(json: any): FakeEnumRequestGetInline200Response { @@ -97,7 +95,7 @@ export function FakeEnumRequestGetInline200ResponseFromJSON(json: any): FakeEnum } export function FakeEnumRequestGetInline200ResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): FakeEnumRequestGetInline200Response { - if ((json === undefined) || (json === null)) { + if (json === undefined || json === null) { return json; } return { @@ -118,10 +116,10 @@ export function FakeEnumRequestGetInline200ResponseToJSON(value?: FakeEnumReques } return { - 'string-enum': value.stringEnum, - 'nullable-string-enum': value.nullableStringEnum, - 'number-enum': value.numberEnum, - 'nullable-number-enum': value.nullableNumberEnum, + 'string-enum': value['stringEnum'], + 'nullable-string-enum': value['nullableStringEnum'], + 'number-enum': value['numberEnum'], + 'nullable-number-enum': value['nullableNumberEnum'], }; } diff --git a/samples/client/petstore/typescript-fetch/builds/with-string-enums/runtime.ts b/samples/client/petstore/typescript-fetch/builds/with-string-enums/runtime.ts index cef607c3fcb5..4f1da922f6df 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-string-enums/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-string-enums/runtime.ts @@ -310,9 +310,9 @@ export interface RequestOpts { body?: HTTPBody; } -export function exists(json: any, key: string) { +export function exists(json: any, key: string): boolean { const value = json[key]; - return value !== null && value !== undefined; + return value !== undefined && value !== null; } export function querystring(params: HTTPQuery, prefix: string = ''): string { diff --git a/samples/client/petstore/typescript-fetch/builds/without-runtime-checks/src/apis/PetApi.ts b/samples/client/petstore/typescript-fetch/builds/without-runtime-checks/src/apis/PetApi.ts index 0aaabe7652a3..8bef5a9c322c 100644 --- a/samples/client/petstore/typescript-fetch/builds/without-runtime-checks/src/apis/PetApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/without-runtime-checks/src/apis/PetApi.ts @@ -65,8 +65,11 @@ export class PetApi extends runtime.BaseAPI { * Add a new pet to the store */ async addPetRaw(requestParameters: AddPetRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.body === null || requestParameters.body === undefined) { - throw new runtime.RequiredError('body','Required parameter requestParameters.body was null or undefined when calling addPet.'); + if (!runtime.exists(requestParameters, 'body')) { + throw new runtime.RequiredError( + 'body', + 'Required parameter "body" was null or undefined when calling addPet().' + ); } const queryParameters: any = {}; @@ -85,7 +88,7 @@ export class PetApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, - body: requestParameters.body, + body: requestParameters['body'], }, initOverrides); return new runtime.VoidApiResponse(response); @@ -102,16 +105,19 @@ export class PetApi extends runtime.BaseAPI { * Deletes a pet */ async deletePetRaw(requestParameters: DeletePetRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.petId === null || requestParameters.petId === undefined) { - throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling deletePet.'); + if (!runtime.exists(requestParameters, 'petId')) { + throw new runtime.RequiredError( + 'petId', + 'Required parameter "petId" was null or undefined when calling deletePet().' + ); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; - if (requestParameters.apiKey !== undefined && requestParameters.apiKey !== null) { - headerParameters['api_key'] = String(requestParameters.apiKey); + if (runtime.exists(requestParameters, 'apiKey')) { + headerParameters['api_key'] = String(requestParameters['apiKey']); } if (this.configuration && this.configuration.accessToken) { @@ -120,7 +126,7 @@ export class PetApi extends runtime.BaseAPI { } const response = await this.request({ - path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), + path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters['petId']))), method: 'DELETE', headers: headerParameters, query: queryParameters, @@ -141,14 +147,17 @@ export class PetApi extends runtime.BaseAPI { * Finds Pets by status */ async findPetsByStatusRaw(requestParameters: FindPetsByStatusRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>> { - if (requestParameters.status === null || requestParameters.status === undefined) { - throw new runtime.RequiredError('status','Required parameter requestParameters.status was null or undefined when calling findPetsByStatus.'); + if (!runtime.exists(requestParameters, 'status')) { + throw new runtime.RequiredError( + 'status', + 'Required parameter "status" was null or undefined when calling findPetsByStatus().' + ); } const queryParameters: any = {}; - if (requestParameters.status) { - queryParameters['status'] = requestParameters.status.join(runtime.COLLECTION_FORMATS["csv"]); + if (runtime.exists(requestParameters, 'status')) { + queryParameters['status'] = requestParameters['status']!.join(runtime.COLLECTION_FORMATS["csv"]); } const headerParameters: runtime.HTTPHeaders = {}; @@ -183,14 +192,17 @@ export class PetApi extends runtime.BaseAPI { * @deprecated */ async findPetsByTagsRaw(requestParameters: FindPetsByTagsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>> { - if (requestParameters.tags === null || requestParameters.tags === undefined) { - throw new runtime.RequiredError('tags','Required parameter requestParameters.tags was null or undefined when calling findPetsByTags.'); + if (!runtime.exists(requestParameters, 'tags')) { + throw new runtime.RequiredError( + 'tags', + 'Required parameter "tags" was null or undefined when calling findPetsByTags().' + ); } const queryParameters: any = {}; - if (requestParameters.tags) { - queryParameters['tags'] = requestParameters.tags.join(runtime.COLLECTION_FORMATS["csv"]); + if (runtime.exists(requestParameters, 'tags')) { + queryParameters['tags'] = requestParameters['tags']!.join(runtime.COLLECTION_FORMATS["csv"]); } const headerParameters: runtime.HTTPHeaders = {}; @@ -225,8 +237,11 @@ export class PetApi extends runtime.BaseAPI { * Find pet by ID */ async getPetByIdRaw(requestParameters: GetPetByIdRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.petId === null || requestParameters.petId === undefined) { - throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling getPetById.'); + if (!runtime.exists(requestParameters, 'petId')) { + throw new runtime.RequiredError( + 'petId', + 'Required parameter "petId" was null or undefined when calling getPetById().' + ); } const queryParameters: any = {}; @@ -238,7 +253,7 @@ export class PetApi extends runtime.BaseAPI { } const response = await this.request({ - path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), + path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters['petId']))), method: 'GET', headers: headerParameters, query: queryParameters, @@ -260,8 +275,11 @@ export class PetApi extends runtime.BaseAPI { * Update an existing pet */ async updatePetRaw(requestParameters: UpdatePetRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.body === null || requestParameters.body === undefined) { - throw new runtime.RequiredError('body','Required parameter requestParameters.body was null or undefined when calling updatePet.'); + if (!runtime.exists(requestParameters, 'body')) { + throw new runtime.RequiredError( + 'body', + 'Required parameter "body" was null or undefined when calling updatePet().' + ); } const queryParameters: any = {}; @@ -280,7 +298,7 @@ export class PetApi extends runtime.BaseAPI { method: 'PUT', headers: headerParameters, query: queryParameters, - body: requestParameters.body, + body: requestParameters['body'], }, initOverrides); return new runtime.VoidApiResponse(response); @@ -297,8 +315,11 @@ export class PetApi extends runtime.BaseAPI { * Updates a pet in the store with form data */ async updatePetWithFormRaw(requestParameters: UpdatePetWithFormRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.petId === null || requestParameters.petId === undefined) { - throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling updatePetWithForm.'); + if (!runtime.exists(requestParameters, 'petId')) { + throw new runtime.RequiredError( + 'petId', + 'Required parameter "petId" was null or undefined when calling updatePetWithForm().' + ); } const queryParameters: any = {}; @@ -324,16 +345,16 @@ export class PetApi extends runtime.BaseAPI { formParams = new URLSearchParams(); } - if (requestParameters.name !== undefined) { - formParams.append('name', requestParameters.name as any); + if (runtime.exists(requestParameters, 'name')) { + formParams.append('name', requestParameters['name'] as any); } - if (requestParameters.status !== undefined) { - formParams.append('status', requestParameters.status as any); + if (runtime.exists(requestParameters, 'status')) { + formParams.append('status', requestParameters['status'] as any); } const response = await this.request({ - path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), + path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters['petId']))), method: 'POST', headers: headerParameters, query: queryParameters, @@ -354,8 +375,11 @@ export class PetApi extends runtime.BaseAPI { * uploads an image */ async uploadFileRaw(requestParameters: UploadFileRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.petId === null || requestParameters.petId === undefined) { - throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling uploadFile.'); + if (!runtime.exists(requestParameters, 'petId')) { + throw new runtime.RequiredError( + 'petId', + 'Required parameter "petId" was null or undefined when calling uploadFile().' + ); } const queryParameters: any = {}; @@ -383,16 +407,16 @@ export class PetApi extends runtime.BaseAPI { formParams = new URLSearchParams(); } - if (requestParameters.additionalMetadata !== undefined) { - formParams.append('additionalMetadata', requestParameters.additionalMetadata as any); + if (runtime.exists(requestParameters, 'additionalMetadata')) { + formParams.append('additionalMetadata', requestParameters['additionalMetadata'] as any); } - if (requestParameters.file !== undefined) { - formParams.append('file', requestParameters.file as any); + if (runtime.exists(requestParameters, 'file')) { + formParams.append('file', requestParameters['file'] as any); } const response = await this.request({ - path: `/pet/{petId}/uploadImage`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), + path: `/pet/{petId}/uploadImage`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters['petId']))), method: 'POST', headers: headerParameters, query: queryParameters, diff --git a/samples/client/petstore/typescript-fetch/builds/without-runtime-checks/src/apis/StoreApi.ts b/samples/client/petstore/typescript-fetch/builds/without-runtime-checks/src/apis/StoreApi.ts index 1b6199a07148..e5443fc60605 100644 --- a/samples/client/petstore/typescript-fetch/builds/without-runtime-checks/src/apis/StoreApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/without-runtime-checks/src/apis/StoreApi.ts @@ -40,8 +40,11 @@ export class StoreApi extends runtime.BaseAPI { * Delete purchase order by ID */ async deleteOrderRaw(requestParameters: DeleteOrderRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.orderId === null || requestParameters.orderId === undefined) { - throw new runtime.RequiredError('orderId','Required parameter requestParameters.orderId was null or undefined when calling deleteOrder.'); + if (!runtime.exists(requestParameters, 'orderId')) { + throw new runtime.RequiredError( + 'orderId', + 'Required parameter "orderId" was null or undefined when calling deleteOrder().' + ); } const queryParameters: any = {}; @@ -49,7 +52,7 @@ export class StoreApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; const response = await this.request({ - path: `/store/order/{orderId}`.replace(`{${"orderId"}}`, encodeURIComponent(String(requestParameters.orderId))), + path: `/store/order/{orderId}`.replace(`{${"orderId"}}`, encodeURIComponent(String(requestParameters['orderId']))), method: 'DELETE', headers: headerParameters, query: queryParameters, @@ -103,8 +106,11 @@ export class StoreApi extends runtime.BaseAPI { * Find purchase order by ID */ async getOrderByIdRaw(requestParameters: GetOrderByIdRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.orderId === null || requestParameters.orderId === undefined) { - throw new runtime.RequiredError('orderId','Required parameter requestParameters.orderId was null or undefined when calling getOrderById.'); + if (!runtime.exists(requestParameters, 'orderId')) { + throw new runtime.RequiredError( + 'orderId', + 'Required parameter "orderId" was null or undefined when calling getOrderById().' + ); } const queryParameters: any = {}; @@ -112,7 +118,7 @@ export class StoreApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; const response = await this.request({ - path: `/store/order/{orderId}`.replace(`{${"orderId"}}`, encodeURIComponent(String(requestParameters.orderId))), + path: `/store/order/{orderId}`.replace(`{${"orderId"}}`, encodeURIComponent(String(requestParameters['orderId']))), method: 'GET', headers: headerParameters, query: queryParameters, @@ -134,8 +140,11 @@ export class StoreApi extends runtime.BaseAPI { * Place an order for a pet */ async placeOrderRaw(requestParameters: PlaceOrderRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.body === null || requestParameters.body === undefined) { - throw new runtime.RequiredError('body','Required parameter requestParameters.body was null or undefined when calling placeOrder.'); + if (!runtime.exists(requestParameters, 'body')) { + throw new runtime.RequiredError( + 'body', + 'Required parameter "body" was null or undefined when calling placeOrder().' + ); } const queryParameters: any = {}; @@ -149,7 +158,7 @@ export class StoreApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, - body: requestParameters.body, + body: requestParameters['body'], }, initOverrides); return new runtime.JSONApiResponse(response); diff --git a/samples/client/petstore/typescript-fetch/builds/without-runtime-checks/src/apis/UserApi.ts b/samples/client/petstore/typescript-fetch/builds/without-runtime-checks/src/apis/UserApi.ts index 08676b352e5d..42175e737dee 100644 --- a/samples/client/petstore/typescript-fetch/builds/without-runtime-checks/src/apis/UserApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/without-runtime-checks/src/apis/UserApi.ts @@ -58,8 +58,11 @@ export class UserApi extends runtime.BaseAPI { * Create user */ async createUserRaw(requestParameters: CreateUserRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.body === null || requestParameters.body === undefined) { - throw new runtime.RequiredError('body','Required parameter requestParameters.body was null or undefined when calling createUser.'); + if (!runtime.exists(requestParameters, 'body')) { + throw new runtime.RequiredError( + 'body', + 'Required parameter "body" was null or undefined when calling createUser().' + ); } const queryParameters: any = {}; @@ -73,7 +76,7 @@ export class UserApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, - body: requestParameters.body, + body: requestParameters['body'], }, initOverrides); return new runtime.VoidApiResponse(response); @@ -91,8 +94,11 @@ export class UserApi extends runtime.BaseAPI { * Creates list of users with given input array */ async createUsersWithArrayInputRaw(requestParameters: CreateUsersWithArrayInputRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.body === null || requestParameters.body === undefined) { - throw new runtime.RequiredError('body','Required parameter requestParameters.body was null or undefined when calling createUsersWithArrayInput.'); + if (!runtime.exists(requestParameters, 'body')) { + throw new runtime.RequiredError( + 'body', + 'Required parameter "body" was null or undefined when calling createUsersWithArrayInput().' + ); } const queryParameters: any = {}; @@ -106,7 +112,7 @@ export class UserApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, - body: requestParameters.body, + body: requestParameters['body'], }, initOverrides); return new runtime.VoidApiResponse(response); @@ -123,8 +129,11 @@ export class UserApi extends runtime.BaseAPI { * Creates list of users with given input array */ async createUsersWithListInputRaw(requestParameters: CreateUsersWithListInputRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.body === null || requestParameters.body === undefined) { - throw new runtime.RequiredError('body','Required parameter requestParameters.body was null or undefined when calling createUsersWithListInput.'); + if (!runtime.exists(requestParameters, 'body')) { + throw new runtime.RequiredError( + 'body', + 'Required parameter "body" was null or undefined when calling createUsersWithListInput().' + ); } const queryParameters: any = {}; @@ -138,7 +147,7 @@ export class UserApi extends runtime.BaseAPI { method: 'POST', headers: headerParameters, query: queryParameters, - body: requestParameters.body, + body: requestParameters['body'], }, initOverrides); return new runtime.VoidApiResponse(response); @@ -156,8 +165,11 @@ export class UserApi extends runtime.BaseAPI { * Delete user */ async deleteUserRaw(requestParameters: DeleteUserRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.username === null || requestParameters.username === undefined) { - throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling deleteUser.'); + if (!runtime.exists(requestParameters, 'username')) { + throw new runtime.RequiredError( + 'username', + 'Required parameter "username" was null or undefined when calling deleteUser().' + ); } const queryParameters: any = {}; @@ -165,7 +177,7 @@ export class UserApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; const response = await this.request({ - path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), + path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters['username']))), method: 'DELETE', headers: headerParameters, query: queryParameters, @@ -186,8 +198,11 @@ export class UserApi extends runtime.BaseAPI { * Get user by user name */ async getUserByNameRaw(requestParameters: GetUserByNameRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.username === null || requestParameters.username === undefined) { - throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling getUserByName.'); + if (!runtime.exists(requestParameters, 'username')) { + throw new runtime.RequiredError( + 'username', + 'Required parameter "username" was null or undefined when calling getUserByName().' + ); } const queryParameters: any = {}; @@ -195,7 +210,7 @@ export class UserApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; const response = await this.request({ - path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), + path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters['username']))), method: 'GET', headers: headerParameters, query: queryParameters, @@ -216,22 +231,28 @@ export class UserApi extends runtime.BaseAPI { * Logs user into the system */ async loginUserRaw(requestParameters: LoginUserRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.username === null || requestParameters.username === undefined) { - throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling loginUser.'); + if (!runtime.exists(requestParameters, 'username')) { + throw new runtime.RequiredError( + 'username', + 'Required parameter "username" was null or undefined when calling loginUser().' + ); } - if (requestParameters.password === null || requestParameters.password === undefined) { - throw new runtime.RequiredError('password','Required parameter requestParameters.password was null or undefined when calling loginUser.'); + if (!runtime.exists(requestParameters, 'password')) { + throw new runtime.RequiredError( + 'password', + 'Required parameter "password" was null or undefined when calling loginUser().' + ); } const queryParameters: any = {}; - if (requestParameters.username !== undefined) { - queryParameters['username'] = requestParameters.username; + if (runtime.exists(requestParameters, 'username')) { + queryParameters['username'] = requestParameters['username']; } - if (requestParameters.password !== undefined) { - queryParameters['password'] = requestParameters.password; + if (runtime.exists(requestParameters, 'password')) { + queryParameters['password'] = requestParameters['password']; } const headerParameters: runtime.HTTPHeaders = {}; @@ -288,12 +309,18 @@ export class UserApi extends runtime.BaseAPI { * Updated user */ async updateUserRaw(requestParameters: UpdateUserRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.username === null || requestParameters.username === undefined) { - throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling updateUser.'); + if (!runtime.exists(requestParameters, 'username')) { + throw new runtime.RequiredError( + 'username', + 'Required parameter "username" was null or undefined when calling updateUser().' + ); } - if (requestParameters.body === null || requestParameters.body === undefined) { - throw new runtime.RequiredError('body','Required parameter requestParameters.body was null or undefined when calling updateUser.'); + if (!runtime.exists(requestParameters, 'body')) { + throw new runtime.RequiredError( + 'body', + 'Required parameter "body" was null or undefined when calling updateUser().' + ); } const queryParameters: any = {}; @@ -303,11 +330,11 @@ export class UserApi extends runtime.BaseAPI { headerParameters['Content-Type'] = 'application/json'; const response = await this.request({ - path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), + path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters['username']))), method: 'PUT', headers: headerParameters, query: queryParameters, - body: requestParameters.body, + body: requestParameters['body'], }, initOverrides); return new runtime.VoidApiResponse(response);