Skip to content

Commit

Permalink
#2147: fix compiler error in angular typescript codegen (#2149)
Browse files Browse the repository at this point in the history
* #2147: fix compiler error in angular typescript codegen

* #2147: generate samples
  • Loading branch information
macjohnny authored and wing328 committed Feb 14, 2019
1 parent 804b589 commit e01a786
Show file tree
Hide file tree
Showing 11 changed files with 40 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -296,17 +296,17 @@ export class {{classname}} {
if ({{paramName}}) {
{{#isCollectionFormatMulti}}
{{paramName}}.forEach((element) => {
{{#useHttpClient}}formParams = {{/useHttpClient}}formParams.append('{{baseName}}', <any>element){{#useHttpClient}} || formParams{{/useHttpClient}};
{{#useHttpClient}}formParams = {{/useHttpClient}}formParams.append('{{baseName}}', <any>element){{#useHttpClient}} as any || formParams{{/useHttpClient}};
})
{{/isCollectionFormatMulti}}
{{^isCollectionFormatMulti}}
{{#useHttpClient}}formParams = {{/useHttpClient}}formParams.append('{{baseName}}', {{paramName}}.join(COLLECTION_FORMATS['{{collectionFormat}}'])){{#useHttpClient}} || formParams{{/useHttpClient}};
{{#useHttpClient}}formParams = {{/useHttpClient}}formParams.append('{{baseName}}', {{paramName}}.join(COLLECTION_FORMATS['{{collectionFormat}}'])){{#useHttpClient}} as any || formParams{{/useHttpClient}};
{{/isCollectionFormatMulti}}
}
{{/isListContainer}}
{{^isListContainer}}
if ({{paramName}} !== undefined) {
{{#useHttpClient}}formParams = {{/useHttpClient}}formParams.append('{{baseName}}', <any>{{paramName}}){{#useHttpClient}} || formParams{{/useHttpClient}};
{{#useHttpClient}}formParams = {{/useHttpClient}}formParams.append('{{baseName}}', <any>{{paramName}}){{#useHttpClient}} as any || formParams{{/useHttpClient}};
}
{{/isListContainer}}
{{/formParams}}
Expand Down
4 changes: 1 addition & 3 deletions samples/client/petstore/typescript-angular-v2/npm/encoder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
export class CustomQueryEncoderHelper extends QueryEncoder {
encodeKey(k: string): string {
k = super.encodeKey(k);
return k.replace(/\+/gi, '%2B')
.replace(/%5B/, "[").replace(/%5D/, "]")
;
return k.replace(/\+/gi, '%2B');
}
encodeValue(v: string): string {
v = super.encodeValue(v);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -425,10 +425,10 @@ export class PetService {
}

if (name !== undefined) {
formParams = formParams.append('name', <any>name) || formParams;
formParams = formParams.append('name', <any>name) as any || formParams;
}
if (status !== undefined) {
formParams = formParams.append('status', <any>status) || formParams;
formParams = formParams.append('status', <any>status) as any || formParams;
}

return this.httpClient.post<any>(`${this.configuration.basePath}/pet/${encodeURIComponent(String(petId))}`,
Expand Down Expand Up @@ -498,10 +498,10 @@ export class PetService {
}

if (additionalMetadata !== undefined) {
formParams = formParams.append('additionalMetadata', <any>additionalMetadata) || formParams;
formParams = formParams.append('additionalMetadata', <any>additionalMetadata) as any || formParams;
}
if (file !== undefined) {
formParams = formParams.append('file', <any>file) || formParams;
formParams = formParams.append('file', <any>file) as any || formParams;
}

return this.httpClient.post<ApiResponse>(`${this.configuration.basePath}/pet/${encodeURIComponent(String(petId))}/uploadImage`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -425,10 +425,10 @@ export class PetService {
}

if (name !== undefined) {
formParams = formParams.append('name', <any>name) || formParams;
formParams = formParams.append('name', <any>name) as any || formParams;
}
if (status !== undefined) {
formParams = formParams.append('status', <any>status) || formParams;
formParams = formParams.append('status', <any>status) as any || formParams;
}

return this.httpClient.post<any>(`${this.configuration.basePath}/pet/${encodeURIComponent(String(petId))}`,
Expand Down Expand Up @@ -498,10 +498,10 @@ export class PetService {
}

if (additionalMetadata !== undefined) {
formParams = formParams.append('additionalMetadata', <any>additionalMetadata) || formParams;
formParams = formParams.append('additionalMetadata', <any>additionalMetadata) as any || formParams;
}
if (file !== undefined) {
formParams = formParams.append('file', <any>file) || formParams;
formParams = formParams.append('file', <any>file) as any || formParams;
}

return this.httpClient.post<ApiResponse>(`${this.configuration.basePath}/pet/${encodeURIComponent(String(petId))}/uploadImage`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -425,10 +425,10 @@ export class PetService {
}

if (name !== undefined) {
formParams = formParams.append('name', <any>name) || formParams;
formParams = formParams.append('name', <any>name) as any || formParams;
}
if (status !== undefined) {
formParams = formParams.append('status', <any>status) || formParams;
formParams = formParams.append('status', <any>status) as any || formParams;
}

return this.httpClient.post<any>(`${this.configuration.basePath}/pet/${encodeURIComponent(String(petId))}`,
Expand Down Expand Up @@ -498,10 +498,10 @@ export class PetService {
}

if (additionalMetadata !== undefined) {
formParams = formParams.append('additionalMetadata', <any>additionalMetadata) || formParams;
formParams = formParams.append('additionalMetadata', <any>additionalMetadata) as any || formParams;
}
if (file !== undefined) {
formParams = formParams.append('file', <any>file) || formParams;
formParams = formParams.append('file', <any>file) as any || formParams;
}

return this.httpClient.post<ApiResponse>(`${this.configuration.basePath}/pet/${encodeURIComponent(String(petId))}/uploadImage`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -427,10 +427,10 @@ export class PetService {
}

if (name !== undefined) {
formParams = formParams.append('name', <any>name) || formParams;
formParams = formParams.append('name', <any>name) as any || formParams;
}
if (status !== undefined) {
formParams = formParams.append('status', <any>status) || formParams;
formParams = formParams.append('status', <any>status) as any || formParams;
}

return this.httpClient.post<any>(`${this.configuration.basePath}/pet/${encodeURIComponent(String(petId))}`,
Expand Down Expand Up @@ -500,10 +500,10 @@ export class PetService {
}

if (additionalMetadata !== undefined) {
formParams = formParams.append('additionalMetadata', <any>additionalMetadata) || formParams;
formParams = formParams.append('additionalMetadata', <any>additionalMetadata) as any || formParams;
}
if (file !== undefined) {
formParams = formParams.append('file', <any>file) || formParams;
formParams = formParams.append('file', <any>file) as any || formParams;
}

return this.httpClient.post<ApiResponse>(`${this.configuration.basePath}/pet/${encodeURIComponent(String(petId))}/uploadImage`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -427,10 +427,10 @@ export class PetService {
}

if (name !== undefined) {
formParams = formParams.append('name', <any>name) || formParams;
formParams = formParams.append('name', <any>name) as any || formParams;
}
if (status !== undefined) {
formParams = formParams.append('status', <any>status) || formParams;
formParams = formParams.append('status', <any>status) as any || formParams;
}

return this.httpClient.post<any>(`${this.configuration.basePath}/pet/${encodeURIComponent(String(petId))}`,
Expand Down Expand Up @@ -500,10 +500,10 @@ export class PetService {
}

if (additionalMetadata !== undefined) {
formParams = formParams.append('additionalMetadata', <any>additionalMetadata) || formParams;
formParams = formParams.append('additionalMetadata', <any>additionalMetadata) as any || formParams;
}
if (file !== undefined) {
formParams = formParams.append('file', <any>file) || formParams;
formParams = formParams.append('file', <any>file) as any || formParams;
}

return this.httpClient.post<ApiResponse>(`${this.configuration.basePath}/pet/${encodeURIComponent(String(petId))}/uploadImage`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -425,10 +425,10 @@ export class PetService {
}

if (name !== undefined) {
formParams = formParams.append('name', <any>name) || formParams;
formParams = formParams.append('name', <any>name) as any || formParams;
}
if (status !== undefined) {
formParams = formParams.append('status', <any>status) || formParams;
formParams = formParams.append('status', <any>status) as any || formParams;
}

return this.httpClient.post<any>(`${this.configuration.basePath}/pet/${encodeURIComponent(String(petId))}`,
Expand Down Expand Up @@ -498,10 +498,10 @@ export class PetService {
}

if (additionalMetadata !== undefined) {
formParams = formParams.append('additionalMetadata', <any>additionalMetadata) || formParams;
formParams = formParams.append('additionalMetadata', <any>additionalMetadata) as any || formParams;
}
if (file !== undefined) {
formParams = formParams.append('file', <any>file) || formParams;
formParams = formParams.append('file', <any>file) as any || formParams;
}

return this.httpClient.post<ApiResponse>(`${this.configuration.basePath}/pet/${encodeURIComponent(String(petId))}/uploadImage`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -425,10 +425,10 @@ export class PetService {
}

if (name !== undefined) {
formParams = formParams.append('name', <any>name) || formParams;
formParams = formParams.append('name', <any>name) as any || formParams;
}
if (status !== undefined) {
formParams = formParams.append('status', <any>status) || formParams;
formParams = formParams.append('status', <any>status) as any || formParams;
}

return this.httpClient.post<any>(`${this.configuration.basePath}/pet/${encodeURIComponent(String(petId))}`,
Expand Down Expand Up @@ -498,10 +498,10 @@ export class PetService {
}

if (additionalMetadata !== undefined) {
formParams = formParams.append('additionalMetadata', <any>additionalMetadata) || formParams;
formParams = formParams.append('additionalMetadata', <any>additionalMetadata) as any || formParams;
}
if (file !== undefined) {
formParams = formParams.append('file', <any>file) || formParams;
formParams = formParams.append('file', <any>file) as any || formParams;
}

return this.httpClient.post<ApiResponse>(`${this.configuration.basePath}/pet/${encodeURIComponent(String(petId))}/uploadImage`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -427,10 +427,10 @@ export class PetService {
}

if (name !== undefined) {
formParams = formParams.append('name', <any>name) || formParams;
formParams = formParams.append('name', <any>name) as any || formParams;
}
if (status !== undefined) {
formParams = formParams.append('status', <any>status) || formParams;
formParams = formParams.append('status', <any>status) as any || formParams;
}

return this.httpClient.post<any>(`${this.configuration.basePath}/pet/${encodeURIComponent(String(petId))}`,
Expand Down Expand Up @@ -500,10 +500,10 @@ export class PetService {
}

if (additionalMetadata !== undefined) {
formParams = formParams.append('additionalMetadata', <any>additionalMetadata) || formParams;
formParams = formParams.append('additionalMetadata', <any>additionalMetadata) as any || formParams;
}
if (file !== undefined) {
formParams = formParams.append('file', <any>file) || formParams;
formParams = formParams.append('file', <any>file) as any || formParams;
}

return this.httpClient.post<ApiResponse>(`${this.configuration.basePath}/pet/${encodeURIComponent(String(petId))}/uploadImage`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -427,10 +427,10 @@ export class PetService {
}

if (name !== undefined) {
formParams = formParams.append('name', <any>name) || formParams;
formParams = formParams.append('name', <any>name) as any || formParams;
}
if (status !== undefined) {
formParams = formParams.append('status', <any>status) || formParams;
formParams = formParams.append('status', <any>status) as any || formParams;
}

return this.httpClient.post<any>(`${this.configuration.basePath}/pet/${encodeURIComponent(String(petId))}`,
Expand Down Expand Up @@ -500,10 +500,10 @@ export class PetService {
}

if (additionalMetadata !== undefined) {
formParams = formParams.append('additionalMetadata', <any>additionalMetadata) || formParams;
formParams = formParams.append('additionalMetadata', <any>additionalMetadata) as any || formParams;
}
if (file !== undefined) {
formParams = formParams.append('file', <any>file) || formParams;
formParams = formParams.append('file', <any>file) as any || formParams;
}

return this.httpClient.post<ApiResponse>(`${this.configuration.basePath}/pet/${encodeURIComponent(String(petId))}/uploadImage`,
Expand Down

0 comments on commit e01a786

Please sign in to comment.