diff --git a/modules/swagger-codegen/src/main/resources/typescript-angular/api.service.mustache b/modules/swagger-codegen/src/main/resources/typescript-angular/api.service.mustache index 1dd20307db1..47a46651b8b 100644 --- a/modules/swagger-codegen/src/main/resources/typescript-angular/api.service.mustache +++ b/modules/swagger-codegen/src/main/resources/typescript-angular/api.service.mustache @@ -34,6 +34,25 @@ import { Configuration } from '../configurat import { {{classname}}Interface } from './{{classFilename}}Interface'; {{/withInterfaces}} +{{#useHttpClient}} + import { HttpClient, HttpHeaders, HttpParams, + HttpResponse, HttpEvent } from '@angular/common/http'; + import { CustomHttpUrlEncodingCodec } from '../encoder'; +{{/useHttpClient}} +{{^useHttpClient}} + import { Http, Headers, URLSearchParams } from '@angular/http'; + import { RequestMethod, RequestOptions, RequestOptionsArgs } from '@angular/http'; + import { Response, ResponseContentType } from '@angular/http'; + import { CustomQueryEncoderHelper } from '../encoder'; +{{/useHttpClient}} + + +type FormParams = URLSearchParams | FormData{{#useHttpClient}} | HttpParams{{/useHttpClient}}; + +function append(formParams: FormParams, param: string, value: any) { + return {{#useHttpClient}}formParams.append(param, value){{/useHttpClient}}{{^useHttpClient}}formParams.append(param, value), formParams{{/useHttpClient}} +}; + {{#operations}} {{#description}} @@ -262,7 +281,7 @@ export class {{classname}} { {{#hasFormParams}} const canConsumeForm = this.canConsumeForm(consumes); - let formParams: { append(param: string, value: any): void; }; + let formParams: FormParams; let useForm = false; let convertFormParamsToString = false; {{#formParams}} @@ -286,23 +305,22 @@ export class {{classname}} { headers.set('Content-Type', 'application/x-www-form-urlencoded;charset=UTF-8'); {{/useHttpClient}} } - {{#formParams}} {{#isListContainer}} if ({{paramName}}) { {{#isCollectionFormatMulti}} {{paramName}}.forEach((element) => { - {{#useHttpClient}}formParams = {{/useHttpClient}}formParams.append('{{baseName}}', element){{#useHttpClient}} || formParams{{/useHttpClient}}; + {{#useHttpClient}}formParams = {{/useHttpClient}}append(formParams, '{{baseName}}', element); }) {{/isCollectionFormatMulti}} {{^isCollectionFormatMulti}} - {{#useHttpClient}}formParams = {{/useHttpClient}}formParams.append('{{baseName}}', {{paramName}}.join(COLLECTION_FORMATS['{{collectionFormat}}'])){{#useHttpClient}} || formParams{{/useHttpClient}}; + {{#useHttpClient}}formParams = {{/useHttpClient}}append(formParams, '{{baseName}}', {{paramName}}.join(COLLECTION_FORMATS['{{collectionFormat}}'])); {{/isCollectionFormatMulti}} } {{/isListContainer}} {{^isListContainer}} if ({{paramName}} !== undefined) { - {{#useHttpClient}}formParams = {{/useHttpClient}}formParams.append('{{baseName}}', {{paramName}}){{#useHttpClient}} || formParams{{/useHttpClient}}; + {{#useHttpClient}}formParams = {{/useHttpClient}}append(formParams, '{{baseName}}', {{paramName}}); } {{/isListContainer}} {{/formParams}} @@ -353,4 +371,4 @@ export class {{classname}} { } {{/operation}}} -{{/operations}} +{{/operations}} \ No newline at end of file diff --git a/samples/client/petstore-security-test/typescript-angular/.swagger-codegen/VERSION b/samples/client/petstore-security-test/typescript-angular/.swagger-codegen/VERSION index 855ff9501eb..017674fb59d 100644 --- a/samples/client/petstore-security-test/typescript-angular/.swagger-codegen/VERSION +++ b/samples/client/petstore-security-test/typescript-angular/.swagger-codegen/VERSION @@ -1 +1 @@ -2.4.0-SNAPSHOT \ No newline at end of file +2.4.3-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore-security-test/typescript-angular/README.md b/samples/client/petstore-security-test/typescript-angular/README.md index f679bcb1320..9c7753a47b7 100644 --- a/samples/client/petstore-security-test/typescript-angular/README.md +++ b/samples/client/petstore-security-test/typescript-angular/README.md @@ -2,7 +2,7 @@ ### Building -To build an compile the typescript sources to javascript use: +To install the required dependencies and to build the typescript sources run: ``` npm install npm run build @@ -14,7 +14,7 @@ First build the package than run ```npm publish``` ### consuming -navigate to the folder of your consuming project and run one of next commando's. +Navigate to the folder of your consuming project and run one of next commands. _published:_ @@ -22,7 +22,7 @@ _published:_ npm install @ --save ``` -_unPublished (not recommended):_ +_without publishing (not recommended):_ ``` npm install PATH_TO_GENERATED_PACKAGE --save @@ -37,9 +37,16 @@ npm link In your project: ``` -npm link @ +npm link ``` +__Note for Windows users:__ The Angular CLI has troubles to use linked npm packages. +Please refer to this issue https://github.com/angular/angular-cli/issues/8284 for a solution / workaround. +Published packages are not effected by this issue. + + +#### General usage + In your Angular project: diff --git a/samples/client/petstore-security-test/typescript-angular/api.module.ts b/samples/client/petstore-security-test/typescript-angular/api.module.ts index a95cda25231..867cee5c7b2 100644 --- a/samples/client/petstore-security-test/typescript-angular/api.module.ts +++ b/samples/client/petstore-security-test/typescript-angular/api.module.ts @@ -17,7 +17,7 @@ export class ApiModule { return { ngModule: ApiModule, providers: [ { provide: Configuration, useFactory: configurationFactory } ] - } + }; } constructor( @Optional() @SkipSelf() parentModule: ApiModule, diff --git a/samples/client/petstore-security-test/typescript-angular/api/fake.service.ts b/samples/client/petstore-security-test/typescript-angular/api/fake.service.ts index d0047d78bee..cdfb5746278 100644 --- a/samples/client/petstore-security-test/typescript-angular/api/fake.service.ts +++ b/samples/client/petstore-security-test/typescript-angular/api/fake.service.ts @@ -22,6 +22,17 @@ import { Observable } from 'rxjs/Observab import { BASE_PATH, COLLECTION_FORMATS } from '../variables'; import { Configuration } from '../configuration'; + import { HttpClient, HttpHeaders, HttpParams, + HttpResponse, HttpEvent } from '@angular/common/http'; + import { CustomHttpUrlEncodingCodec } from '../encoder'; + + +type FormParams = URLSearchParams | FormData | HttpParams; + +function append(formParams: FormParams, param: string, value: any) { + return formParams.append(param, value) +}; + @Injectable() export class FakeService { @@ -46,7 +57,7 @@ export class FakeService { */ private canConsumeForm(consumes: string[]): boolean { const form = 'multipart/form-data'; - for (let consume of consumes) { + for (const consume of consumes) { if (form === consume) { return true; } @@ -67,6 +78,7 @@ export class FakeService { public testCodeInjectEndRnNR(testCodeInjectEndRnNR?: string, observe?: 'events', reportProgress?: boolean): Observable>; public testCodeInjectEndRnNR(testCodeInjectEndRnNR?: string, observe: any = 'body', reportProgress: boolean = false ): Observable { + let headers = this.defaultHeaders; // to determine the Accept header @@ -74,20 +86,20 @@ export class FakeService { 'application/json', '*_/ =end -- ' ]; - let httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts); + const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts); if (httpHeaderAcceptSelected != undefined) { - headers = headers.set("Accept", httpHeaderAcceptSelected); + headers = headers.set('Accept', httpHeaderAcceptSelected); } // to determine the Content-Type header - let consumes: string[] = [ + const consumes: string[] = [ 'application/json', '*_/ =end -- ' ]; const canConsumeForm = this.canConsumeForm(consumes); - let formParams: { append(param: string, value: any): void; }; + let formParams: FormParams; let useForm = false; let convertFormParamsToString = false; if (useForm) { @@ -95,9 +107,8 @@ export class FakeService { } else { formParams = new HttpParams({encoder: new CustomHttpUrlEncodingCodec()}); } - if (testCodeInjectEndRnNR !== undefined) { - formParams = formParams.append('test code inject */ ' " =end -- \r\n \n \r', testCodeInjectEndRnNR) || formParams; + formParams = append(formParams, 'test code inject */ ' " =end -- \r\n \n \r', testCodeInjectEndRnNR); } return this.httpClient.put(`${this.basePath}/fake`, diff --git a/samples/client/petstore-security-test/typescript-angular/configuration.ts b/samples/client/petstore-security-test/typescript-angular/configuration.ts index 2ee1824f5f7..82e8458f39e 100644 --- a/samples/client/petstore-security-test/typescript-angular/configuration.ts +++ b/samples/client/petstore-security-test/typescript-angular/configuration.ts @@ -28,8 +28,8 @@ export class Configuration { * Select the correct content-type to use for a request. * Uses {@link Configuration#isJsonMime} to determine the correct content-type. * If no content type is found return the first found type if the contentTypes is not empty - * @param {string[]} contentTypes - the array of content types that are available for selection - * @returns {string} the selected content-type or undefined if no selection could be made. + * @param contentTypes - the array of content types that are available for selection + * @returns the selected content-type or undefined if no selection could be made. */ public selectHeaderContentType (contentTypes: string[]): string | undefined { if (contentTypes.length == 0) { @@ -47,8 +47,8 @@ export class Configuration { * Select the correct accept content-type to use for a request. * Uses {@link Configuration#isJsonMime} to determine the correct accept content-type. * If no content type is found return the first found type if the contentTypes is not empty - * @param {string[]} accepts - the array of content types that are available for selection. - * @returns {string} the selected content-type or undefined if no selection could be made. + * @param accepts - the array of content types that are available for selection. + * @returns the selected content-type or undefined if no selection could be made. */ public selectHeaderAccept(accepts: string[]): string | undefined { if (accepts.length == 0) { @@ -69,8 +69,8 @@ export class Configuration { * application/json; charset=UTF8 * APPLICATION/JSON * application/vnd.company+json - * @param {string} mime - MIME (Multipurpose Internet Mail Extensions) - * @return {boolean} True if the given MIME is JSON, false otherwise. + * @param mime - MIME (Multipurpose Internet Mail Extensions) + * @return True if the given MIME is JSON, false otherwise. */ public isJsonMime(mime: string): boolean { const jsonMime: RegExp = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i'); diff --git a/samples/client/petstore/typescript-angular-v2/default/api/pet.service.ts b/samples/client/petstore/typescript-angular-v2/default/api/pet.service.ts index 78080a33ea2..ee187c89cd0 100644 --- a/samples/client/petstore/typescript-angular-v2/default/api/pet.service.ts +++ b/samples/client/petstore/typescript-angular-v2/default/api/pet.service.ts @@ -26,6 +26,12 @@ import { Pet } from '../model/pet'; import { BASE_PATH, COLLECTION_FORMATS } from '../variables'; import { Configuration } from '../configuration'; +type FormParams = HttpParams | URLSearchParams | FormData; + +function getAppender(useReturnValue = false) { + return (formParams: FormParams, param: string, value: any) => + useReturnValue ? formParams.append(param, value) : formParams.append(param, value), formParams; +} @Injectable() export class PetService { @@ -557,7 +563,8 @@ export class PetService { const canConsumeForm = this.canConsumeForm(consumes); - let formParams: { append(param: string, value: any): void; }; + let formParams: FormParams; + let append = getAppender(); let useForm = false; let convertFormParamsToString = false; if (useForm) { @@ -569,12 +576,11 @@ export class PetService { // set the content-type explicitly to avoid having it set to 'text/plain' headers.set('Content-Type', 'application/x-www-form-urlencoded;charset=UTF-8'); } - if (name !== undefined) { - formParams.append('name', name); + append(formParams, 'name', name); } if (status !== undefined) { - formParams.append('status', status); + append(formParams, 'status', status); } let requestOptions: RequestOptionsArgs = new RequestOptions({ @@ -633,7 +639,8 @@ export class PetService { const canConsumeForm = this.canConsumeForm(consumes); - let formParams: { append(param: string, value: any): void; }; + let formParams: FormParams; + let append = getAppender(); let useForm = false; let convertFormParamsToString = false; // use FormData to transmit files using content-type "multipart/form-data" @@ -648,12 +655,11 @@ export class PetService { // set the content-type explicitly to avoid having it set to 'text/plain' headers.set('Content-Type', 'application/x-www-form-urlencoded;charset=UTF-8'); } - if (additionalMetadata !== undefined) { - formParams.append('additionalMetadata', additionalMetadata); + append(formParams, 'additionalMetadata', additionalMetadata); } if (file !== undefined) { - formParams.append('file', file); + append(formParams, 'file', file); } let requestOptions: RequestOptionsArgs = new RequestOptions({ diff --git a/samples/client/petstore/typescript-angular-v2/default/api/store.service.ts b/samples/client/petstore/typescript-angular-v2/default/api/store.service.ts index fa78d49386a..559f8d9286b 100644 --- a/samples/client/petstore/typescript-angular-v2/default/api/store.service.ts +++ b/samples/client/petstore/typescript-angular-v2/default/api/store.service.ts @@ -25,6 +25,12 @@ import { Order } from '../model/order'; import { BASE_PATH, COLLECTION_FORMATS } from '../variables'; import { Configuration } from '../configuration'; +type FormParams = HttpParams | URLSearchParams | FormData; + +function getAppender(useReturnValue = false) { + return (formParams: FormParams, param: string, value: any) => + useReturnValue ? formParams.append(param, value) : formParams.append(param, value), formParams; +} @Injectable() export class StoreService { diff --git a/samples/client/petstore/typescript-angular-v2/default/api/user.service.ts b/samples/client/petstore/typescript-angular-v2/default/api/user.service.ts index 2d4286f42f1..047894acf77 100644 --- a/samples/client/petstore/typescript-angular-v2/default/api/user.service.ts +++ b/samples/client/petstore/typescript-angular-v2/default/api/user.service.ts @@ -25,6 +25,12 @@ import { User } from '../model/user'; import { BASE_PATH, COLLECTION_FORMATS } from '../variables'; import { Configuration } from '../configuration'; +type FormParams = HttpParams | URLSearchParams | FormData; + +function getAppender(useReturnValue = false) { + return (formParams: FormParams, param: string, value: any) => + useReturnValue ? formParams.append(param, value) : formParams.append(param, value), formParams; +} @Injectable() export class UserService { diff --git a/samples/client/petstore/typescript-angular-v2/npm/api/pet.service.ts b/samples/client/petstore/typescript-angular-v2/npm/api/pet.service.ts index 78080a33ea2..ee187c89cd0 100644 --- a/samples/client/petstore/typescript-angular-v2/npm/api/pet.service.ts +++ b/samples/client/petstore/typescript-angular-v2/npm/api/pet.service.ts @@ -26,6 +26,12 @@ import { Pet } from '../model/pet'; import { BASE_PATH, COLLECTION_FORMATS } from '../variables'; import { Configuration } from '../configuration'; +type FormParams = HttpParams | URLSearchParams | FormData; + +function getAppender(useReturnValue = false) { + return (formParams: FormParams, param: string, value: any) => + useReturnValue ? formParams.append(param, value) : formParams.append(param, value), formParams; +} @Injectable() export class PetService { @@ -557,7 +563,8 @@ export class PetService { const canConsumeForm = this.canConsumeForm(consumes); - let formParams: { append(param: string, value: any): void; }; + let formParams: FormParams; + let append = getAppender(); let useForm = false; let convertFormParamsToString = false; if (useForm) { @@ -569,12 +576,11 @@ export class PetService { // set the content-type explicitly to avoid having it set to 'text/plain' headers.set('Content-Type', 'application/x-www-form-urlencoded;charset=UTF-8'); } - if (name !== undefined) { - formParams.append('name', name); + append(formParams, 'name', name); } if (status !== undefined) { - formParams.append('status', status); + append(formParams, 'status', status); } let requestOptions: RequestOptionsArgs = new RequestOptions({ @@ -633,7 +639,8 @@ export class PetService { const canConsumeForm = this.canConsumeForm(consumes); - let formParams: { append(param: string, value: any): void; }; + let formParams: FormParams; + let append = getAppender(); let useForm = false; let convertFormParamsToString = false; // use FormData to transmit files using content-type "multipart/form-data" @@ -648,12 +655,11 @@ export class PetService { // set the content-type explicitly to avoid having it set to 'text/plain' headers.set('Content-Type', 'application/x-www-form-urlencoded;charset=UTF-8'); } - if (additionalMetadata !== undefined) { - formParams.append('additionalMetadata', additionalMetadata); + append(formParams, 'additionalMetadata', additionalMetadata); } if (file !== undefined) { - formParams.append('file', file); + append(formParams, 'file', file); } let requestOptions: RequestOptionsArgs = new RequestOptions({ diff --git a/samples/client/petstore/typescript-angular-v2/npm/api/store.service.ts b/samples/client/petstore/typescript-angular-v2/npm/api/store.service.ts index fa78d49386a..559f8d9286b 100644 --- a/samples/client/petstore/typescript-angular-v2/npm/api/store.service.ts +++ b/samples/client/petstore/typescript-angular-v2/npm/api/store.service.ts @@ -25,6 +25,12 @@ import { Order } from '../model/order'; import { BASE_PATH, COLLECTION_FORMATS } from '../variables'; import { Configuration } from '../configuration'; +type FormParams = HttpParams | URLSearchParams | FormData; + +function getAppender(useReturnValue = false) { + return (formParams: FormParams, param: string, value: any) => + useReturnValue ? formParams.append(param, value) : formParams.append(param, value), formParams; +} @Injectable() export class StoreService { diff --git a/samples/client/petstore/typescript-angular-v2/npm/api/user.service.ts b/samples/client/petstore/typescript-angular-v2/npm/api/user.service.ts index 2d4286f42f1..047894acf77 100644 --- a/samples/client/petstore/typescript-angular-v2/npm/api/user.service.ts +++ b/samples/client/petstore/typescript-angular-v2/npm/api/user.service.ts @@ -25,6 +25,12 @@ import { User } from '../model/user'; import { BASE_PATH, COLLECTION_FORMATS } from '../variables'; import { Configuration } from '../configuration'; +type FormParams = HttpParams | URLSearchParams | FormData; + +function getAppender(useReturnValue = false) { + return (formParams: FormParams, param: string, value: any) => + useReturnValue ? formParams.append(param, value) : formParams.append(param, value), formParams; +} @Injectable() export class UserService { diff --git a/samples/client/petstore/typescript-angular-v2/with-interfaces/api/pet.service.ts b/samples/client/petstore/typescript-angular-v2/with-interfaces/api/pet.service.ts index f3caaf58a5b..e2363deed4d 100644 --- a/samples/client/petstore/typescript-angular-v2/with-interfaces/api/pet.service.ts +++ b/samples/client/petstore/typescript-angular-v2/with-interfaces/api/pet.service.ts @@ -27,6 +27,12 @@ import { BASE_PATH, COLLECTION_FORMATS } from '../variables' import { Configuration } from '../configuration'; import { PetServiceInterface } from './pet.serviceInterface'; +type FormParams = HttpParams | URLSearchParams | FormData; + +function getAppender(useReturnValue = false) { + return (formParams: FormParams, param: string, value: any) => + useReturnValue ? formParams.append(param, value) : formParams.append(param, value), formParams; +} @Injectable() export class PetService implements PetServiceInterface { @@ -558,7 +564,8 @@ export class PetService implements PetServiceInterface { const canConsumeForm = this.canConsumeForm(consumes); - let formParams: { append(param: string, value: any): void; }; + let formParams: FormParams; + let append = getAppender(); let useForm = false; let convertFormParamsToString = false; if (useForm) { @@ -570,12 +577,11 @@ export class PetService implements PetServiceInterface { // set the content-type explicitly to avoid having it set to 'text/plain' headers.set('Content-Type', 'application/x-www-form-urlencoded;charset=UTF-8'); } - if (name !== undefined) { - formParams.append('name', name); + append(formParams, 'name', name); } if (status !== undefined) { - formParams.append('status', status); + append(formParams, 'status', status); } let requestOptions: RequestOptionsArgs = new RequestOptions({ @@ -634,7 +640,8 @@ export class PetService implements PetServiceInterface { const canConsumeForm = this.canConsumeForm(consumes); - let formParams: { append(param: string, value: any): void; }; + let formParams: FormParams; + let append = getAppender(); let useForm = false; let convertFormParamsToString = false; // use FormData to transmit files using content-type "multipart/form-data" @@ -649,12 +656,11 @@ export class PetService implements PetServiceInterface { // set the content-type explicitly to avoid having it set to 'text/plain' headers.set('Content-Type', 'application/x-www-form-urlencoded;charset=UTF-8'); } - if (additionalMetadata !== undefined) { - formParams.append('additionalMetadata', additionalMetadata); + append(formParams, 'additionalMetadata', additionalMetadata); } if (file !== undefined) { - formParams.append('file', file); + append(formParams, 'file', file); } let requestOptions: RequestOptionsArgs = new RequestOptions({ diff --git a/samples/client/petstore/typescript-angular-v2/with-interfaces/api/store.service.ts b/samples/client/petstore/typescript-angular-v2/with-interfaces/api/store.service.ts index 9c34dc32632..d62ef57a51d 100644 --- a/samples/client/petstore/typescript-angular-v2/with-interfaces/api/store.service.ts +++ b/samples/client/petstore/typescript-angular-v2/with-interfaces/api/store.service.ts @@ -26,6 +26,12 @@ import { BASE_PATH, COLLECTION_FORMATS } from '../variables' import { Configuration } from '../configuration'; import { StoreServiceInterface } from './store.serviceInterface'; +type FormParams = HttpParams | URLSearchParams | FormData; + +function getAppender(useReturnValue = false) { + return (formParams: FormParams, param: string, value: any) => + useReturnValue ? formParams.append(param, value) : formParams.append(param, value), formParams; +} @Injectable() export class StoreService implements StoreServiceInterface { diff --git a/samples/client/petstore/typescript-angular-v2/with-interfaces/api/user.service.ts b/samples/client/petstore/typescript-angular-v2/with-interfaces/api/user.service.ts index b093e70e7e2..5a304772450 100644 --- a/samples/client/petstore/typescript-angular-v2/with-interfaces/api/user.service.ts +++ b/samples/client/petstore/typescript-angular-v2/with-interfaces/api/user.service.ts @@ -26,6 +26,12 @@ import { BASE_PATH, COLLECTION_FORMATS } from '../variables' import { Configuration } from '../configuration'; import { UserServiceInterface } from './user.serviceInterface'; +type FormParams = HttpParams | URLSearchParams | FormData; + +function getAppender(useReturnValue = false) { + return (formParams: FormParams, param: string, value: any) => + useReturnValue ? formParams.append(param, value) : formParams.append(param, value), formParams; +} @Injectable() export class UserService implements UserServiceInterface { diff --git a/samples/client/petstore/typescript-angular-v4.3/npm/api/pet.service.ts b/samples/client/petstore/typescript-angular-v4.3/npm/api/pet.service.ts index b3b51af413d..d3d36089ec3 100644 --- a/samples/client/petstore/typescript-angular-v4.3/npm/api/pet.service.ts +++ b/samples/client/petstore/typescript-angular-v4.3/npm/api/pet.service.ts @@ -24,6 +24,12 @@ import { Pet } from '../model/pet'; import { BASE_PATH, COLLECTION_FORMATS } from '../variables'; import { Configuration } from '../configuration'; +type FormParams = HttpParams | URLSearchParams | FormData; + +function getAppender(useReturnValue = false) { + return (formParams: FormParams, param: string, value: any) => + useReturnValue ? formParams.append(param, value) : formParams.append(param, value), formParams; +} @Injectable() export class PetService { @@ -432,20 +438,21 @@ export class PetService { const canConsumeForm = this.canConsumeForm(consumes); - let formParams: { append(param: string, value: any): void; }; + let formParams: FormParams; + let append = getAppender(); let useForm = false; let convertFormParamsToString = false; if (useForm) { formParams = new FormData(); } else { formParams = new HttpParams({encoder: new CustomHttpUrlEncodingCodec()}); + append = getAppender(true); } - if (name !== undefined) { - formParams = formParams.append('name', name) || formParams; + formParams = append(formParams, 'name', name); } if (status !== undefined) { - formParams = formParams.append('status', status) || formParams; + formParams = append(formParams, 'status', status); } return this.httpClient.post(`${this.basePath}/pet/${encodeURIComponent(String(petId))}`, @@ -505,7 +512,8 @@ export class PetService { const canConsumeForm = this.canConsumeForm(consumes); - let formParams: { append(param: string, value: any): void; }; + let formParams: FormParams; + let append = getAppender(); let useForm = false; let convertFormParamsToString = false; // use FormData to transmit files using content-type "multipart/form-data" @@ -515,13 +523,13 @@ export class PetService { formParams = new FormData(); } else { formParams = new HttpParams({encoder: new CustomHttpUrlEncodingCodec()}); + append = getAppender(true); } - if (additionalMetadata !== undefined) { - formParams = formParams.append('additionalMetadata', additionalMetadata) || formParams; + formParams = append(formParams, 'additionalMetadata', additionalMetadata); } if (file !== undefined) { - formParams = formParams.append('file', file) || formParams; + formParams = append(formParams, 'file', file); } return this.httpClient.post(`${this.basePath}/pet/${encodeURIComponent(String(petId))}/uploadImage`, diff --git a/samples/client/petstore/typescript-angular-v4.3/npm/api/store.service.ts b/samples/client/petstore/typescript-angular-v4.3/npm/api/store.service.ts index 22f13b6f1bb..25241499b5b 100644 --- a/samples/client/petstore/typescript-angular-v4.3/npm/api/store.service.ts +++ b/samples/client/petstore/typescript-angular-v4.3/npm/api/store.service.ts @@ -23,6 +23,12 @@ import { Order } from '../model/order'; import { BASE_PATH, COLLECTION_FORMATS } from '../variables'; import { Configuration } from '../configuration'; +type FormParams = HttpParams | URLSearchParams | FormData; + +function getAppender(useReturnValue = false) { + return (formParams: FormParams, param: string, value: any) => + useReturnValue ? formParams.append(param, value) : formParams.append(param, value), formParams; +} @Injectable() export class StoreService { diff --git a/samples/client/petstore/typescript-angular-v4.3/npm/api/user.service.ts b/samples/client/petstore/typescript-angular-v4.3/npm/api/user.service.ts index e1323ce454b..26ace0707e5 100644 --- a/samples/client/petstore/typescript-angular-v4.3/npm/api/user.service.ts +++ b/samples/client/petstore/typescript-angular-v4.3/npm/api/user.service.ts @@ -23,6 +23,12 @@ import { User } from '../model/user'; import { BASE_PATH, COLLECTION_FORMATS } from '../variables'; import { Configuration } from '../configuration'; +type FormParams = HttpParams | URLSearchParams | FormData; + +function getAppender(useReturnValue = false) { + return (formParams: FormParams, param: string, value: any) => + useReturnValue ? formParams.append(param, value) : formParams.append(param, value), formParams; +} @Injectable() export class UserService { diff --git a/samples/client/petstore/typescript-angular-v4.3/with-interfaces/api/pet.service.ts b/samples/client/petstore/typescript-angular-v4.3/with-interfaces/api/pet.service.ts index a922b13249f..24542324765 100644 --- a/samples/client/petstore/typescript-angular-v4.3/with-interfaces/api/pet.service.ts +++ b/samples/client/petstore/typescript-angular-v4.3/with-interfaces/api/pet.service.ts @@ -25,6 +25,12 @@ import { BASE_PATH, COLLECTION_FORMATS } from '../variables' import { Configuration } from '../configuration'; import { PetServiceInterface } from './pet.serviceInterface'; +type FormParams = HttpParams | URLSearchParams | FormData; + +function getAppender(useReturnValue = false) { + return (formParams: FormParams, param: string, value: any) => + useReturnValue ? formParams.append(param, value) : formParams.append(param, value), formParams; +} @Injectable() export class PetService implements PetServiceInterface { @@ -433,20 +439,21 @@ export class PetService implements PetServiceInterface { const canConsumeForm = this.canConsumeForm(consumes); - let formParams: { append(param: string, value: any): void; }; + let formParams: FormParams; + let append = getAppender(); let useForm = false; let convertFormParamsToString = false; if (useForm) { formParams = new FormData(); } else { formParams = new HttpParams({encoder: new CustomHttpUrlEncodingCodec()}); + append = getAppender(true); } - if (name !== undefined) { - formParams = formParams.append('name', name) || formParams; + formParams = append(formParams, 'name', name); } if (status !== undefined) { - formParams = formParams.append('status', status) || formParams; + formParams = append(formParams, 'status', status); } return this.httpClient.post(`${this.basePath}/pet/${encodeURIComponent(String(petId))}`, @@ -506,7 +513,8 @@ export class PetService implements PetServiceInterface { const canConsumeForm = this.canConsumeForm(consumes); - let formParams: { append(param: string, value: any): void; }; + let formParams: FormParams; + let append = getAppender(); let useForm = false; let convertFormParamsToString = false; // use FormData to transmit files using content-type "multipart/form-data" @@ -516,13 +524,13 @@ export class PetService implements PetServiceInterface { formParams = new FormData(); } else { formParams = new HttpParams({encoder: new CustomHttpUrlEncodingCodec()}); + append = getAppender(true); } - if (additionalMetadata !== undefined) { - formParams = formParams.append('additionalMetadata', additionalMetadata) || formParams; + formParams = append(formParams, 'additionalMetadata', additionalMetadata); } if (file !== undefined) { - formParams = formParams.append('file', file) || formParams; + formParams = append(formParams, 'file', file); } return this.httpClient.post(`${this.basePath}/pet/${encodeURIComponent(String(petId))}/uploadImage`, diff --git a/samples/client/petstore/typescript-angular-v4.3/with-interfaces/api/store.service.ts b/samples/client/petstore/typescript-angular-v4.3/with-interfaces/api/store.service.ts index 271fabb7ba8..59abfbfb980 100644 --- a/samples/client/petstore/typescript-angular-v4.3/with-interfaces/api/store.service.ts +++ b/samples/client/petstore/typescript-angular-v4.3/with-interfaces/api/store.service.ts @@ -24,6 +24,12 @@ import { BASE_PATH, COLLECTION_FORMATS } from '../variables' import { Configuration } from '../configuration'; import { StoreServiceInterface } from './store.serviceInterface'; +type FormParams = HttpParams | URLSearchParams | FormData; + +function getAppender(useReturnValue = false) { + return (formParams: FormParams, param: string, value: any) => + useReturnValue ? formParams.append(param, value) : formParams.append(param, value), formParams; +} @Injectable() export class StoreService implements StoreServiceInterface { diff --git a/samples/client/petstore/typescript-angular-v4.3/with-interfaces/api/user.service.ts b/samples/client/petstore/typescript-angular-v4.3/with-interfaces/api/user.service.ts index 491402e119a..5cf120e6431 100644 --- a/samples/client/petstore/typescript-angular-v4.3/with-interfaces/api/user.service.ts +++ b/samples/client/petstore/typescript-angular-v4.3/with-interfaces/api/user.service.ts @@ -24,6 +24,12 @@ import { BASE_PATH, COLLECTION_FORMATS } from '../variables' import { Configuration } from '../configuration'; import { UserServiceInterface } from './user.serviceInterface'; +type FormParams = HttpParams | URLSearchParams | FormData; + +function getAppender(useReturnValue = false) { + return (formParams: FormParams, param: string, value: any) => + useReturnValue ? formParams.append(param, value) : formParams.append(param, value), formParams; +} @Injectable() export class UserService implements UserServiceInterface { diff --git a/samples/client/petstore/typescript-angular-v4/npm/api/pet.service.ts b/samples/client/petstore/typescript-angular-v4/npm/api/pet.service.ts index 78080a33ea2..ee187c89cd0 100644 --- a/samples/client/petstore/typescript-angular-v4/npm/api/pet.service.ts +++ b/samples/client/petstore/typescript-angular-v4/npm/api/pet.service.ts @@ -26,6 +26,12 @@ import { Pet } from '../model/pet'; import { BASE_PATH, COLLECTION_FORMATS } from '../variables'; import { Configuration } from '../configuration'; +type FormParams = HttpParams | URLSearchParams | FormData; + +function getAppender(useReturnValue = false) { + return (formParams: FormParams, param: string, value: any) => + useReturnValue ? formParams.append(param, value) : formParams.append(param, value), formParams; +} @Injectable() export class PetService { @@ -557,7 +563,8 @@ export class PetService { const canConsumeForm = this.canConsumeForm(consumes); - let formParams: { append(param: string, value: any): void; }; + let formParams: FormParams; + let append = getAppender(); let useForm = false; let convertFormParamsToString = false; if (useForm) { @@ -569,12 +576,11 @@ export class PetService { // set the content-type explicitly to avoid having it set to 'text/plain' headers.set('Content-Type', 'application/x-www-form-urlencoded;charset=UTF-8'); } - if (name !== undefined) { - formParams.append('name', name); + append(formParams, 'name', name); } if (status !== undefined) { - formParams.append('status', status); + append(formParams, 'status', status); } let requestOptions: RequestOptionsArgs = new RequestOptions({ @@ -633,7 +639,8 @@ export class PetService { const canConsumeForm = this.canConsumeForm(consumes); - let formParams: { append(param: string, value: any): void; }; + let formParams: FormParams; + let append = getAppender(); let useForm = false; let convertFormParamsToString = false; // use FormData to transmit files using content-type "multipart/form-data" @@ -648,12 +655,11 @@ export class PetService { // set the content-type explicitly to avoid having it set to 'text/plain' headers.set('Content-Type', 'application/x-www-form-urlencoded;charset=UTF-8'); } - if (additionalMetadata !== undefined) { - formParams.append('additionalMetadata', additionalMetadata); + append(formParams, 'additionalMetadata', additionalMetadata); } if (file !== undefined) { - formParams.append('file', file); + append(formParams, 'file', file); } let requestOptions: RequestOptionsArgs = new RequestOptions({ diff --git a/samples/client/petstore/typescript-angular-v4/npm/api/store.service.ts b/samples/client/petstore/typescript-angular-v4/npm/api/store.service.ts index fa78d49386a..559f8d9286b 100644 --- a/samples/client/petstore/typescript-angular-v4/npm/api/store.service.ts +++ b/samples/client/petstore/typescript-angular-v4/npm/api/store.service.ts @@ -25,6 +25,12 @@ import { Order } from '../model/order'; import { BASE_PATH, COLLECTION_FORMATS } from '../variables'; import { Configuration } from '../configuration'; +type FormParams = HttpParams | URLSearchParams | FormData; + +function getAppender(useReturnValue = false) { + return (formParams: FormParams, param: string, value: any) => + useReturnValue ? formParams.append(param, value) : formParams.append(param, value), formParams; +} @Injectable() export class StoreService { diff --git a/samples/client/petstore/typescript-angular-v4/npm/api/user.service.ts b/samples/client/petstore/typescript-angular-v4/npm/api/user.service.ts index 2d4286f42f1..047894acf77 100644 --- a/samples/client/petstore/typescript-angular-v4/npm/api/user.service.ts +++ b/samples/client/petstore/typescript-angular-v4/npm/api/user.service.ts @@ -25,6 +25,12 @@ import { User } from '../model/user'; import { BASE_PATH, COLLECTION_FORMATS } from '../variables'; import { Configuration } from '../configuration'; +type FormParams = HttpParams | URLSearchParams | FormData; + +function getAppender(useReturnValue = false) { + return (formParams: FormParams, param: string, value: any) => + useReturnValue ? formParams.append(param, value) : formParams.append(param, value), formParams; +} @Injectable() export class UserService { diff --git a/samples/client/petstore/typescript-angular-v5/npm/api/pet.service.ts b/samples/client/petstore/typescript-angular-v5/npm/api/pet.service.ts index 18563adb1b3..d3d36089ec3 100644 --- a/samples/client/petstore/typescript-angular-v5/npm/api/pet.service.ts +++ b/samples/client/petstore/typescript-angular-v5/npm/api/pet.service.ts @@ -24,6 +24,12 @@ import { Pet } from '../model/pet'; import { BASE_PATH, COLLECTION_FORMATS } from '../variables'; import { Configuration } from '../configuration'; +type FormParams = HttpParams | URLSearchParams | FormData; + +function getAppender(useReturnValue = false) { + return (formParams: FormParams, param: string, value: any) => + useReturnValue ? formParams.append(param, value) : formParams.append(param, value), formParams; +} @Injectable() export class PetService { @@ -68,6 +74,7 @@ export class PetService { public addPet(body: Pet, observe?: 'response', reportProgress?: boolean): Observable>; public addPet(body: Pet, observe?: 'events', reportProgress?: boolean): Observable>; public addPet(body: Pet, observe: any = 'body', reportProgress: boolean = false ): Observable { + if (body === null || body === undefined) { throw new Error('Required parameter body was null or undefined when calling addPet.'); } @@ -125,10 +132,12 @@ export class PetService { public deletePet(petId: number, apiKey?: string, observe?: 'response', reportProgress?: boolean): Observable>; public deletePet(petId: number, apiKey?: string, observe?: 'events', reportProgress?: boolean): Observable>; public deletePet(petId: number, apiKey?: string, observe: any = 'body', reportProgress: boolean = false ): Observable { + if (petId === null || petId === undefined) { throw new Error('Required parameter petId was null or undefined when calling deletePet.'); } + let headers = this.defaultHeaders; if (apiKey !== undefined && apiKey !== null) { headers = headers.set('api_key', String(apiKey)); @@ -177,6 +186,7 @@ export class PetService { public findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, observe?: 'response', reportProgress?: boolean): Observable>>; public findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, observe?: 'events', reportProgress?: boolean): Observable>>; public findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, observe: any = 'body', reportProgress: boolean = false ): Observable { + if (status === null || status === undefined) { throw new Error('Required parameter status was null or undefined when calling findPetsByStatus.'); } @@ -232,6 +242,7 @@ export class PetService { public findPetsByTags(tags: Array, observe?: 'response', reportProgress?: boolean): Observable>>; public findPetsByTags(tags: Array, observe?: 'events', reportProgress?: boolean): Observable>>; public findPetsByTags(tags: Array, observe: any = 'body', reportProgress: boolean = false ): Observable { + if (tags === null || tags === undefined) { throw new Error('Required parameter tags was null or undefined when calling findPetsByTags.'); } @@ -287,6 +298,7 @@ export class PetService { public getPetById(petId: number, observe?: 'response', reportProgress?: boolean): Observable>; public getPetById(petId: number, observe?: 'events', reportProgress?: boolean): Observable>; public getPetById(petId: number, observe: any = 'body', reportProgress: boolean = false ): Observable { + if (petId === null || petId === undefined) { throw new Error('Required parameter petId was null or undefined when calling getPetById.'); } @@ -333,6 +345,7 @@ export class PetService { public updatePet(body: Pet, observe?: 'response', reportProgress?: boolean): Observable>; public updatePet(body: Pet, observe?: 'events', reportProgress?: boolean): Observable>; public updatePet(body: Pet, observe: any = 'body', reportProgress: boolean = false ): Observable { + if (body === null || body === undefined) { throw new Error('Required parameter body was null or undefined when calling updatePet.'); } @@ -391,10 +404,13 @@ export class PetService { public updatePetWithForm(petId: number, name?: string, status?: string, observe?: 'response', reportProgress?: boolean): Observable>; public updatePetWithForm(petId: number, name?: string, status?: string, observe?: 'events', reportProgress?: boolean): Observable>; public updatePetWithForm(petId: number, name?: string, status?: string, observe: any = 'body', reportProgress: boolean = false ): Observable { + if (petId === null || petId === undefined) { throw new Error('Required parameter petId was null or undefined when calling updatePetWithForm.'); } + + let headers = this.defaultHeaders; // authentication (petstore_auth) required @@ -422,20 +438,21 @@ export class PetService { const canConsumeForm = this.canConsumeForm(consumes); - let formParams: { append(param: string, value: any): void; }; + let formParams: FormParams; + let append = getAppender(); let useForm = false; let convertFormParamsToString = false; if (useForm) { formParams = new FormData(); } else { formParams = new HttpParams({encoder: new CustomHttpUrlEncodingCodec()}); + append = getAppender(true); } - if (name !== undefined) { - formParams = formParams.append('name', name) || formParams; + formParams = append(formParams, 'name', name); } if (status !== undefined) { - formParams = formParams.append('status', status) || formParams; + formParams = append(formParams, 'status', status); } return this.httpClient.post(`${this.basePath}/pet/${encodeURIComponent(String(petId))}`, @@ -462,10 +479,13 @@ export class PetService { public uploadFile(petId: number, additionalMetadata?: string, file?: Blob, observe?: 'response', reportProgress?: boolean): Observable>; public uploadFile(petId: number, additionalMetadata?: string, file?: Blob, observe?: 'events', reportProgress?: boolean): Observable>; public uploadFile(petId: number, additionalMetadata?: string, file?: Blob, observe: any = 'body', reportProgress: boolean = false ): Observable { + if (petId === null || petId === undefined) { throw new Error('Required parameter petId was null or undefined when calling uploadFile.'); } + + let headers = this.defaultHeaders; // authentication (petstore_auth) required @@ -492,7 +512,8 @@ export class PetService { const canConsumeForm = this.canConsumeForm(consumes); - let formParams: { append(param: string, value: any): void; }; + let formParams: FormParams; + let append = getAppender(); let useForm = false; let convertFormParamsToString = false; // use FormData to transmit files using content-type "multipart/form-data" @@ -502,13 +523,13 @@ export class PetService { formParams = new FormData(); } else { formParams = new HttpParams({encoder: new CustomHttpUrlEncodingCodec()}); + append = getAppender(true); } - if (additionalMetadata !== undefined) { - formParams = formParams.append('additionalMetadata', additionalMetadata) || formParams; + formParams = append(formParams, 'additionalMetadata', additionalMetadata); } if (file !== undefined) { - formParams = formParams.append('file', file) || formParams; + formParams = append(formParams, 'file', file); } return this.httpClient.post(`${this.basePath}/pet/${encodeURIComponent(String(petId))}/uploadImage`, diff --git a/samples/client/petstore/typescript-angular-v5/npm/api/store.service.ts b/samples/client/petstore/typescript-angular-v5/npm/api/store.service.ts index 03016b73c9d..25241499b5b 100644 --- a/samples/client/petstore/typescript-angular-v5/npm/api/store.service.ts +++ b/samples/client/petstore/typescript-angular-v5/npm/api/store.service.ts @@ -23,6 +23,12 @@ import { Order } from '../model/order'; import { BASE_PATH, COLLECTION_FORMATS } from '../variables'; import { Configuration } from '../configuration'; +type FormParams = HttpParams | URLSearchParams | FormData; + +function getAppender(useReturnValue = false) { + return (formParams: FormParams, param: string, value: any) => + useReturnValue ? formParams.append(param, value) : formParams.append(param, value), formParams; +} @Injectable() export class StoreService { @@ -67,6 +73,7 @@ export class StoreService { public deleteOrder(orderId: string, observe?: 'response', reportProgress?: boolean): Observable>; public deleteOrder(orderId: string, observe?: 'events', reportProgress?: boolean): Observable>; public deleteOrder(orderId: string, observe: any = 'body', reportProgress: boolean = false ): Observable { + if (orderId === null || orderId === undefined) { throw new Error('Required parameter orderId was null or undefined when calling deleteOrder.'); } @@ -149,6 +156,7 @@ export class StoreService { public getOrderById(orderId: number, observe?: 'response', reportProgress?: boolean): Observable>; public getOrderById(orderId: number, observe?: 'events', reportProgress?: boolean): Observable>; public getOrderById(orderId: number, observe: any = 'body', reportProgress: boolean = false ): Observable { + if (orderId === null || orderId === undefined) { throw new Error('Required parameter orderId was null or undefined when calling getOrderById.'); } @@ -190,6 +198,7 @@ export class StoreService { public placeOrder(body: Order, observe?: 'response', reportProgress?: boolean): Observable>; public placeOrder(body: Order, observe?: 'events', reportProgress?: boolean): Observable>; public placeOrder(body: Order, observe: any = 'body', reportProgress: boolean = false ): Observable { + if (body === null || body === undefined) { throw new Error('Required parameter body was null or undefined when calling placeOrder.'); } diff --git a/samples/client/petstore/typescript-angular-v5/npm/api/user.service.ts b/samples/client/petstore/typescript-angular-v5/npm/api/user.service.ts index 7c7ccda2a79..26ace0707e5 100644 --- a/samples/client/petstore/typescript-angular-v5/npm/api/user.service.ts +++ b/samples/client/petstore/typescript-angular-v5/npm/api/user.service.ts @@ -23,6 +23,12 @@ import { User } from '../model/user'; import { BASE_PATH, COLLECTION_FORMATS } from '../variables'; import { Configuration } from '../configuration'; +type FormParams = HttpParams | URLSearchParams | FormData; + +function getAppender(useReturnValue = false) { + return (formParams: FormParams, param: string, value: any) => + useReturnValue ? formParams.append(param, value) : formParams.append(param, value), formParams; +} @Injectable() export class UserService { @@ -67,6 +73,7 @@ export class UserService { public createUser(body: User, observe?: 'response', reportProgress?: boolean): Observable>; public createUser(body: User, observe?: 'events', reportProgress?: boolean): Observable>; public createUser(body: User, observe: any = 'body', reportProgress: boolean = false ): Observable { + if (body === null || body === undefined) { throw new Error('Required parameter body was null or undefined when calling createUser.'); } @@ -113,6 +120,7 @@ export class UserService { public createUsersWithArrayInput(body: Array, observe?: 'response', reportProgress?: boolean): Observable>; public createUsersWithArrayInput(body: Array, observe?: 'events', reportProgress?: boolean): Observable>; public createUsersWithArrayInput(body: Array, observe: any = 'body', reportProgress: boolean = false ): Observable { + if (body === null || body === undefined) { throw new Error('Required parameter body was null or undefined when calling createUsersWithArrayInput.'); } @@ -159,6 +167,7 @@ export class UserService { public createUsersWithListInput(body: Array, observe?: 'response', reportProgress?: boolean): Observable>; public createUsersWithListInput(body: Array, observe?: 'events', reportProgress?: boolean): Observable>; public createUsersWithListInput(body: Array, observe: any = 'body', reportProgress: boolean = false ): Observable { + if (body === null || body === undefined) { throw new Error('Required parameter body was null or undefined when calling createUsersWithListInput.'); } @@ -205,6 +214,7 @@ export class UserService { public deleteUser(username: string, observe?: 'response', reportProgress?: boolean): Observable>; public deleteUser(username: string, observe?: 'events', reportProgress?: boolean): Observable>; public deleteUser(username: string, observe: any = 'body', reportProgress: boolean = false ): Observable { + if (username === null || username === undefined) { throw new Error('Required parameter username was null or undefined when calling deleteUser.'); } @@ -246,6 +256,7 @@ export class UserService { public getUserByName(username: string, observe?: 'response', reportProgress?: boolean): Observable>; public getUserByName(username: string, observe?: 'events', reportProgress?: boolean): Observable>; public getUserByName(username: string, observe: any = 'body', reportProgress: boolean = false ): Observable { + if (username === null || username === undefined) { throw new Error('Required parameter username was null or undefined when calling getUserByName.'); } @@ -288,9 +299,11 @@ export class UserService { public loginUser(username: string, password: string, observe?: 'response', reportProgress?: boolean): Observable>; public loginUser(username: string, password: string, observe?: 'events', reportProgress?: boolean): Observable>; public loginUser(username: string, password: string, observe: any = 'body', reportProgress: boolean = false ): Observable { + if (username === null || username === undefined) { throw new Error('Required parameter username was null or undefined when calling loginUser.'); } + if (password === null || password === undefined) { throw new Error('Required parameter password was null or undefined when calling loginUser.'); } @@ -379,9 +392,11 @@ export class UserService { public updateUser(username: string, body: User, observe?: 'response', reportProgress?: boolean): Observable>; public updateUser(username: string, body: User, observe?: 'events', reportProgress?: boolean): Observable>; public updateUser(username: string, body: User, observe: any = 'body', reportProgress: boolean = false ): Observable { + if (username === null || username === undefined) { throw new Error('Required parameter username was null or undefined when calling updateUser.'); } + if (body === null || body === undefined) { throw new Error('Required parameter body was null or undefined when calling updateUser.'); } diff --git a/samples/client/petstore/typescript-angular-v5/npm/model/amount.ts b/samples/client/petstore/typescript-angular-v5/npm/model/amount.ts new file mode 100644 index 00000000000..90fc5c01a30 --- /dev/null +++ b/samples/client/petstore/typescript-angular-v5/npm/model/amount.ts @@ -0,0 +1,24 @@ +/** + * Swagger Petstore + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ +import { Currency } from './currency'; + + +/** + * some description + */ +export interface Amount { + /** + * some description + */ + value: number; + currency: Currency; +} diff --git a/samples/client/petstore/typescript-angular-v5/npm/model/currency.ts b/samples/client/petstore/typescript-angular-v5/npm/model/currency.ts new file mode 100644 index 00000000000..c9ff596d4cb --- /dev/null +++ b/samples/client/petstore/typescript-angular-v5/npm/model/currency.ts @@ -0,0 +1,17 @@ +/** + * Swagger Petstore + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +/** + * some description + */ +export type Currency = string; diff --git a/samples/client/petstore/typescript-angular-v5/npm/model/models.ts b/samples/client/petstore/typescript-angular-v5/npm/model/models.ts index 8607c5dabd0..f6aebdbf709 100644 --- a/samples/client/petstore/typescript-angular-v5/npm/model/models.ts +++ b/samples/client/petstore/typescript-angular-v5/npm/model/models.ts @@ -1,5 +1,7 @@ +export * from './amount'; export * from './apiResponse'; export * from './category'; +export * from './currency'; export * from './order'; export * from './pet'; export * from './tag'; diff --git a/samples/client/petstore/typescript-angular-v5/with-interfaces/api/pet.service.ts b/samples/client/petstore/typescript-angular-v5/with-interfaces/api/pet.service.ts index a922b13249f..24542324765 100644 --- a/samples/client/petstore/typescript-angular-v5/with-interfaces/api/pet.service.ts +++ b/samples/client/petstore/typescript-angular-v5/with-interfaces/api/pet.service.ts @@ -25,6 +25,12 @@ import { BASE_PATH, COLLECTION_FORMATS } from '../variables' import { Configuration } from '../configuration'; import { PetServiceInterface } from './pet.serviceInterface'; +type FormParams = HttpParams | URLSearchParams | FormData; + +function getAppender(useReturnValue = false) { + return (formParams: FormParams, param: string, value: any) => + useReturnValue ? formParams.append(param, value) : formParams.append(param, value), formParams; +} @Injectable() export class PetService implements PetServiceInterface { @@ -433,20 +439,21 @@ export class PetService implements PetServiceInterface { const canConsumeForm = this.canConsumeForm(consumes); - let formParams: { append(param: string, value: any): void; }; + let formParams: FormParams; + let append = getAppender(); let useForm = false; let convertFormParamsToString = false; if (useForm) { formParams = new FormData(); } else { formParams = new HttpParams({encoder: new CustomHttpUrlEncodingCodec()}); + append = getAppender(true); } - if (name !== undefined) { - formParams = formParams.append('name', name) || formParams; + formParams = append(formParams, 'name', name); } if (status !== undefined) { - formParams = formParams.append('status', status) || formParams; + formParams = append(formParams, 'status', status); } return this.httpClient.post(`${this.basePath}/pet/${encodeURIComponent(String(petId))}`, @@ -506,7 +513,8 @@ export class PetService implements PetServiceInterface { const canConsumeForm = this.canConsumeForm(consumes); - let formParams: { append(param: string, value: any): void; }; + let formParams: FormParams; + let append = getAppender(); let useForm = false; let convertFormParamsToString = false; // use FormData to transmit files using content-type "multipart/form-data" @@ -516,13 +524,13 @@ export class PetService implements PetServiceInterface { formParams = new FormData(); } else { formParams = new HttpParams({encoder: new CustomHttpUrlEncodingCodec()}); + append = getAppender(true); } - if (additionalMetadata !== undefined) { - formParams = formParams.append('additionalMetadata', additionalMetadata) || formParams; + formParams = append(formParams, 'additionalMetadata', additionalMetadata); } if (file !== undefined) { - formParams = formParams.append('file', file) || formParams; + formParams = append(formParams, 'file', file); } return this.httpClient.post(`${this.basePath}/pet/${encodeURIComponent(String(petId))}/uploadImage`, diff --git a/samples/client/petstore/typescript-angular-v5/with-interfaces/api/store.service.ts b/samples/client/petstore/typescript-angular-v5/with-interfaces/api/store.service.ts index 271fabb7ba8..59abfbfb980 100644 --- a/samples/client/petstore/typescript-angular-v5/with-interfaces/api/store.service.ts +++ b/samples/client/petstore/typescript-angular-v5/with-interfaces/api/store.service.ts @@ -24,6 +24,12 @@ import { BASE_PATH, COLLECTION_FORMATS } from '../variables' import { Configuration } from '../configuration'; import { StoreServiceInterface } from './store.serviceInterface'; +type FormParams = HttpParams | URLSearchParams | FormData; + +function getAppender(useReturnValue = false) { + return (formParams: FormParams, param: string, value: any) => + useReturnValue ? formParams.append(param, value) : formParams.append(param, value), formParams; +} @Injectable() export class StoreService implements StoreServiceInterface { diff --git a/samples/client/petstore/typescript-angular-v5/with-interfaces/api/user.service.ts b/samples/client/petstore/typescript-angular-v5/with-interfaces/api/user.service.ts index 491402e119a..5cf120e6431 100644 --- a/samples/client/petstore/typescript-angular-v5/with-interfaces/api/user.service.ts +++ b/samples/client/petstore/typescript-angular-v5/with-interfaces/api/user.service.ts @@ -24,6 +24,12 @@ import { BASE_PATH, COLLECTION_FORMATS } from '../variables' import { Configuration } from '../configuration'; import { UserServiceInterface } from './user.serviceInterface'; +type FormParams = HttpParams | URLSearchParams | FormData; + +function getAppender(useReturnValue = false) { + return (formParams: FormParams, param: string, value: any) => + useReturnValue ? formParams.append(param, value) : formParams.append(param, value), formParams; +} @Injectable() export class UserService implements UserServiceInterface { diff --git a/samples/client/petstore/typescript-angular-v6/npm/api/pet.service.ts b/samples/client/petstore/typescript-angular-v6/npm/api/pet.service.ts index d62314aefe5..caef4a0d383 100644 --- a/samples/client/petstore/typescript-angular-v6/npm/api/pet.service.ts +++ b/samples/client/petstore/typescript-angular-v6/npm/api/pet.service.ts @@ -24,6 +24,12 @@ import { Pet } from '../model/pet'; import { BASE_PATH, COLLECTION_FORMATS } from '../variables'; import { Configuration } from '../configuration'; +type FormParams = HttpParams | URLSearchParams | FormData; + +function getAppender(useReturnValue = false) { + return (formParams: FormParams, param: string, value: any) => + useReturnValue ? formParams.append(param, value) : formParams.append(param, value), formParams; +} @Injectable() export class PetService { @@ -68,6 +74,7 @@ export class PetService { public addPet(body: Pet, observe?: 'response', reportProgress?: boolean): Observable>; public addPet(body: Pet, observe?: 'events', reportProgress?: boolean): Observable>; public addPet(body: Pet, observe: any = 'body', reportProgress: boolean = false ): Observable { + if (body === null || body === undefined) { throw new Error('Required parameter body was null or undefined when calling addPet.'); } @@ -125,10 +132,12 @@ export class PetService { public deletePet(petId: number, apiKey?: string, observe?: 'response', reportProgress?: boolean): Observable>; public deletePet(petId: number, apiKey?: string, observe?: 'events', reportProgress?: boolean): Observable>; public deletePet(petId: number, apiKey?: string, observe: any = 'body', reportProgress: boolean = false ): Observable { + if (petId === null || petId === undefined) { throw new Error('Required parameter petId was null or undefined when calling deletePet.'); } + let headers = this.defaultHeaders; if (apiKey !== undefined && apiKey !== null) { headers = headers.set('api_key', String(apiKey)); @@ -177,6 +186,7 @@ export class PetService { public findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, observe?: 'response', reportProgress?: boolean): Observable>>; public findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, observe?: 'events', reportProgress?: boolean): Observable>>; public findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, observe: any = 'body', reportProgress: boolean = false ): Observable { + if (status === null || status === undefined) { throw new Error('Required parameter status was null or undefined when calling findPetsByStatus.'); } @@ -232,6 +242,7 @@ export class PetService { public findPetsByTags(tags: Array, observe?: 'response', reportProgress?: boolean): Observable>>; public findPetsByTags(tags: Array, observe?: 'events', reportProgress?: boolean): Observable>>; public findPetsByTags(tags: Array, observe: any = 'body', reportProgress: boolean = false ): Observable { + if (tags === null || tags === undefined) { throw new Error('Required parameter tags was null or undefined when calling findPetsByTags.'); } @@ -287,6 +298,7 @@ export class PetService { public getPetById(petId: number, observe?: 'response', reportProgress?: boolean): Observable>; public getPetById(petId: number, observe?: 'events', reportProgress?: boolean): Observable>; public getPetById(petId: number, observe: any = 'body', reportProgress: boolean = false ): Observable { + if (petId === null || petId === undefined) { throw new Error('Required parameter petId was null or undefined when calling getPetById.'); } @@ -333,6 +345,7 @@ export class PetService { public updatePet(body: Pet, observe?: 'response', reportProgress?: boolean): Observable>; public updatePet(body: Pet, observe?: 'events', reportProgress?: boolean): Observable>; public updatePet(body: Pet, observe: any = 'body', reportProgress: boolean = false ): Observable { + if (body === null || body === undefined) { throw new Error('Required parameter body was null or undefined when calling updatePet.'); } @@ -391,10 +404,13 @@ export class PetService { public updatePetWithForm(petId: number, name?: string, status?: string, observe?: 'response', reportProgress?: boolean): Observable>; public updatePetWithForm(petId: number, name?: string, status?: string, observe?: 'events', reportProgress?: boolean): Observable>; public updatePetWithForm(petId: number, name?: string, status?: string, observe: any = 'body', reportProgress: boolean = false ): Observable { + if (petId === null || petId === undefined) { throw new Error('Required parameter petId was null or undefined when calling updatePetWithForm.'); } + + let headers = this.defaultHeaders; // authentication (petstore_auth) required @@ -422,20 +438,21 @@ export class PetService { const canConsumeForm = this.canConsumeForm(consumes); - let formParams: { append(param: string, value: any): void; }; + let formParams: FormParams; + let append = getAppender(); let useForm = false; let convertFormParamsToString = false; if (useForm) { formParams = new FormData(); } else { formParams = new HttpParams({encoder: new CustomHttpUrlEncodingCodec()}); + append = getAppender(true); } - if (name !== undefined) { - formParams = formParams.append('name', name) || formParams; + formParams = append(formParams, 'name', name); } if (status !== undefined) { - formParams = formParams.append('status', status) || formParams; + formParams = append(formParams, 'status', status); } return this.httpClient.post(`${this.basePath}/pet/${encodeURIComponent(String(petId))}`, @@ -462,10 +479,13 @@ export class PetService { public uploadFile(petId: number, additionalMetadata?: string, file?: Blob, observe?: 'response', reportProgress?: boolean): Observable>; public uploadFile(petId: number, additionalMetadata?: string, file?: Blob, observe?: 'events', reportProgress?: boolean): Observable>; public uploadFile(petId: number, additionalMetadata?: string, file?: Blob, observe: any = 'body', reportProgress: boolean = false ): Observable { + if (petId === null || petId === undefined) { throw new Error('Required parameter petId was null or undefined when calling uploadFile.'); } + + let headers = this.defaultHeaders; // authentication (petstore_auth) required @@ -492,7 +512,8 @@ export class PetService { const canConsumeForm = this.canConsumeForm(consumes); - let formParams: { append(param: string, value: any): void; }; + let formParams: FormParams; + let append = getAppender(); let useForm = false; let convertFormParamsToString = false; // use FormData to transmit files using content-type "multipart/form-data" @@ -502,13 +523,13 @@ export class PetService { formParams = new FormData(); } else { formParams = new HttpParams({encoder: new CustomHttpUrlEncodingCodec()}); + append = getAppender(true); } - if (additionalMetadata !== undefined) { - formParams = formParams.append('additionalMetadata', additionalMetadata) || formParams; + formParams = append(formParams, 'additionalMetadata', additionalMetadata); } if (file !== undefined) { - formParams = formParams.append('file', file) || formParams; + formParams = append(formParams, 'file', file); } return this.httpClient.post(`${this.basePath}/pet/${encodeURIComponent(String(petId))}/uploadImage`, diff --git a/samples/client/petstore/typescript-angular-v6/npm/api/store.service.ts b/samples/client/petstore/typescript-angular-v6/npm/api/store.service.ts index c8e83fb6416..372f5fe1bd7 100644 --- a/samples/client/petstore/typescript-angular-v6/npm/api/store.service.ts +++ b/samples/client/petstore/typescript-angular-v6/npm/api/store.service.ts @@ -23,6 +23,12 @@ import { Order } from '../model/order'; import { BASE_PATH, COLLECTION_FORMATS } from '../variables'; import { Configuration } from '../configuration'; +type FormParams = HttpParams | URLSearchParams | FormData; + +function getAppender(useReturnValue = false) { + return (formParams: FormParams, param: string, value: any) => + useReturnValue ? formParams.append(param, value) : formParams.append(param, value), formParams; +} @Injectable() export class StoreService { @@ -67,6 +73,7 @@ export class StoreService { public deleteOrder(orderId: string, observe?: 'response', reportProgress?: boolean): Observable>; public deleteOrder(orderId: string, observe?: 'events', reportProgress?: boolean): Observable>; public deleteOrder(orderId: string, observe: any = 'body', reportProgress: boolean = false ): Observable { + if (orderId === null || orderId === undefined) { throw new Error('Required parameter orderId was null or undefined when calling deleteOrder.'); } @@ -149,6 +156,7 @@ export class StoreService { public getOrderById(orderId: number, observe?: 'response', reportProgress?: boolean): Observable>; public getOrderById(orderId: number, observe?: 'events', reportProgress?: boolean): Observable>; public getOrderById(orderId: number, observe: any = 'body', reportProgress: boolean = false ): Observable { + if (orderId === null || orderId === undefined) { throw new Error('Required parameter orderId was null or undefined when calling getOrderById.'); } @@ -190,6 +198,7 @@ export class StoreService { public placeOrder(body: Order, observe?: 'response', reportProgress?: boolean): Observable>; public placeOrder(body: Order, observe?: 'events', reportProgress?: boolean): Observable>; public placeOrder(body: Order, observe: any = 'body', reportProgress: boolean = false ): Observable { + if (body === null || body === undefined) { throw new Error('Required parameter body was null or undefined when calling placeOrder.'); } diff --git a/samples/client/petstore/typescript-angular-v6/npm/api/user.service.ts b/samples/client/petstore/typescript-angular-v6/npm/api/user.service.ts index c6ea28aa921..acb0066d250 100644 --- a/samples/client/petstore/typescript-angular-v6/npm/api/user.service.ts +++ b/samples/client/petstore/typescript-angular-v6/npm/api/user.service.ts @@ -23,6 +23,12 @@ import { User } from '../model/user'; import { BASE_PATH, COLLECTION_FORMATS } from '../variables'; import { Configuration } from '../configuration'; +type FormParams = HttpParams | URLSearchParams | FormData; + +function getAppender(useReturnValue = false) { + return (formParams: FormParams, param: string, value: any) => + useReturnValue ? formParams.append(param, value) : formParams.append(param, value), formParams; +} @Injectable() export class UserService { @@ -67,6 +73,7 @@ export class UserService { public createUser(body: User, observe?: 'response', reportProgress?: boolean): Observable>; public createUser(body: User, observe?: 'events', reportProgress?: boolean): Observable>; public createUser(body: User, observe: any = 'body', reportProgress: boolean = false ): Observable { + if (body === null || body === undefined) { throw new Error('Required parameter body was null or undefined when calling createUser.'); } @@ -113,6 +120,7 @@ export class UserService { public createUsersWithArrayInput(body: Array, observe?: 'response', reportProgress?: boolean): Observable>; public createUsersWithArrayInput(body: Array, observe?: 'events', reportProgress?: boolean): Observable>; public createUsersWithArrayInput(body: Array, observe: any = 'body', reportProgress: boolean = false ): Observable { + if (body === null || body === undefined) { throw new Error('Required parameter body was null or undefined when calling createUsersWithArrayInput.'); } @@ -159,6 +167,7 @@ export class UserService { public createUsersWithListInput(body: Array, observe?: 'response', reportProgress?: boolean): Observable>; public createUsersWithListInput(body: Array, observe?: 'events', reportProgress?: boolean): Observable>; public createUsersWithListInput(body: Array, observe: any = 'body', reportProgress: boolean = false ): Observable { + if (body === null || body === undefined) { throw new Error('Required parameter body was null or undefined when calling createUsersWithListInput.'); } @@ -205,6 +214,7 @@ export class UserService { public deleteUser(username: string, observe?: 'response', reportProgress?: boolean): Observable>; public deleteUser(username: string, observe?: 'events', reportProgress?: boolean): Observable>; public deleteUser(username: string, observe: any = 'body', reportProgress: boolean = false ): Observable { + if (username === null || username === undefined) { throw new Error('Required parameter username was null or undefined when calling deleteUser.'); } @@ -246,6 +256,7 @@ export class UserService { public getUserByName(username: string, observe?: 'response', reportProgress?: boolean): Observable>; public getUserByName(username: string, observe?: 'events', reportProgress?: boolean): Observable>; public getUserByName(username: string, observe: any = 'body', reportProgress: boolean = false ): Observable { + if (username === null || username === undefined) { throw new Error('Required parameter username was null or undefined when calling getUserByName.'); } @@ -288,9 +299,11 @@ export class UserService { public loginUser(username: string, password: string, observe?: 'response', reportProgress?: boolean): Observable>; public loginUser(username: string, password: string, observe?: 'events', reportProgress?: boolean): Observable>; public loginUser(username: string, password: string, observe: any = 'body', reportProgress: boolean = false ): Observable { + if (username === null || username === undefined) { throw new Error('Required parameter username was null or undefined when calling loginUser.'); } + if (password === null || password === undefined) { throw new Error('Required parameter password was null or undefined when calling loginUser.'); } @@ -379,9 +392,11 @@ export class UserService { public updateUser(username: string, body: User, observe?: 'response', reportProgress?: boolean): Observable>; public updateUser(username: string, body: User, observe?: 'events', reportProgress?: boolean): Observable>; public updateUser(username: string, body: User, observe: any = 'body', reportProgress: boolean = false ): Observable { + if (username === null || username === undefined) { throw new Error('Required parameter username was null or undefined when calling updateUser.'); } + if (body === null || body === undefined) { throw new Error('Required parameter body was null or undefined when calling updateUser.'); } diff --git a/samples/client/petstore/typescript-angular-v6/npm/model/amount.ts b/samples/client/petstore/typescript-angular-v6/npm/model/amount.ts new file mode 100644 index 00000000000..90fc5c01a30 --- /dev/null +++ b/samples/client/petstore/typescript-angular-v6/npm/model/amount.ts @@ -0,0 +1,24 @@ +/** + * Swagger Petstore + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ +import { Currency } from './currency'; + + +/** + * some description + */ +export interface Amount { + /** + * some description + */ + value: number; + currency: Currency; +} diff --git a/samples/client/petstore/typescript-angular-v6/npm/model/currency.ts b/samples/client/petstore/typescript-angular-v6/npm/model/currency.ts new file mode 100644 index 00000000000..c9ff596d4cb --- /dev/null +++ b/samples/client/petstore/typescript-angular-v6/npm/model/currency.ts @@ -0,0 +1,17 @@ +/** + * Swagger Petstore + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +/** + * some description + */ +export type Currency = string; diff --git a/samples/client/petstore/typescript-angular-v6/npm/model/models.ts b/samples/client/petstore/typescript-angular-v6/npm/model/models.ts index 8607c5dabd0..f6aebdbf709 100644 --- a/samples/client/petstore/typescript-angular-v6/npm/model/models.ts +++ b/samples/client/petstore/typescript-angular-v6/npm/model/models.ts @@ -1,5 +1,7 @@ +export * from './amount'; export * from './apiResponse'; export * from './category'; +export * from './currency'; export * from './order'; export * from './pet'; export * from './tag';