Skip to content

Commit

Permalink
[TS][nestjs] fix isListContainer with isArray (#11425)
Browse files Browse the repository at this point in the history
* fix isListContainer with isArray in ts nextjs

* update samples
  • Loading branch information
wing328 authored Jan 28, 2022
1 parent ff7c2bd commit aed513f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export class {{classname}} {
{{#hasQueryParams}}
let queryParameters = {};
{{#queryParams}}
{{#isListContainer}}
{{#isArray}}
if ({{paramName}}) {
{{#isCollectionFormatMulti}}
{{paramName}}.forEach((element) => {
Expand All @@ -83,8 +83,8 @@ export class {{classname}} {
queryParameters['{{baseName}}'] = {{paramName}}.join(COLLECTION_FORMATS['{{collectionFormat}}']);
{{/isCollectionFormatMulti}}
}
{{/isListContainer}}
{{^isListContainer}}
{{/isArray}}
{{^isArray}}
if ({{paramName}} !== undefined && {{paramName}} !== null) {
{{#isDateTime}}
queryParameters['{{baseName}}'] = <any>{{paramName}}.toISOString();
Expand All @@ -93,22 +93,22 @@ export class {{classname}} {
queryParameters['{{baseName}}'] = <any>{{paramName}};
{{/isDateTime}}
}
{{/isListContainer}}
{{/isArray}}
{{/queryParams}}

{{/hasQueryParams}}
let headers = this.defaultHeaders;
{{#headerParams}}
{{#isListContainer}}
{{#isArray}}
if ({{paramName}}) {
headers['{{baseName}}'] = {{paramName}}.join(COLLECTION_FORMATS['{{collectionFormat}}']);
}
{{/isListContainer}}
{{^isListContainer}}
{{/isArray}}
{{^isArray}}
if ({{paramName}} !== undefined && {{paramName}} !== null) {
headers['{{baseName}}'] = String({{paramName}});
}
{{/isListContainer}}
{{/isArray}}
{{/headerParams}}

{{#authMethods}}
Expand Down Expand Up @@ -188,7 +188,7 @@ export class {{classname}} {
}
{{#formParams}}

{{#isListContainer}}
{{#isArray}}
if ({{paramName}}) {
{{#isCollectionFormatMulti}}
{{paramName}}.forEach((element) => {
Expand All @@ -199,12 +199,12 @@ export class {{classname}} {
formParams.append('{{baseName}}', {{paramName}}.join(COLLECTION_FORMATS['{{collectionFormat}}']));
{{/isCollectionFormatMulti}}
}
{{/isListContainer}}
{{^isListContainer}}
{{/isArray}}
{{^isArray}}
if ({{paramName}} !== undefined) {
formParams.append('{{baseName}}', <any>{{paramName}});
}
{{/isListContainer}}
{{/isArray}}
{{/formParams}}

{{/hasFormParams}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ export class PetService {
}

let queryParameters = {};
if (status !== undefined && status !== null) {
queryParameters['status'] = <any>status;
if (status) {
queryParameters['status'] = status.join(COLLECTION_FORMATS['csv']);
}

let headers = this.defaultHeaders;
Expand Down Expand Up @@ -203,8 +203,8 @@ export class PetService {
}

let queryParameters = {};
if (tags !== undefined && tags !== null) {
queryParameters['tags'] = <any>tags;
if (tags) {
queryParameters['tags'] = tags.join(COLLECTION_FORMATS['csv']);
}

let headers = this.defaultHeaders;
Expand Down

0 comments on commit aed513f

Please sign in to comment.