From ced6e0502ec53031efa0a043924f7fe7e4b2691e Mon Sep 17 00:00:00 2001 From: Atsushi Hanaoka Date: Thu, 6 Dec 2018 18:10:45 +0900 Subject: [PATCH] [typescript] Avoid strictNullChecks errors for apiKeys (#1611) * [typescript] Avoid strictNullChecks errors for apiKeys fix #1607 * Run ./bin/{LANG}-petstore.sh - ./bin/typescript-angular-petstore-all.sh - ./bin/typescript-inversify-petstore.sh * Run ./bin/security/{LANG}-petstore.sh - ./bin/security/typescript-angular.sh - ./bin/security/typescript-angular2.sh - ./bin/security/typescript-inversify.sh * [typescript] Fix parameter name sanitization * Fix invalid consumes of petstore-security-test.yaml * Run ./bin/security/typescript-*.sh --- .../AbstractTypeScriptClientCodegen.java | 2 +- .../typescript-angular/api.service.mustache | 4 +- .../typescript-inversify/api.service.mustache | 4 +- .../TypeScriptNodeClientCodegenTest.java | 1 + .../resources/2_0/petstore-security-test.yaml | 3 +- .../.openapi-generator/VERSION | 2 +- .../typescript-angular/README.md | 23 +- .../typescript-angular/api.module.ts | 2 +- .../typescript-angular/api/fake.service.ts | 42 ++- .../typescript-angular/configuration.ts | 18 +- .../typescript-angular/git_push.sh | 2 +- .../typescript-angular/model/models.ts | 2 +- .../typescript-angular/model/return.ts | 22 ++ .../.openapi-generator/VERSION | 2 +- .../typescript-angular2/README.md | 23 +- .../typescript-angular2/api.module.ts | 2 +- .../typescript-angular2/api/fake.service.ts | 42 ++- .../typescript-angular2/configuration.ts | 18 +- .../typescript-angular2/git_push.sh | 2 +- .../typescript-angular2/model/models.ts | 2 +- .../typescript-angular2/model/return.ts | 22 ++ .../.openapi-generator/VERSION | 2 +- .../typescript-fetch/apis/FakeApi.ts | 56 ++++ .../typescript-fetch/apis/index.ts | 1 + .../typescript-fetch/index.ts | 19 +- .../typescript-fetch/models/Return.ts | 44 +++ .../typescript-fetch/models/index.ts | 1 + .../typescript-fetch/runtime.ts | 267 ++++++++++++++++++ .../typescript-fetch/tsconfig.json | 17 ++ .../.openapi-generator/VERSION | 2 +- .../typescript-inversify/api/fake.service.ts | 14 +- .../typescript-inversify/model/return.ts | 22 ++ .../.openapi-generator/VERSION | 2 +- .../typescript-node/api/fakeApi.ts | 13 +- .../typescript-node/model/models.ts | 8 +- .../typescript-node/model/return.ts | 36 +++ .../default/api/pet.service.ts | 2 +- .../default/api/store.service.ts | 2 +- .../npm/api/pet.service.ts | 2 +- .../npm/api/store.service.ts | 2 +- .../with-interfaces/api/pet.service.ts | 2 +- .../with-interfaces/api/store.service.ts | 2 +- .../npm/api/pet.service.ts | 2 +- .../npm/api/store.service.ts | 2 +- .../npm/api/pet.service.ts | 2 +- .../npm/api/store.service.ts | 2 +- .../builds/default/api/pet.service.ts | 2 +- .../builds/default/api/store.service.ts | 2 +- .../builds/with-npm/api/pet.service.ts | 2 +- .../builds/with-npm/api/store.service.ts | 2 +- .../builds/default/api/pet.service.ts | 2 +- .../builds/default/api/store.service.ts | 2 +- .../builds/with-npm/api/pet.service.ts | 2 +- .../builds/with-npm/api/store.service.ts | 2 +- .../typescript-inversify/api/pet.service.ts | 2 +- .../typescript-inversify/api/store.service.ts | 2 +- 56 files changed, 636 insertions(+), 148 deletions(-) create mode 100644 samples/client/petstore-security-test/typescript-angular/model/return.ts create mode 100644 samples/client/petstore-security-test/typescript-angular2/model/return.ts create mode 100644 samples/client/petstore-security-test/typescript-fetch/apis/FakeApi.ts create mode 100644 samples/client/petstore-security-test/typescript-fetch/apis/index.ts create mode 100644 samples/client/petstore-security-test/typescript-fetch/models/Return.ts create mode 100644 samples/client/petstore-security-test/typescript-fetch/models/index.ts create mode 100644 samples/client/petstore-security-test/typescript-fetch/runtime.ts create mode 100644 samples/client/petstore-security-test/typescript-fetch/tsconfig.json create mode 100644 samples/client/petstore-security-test/typescript-inversify/model/return.ts create mode 100644 samples/client/petstore-security-test/typescript-node/model/return.ts diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractTypeScriptClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractTypeScriptClientCodegen.java index 6e178de0cc..c6a81150c0 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractTypeScriptClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractTypeScriptClientCodegen.java @@ -161,7 +161,7 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp @Override public String toParamName(String name) { // sanitize name - name = sanitizeName(name, "\\W-[\\$]"); + name = sanitizeName(name, "[^\\w$]"); if ("_".equals(name)) { name = "_u"; diff --git a/modules/openapi-generator/src/main/resources/typescript-angular/api.service.mustache b/modules/openapi-generator/src/main/resources/typescript-angular/api.service.mustache index 55a115fff3..aa403a86ec 100644 --- a/modules/openapi-generator/src/main/resources/typescript-angular/api.service.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-angular/api.service.mustache @@ -192,13 +192,13 @@ export class {{classname}} { // authentication ({{name}}) required {{#isApiKey}} {{#isKeyInHeader}} - if (this.configuration.apiKeys["{{keyParamName}}"]) { + if (this.configuration.apiKeys && this.configuration.apiKeys["{{keyParamName}}"]) { {{#useHttpClient}}headers = {{/useHttpClient}}headers.set('{{keyParamName}}', this.configuration.apiKeys["{{keyParamName}}"]); } {{/isKeyInHeader}} {{#isKeyInQuery}} - if (this.configuration.apiKeys["{{keyParamName}}"]) { + if (this.configuration.apiKeys && this.configuration.apiKeys["{{keyParamName}}"]) { {{#useHttpClient}}queryParameters = {{/useHttpClient}}queryParameters.set('{{keyParamName}}', this.configuration.apiKeys["{{keyParamName}}"]); } diff --git a/modules/openapi-generator/src/main/resources/typescript-inversify/api.service.mustache b/modules/openapi-generator/src/main/resources/typescript-inversify/api.service.mustache index 2595837557..703a3d0573 100644 --- a/modules/openapi-generator/src/main/resources/typescript-inversify/api.service.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-inversify/api.service.mustache @@ -106,12 +106,12 @@ export class {{classname}} { // authentication ({{name}}) required {{#isApiKey}} {{#isKeyInHeader}} - if (this.APIConfiguration.apiKeys["{{keyParamName}}"]) { + if (this.APIConfiguration.apiKeys && this.APIConfiguration.apiKeys["{{keyParamName}}"]) { headers['{{keyParamName}}'] = this.APIConfiguration.apiKeys["{{keyParamName}}"]; } {{/isKeyInHeader}} {{#isKeyInQuery}} - if (this.APIConfiguration.apiKeys["{{keyParamName}}"]) { + if (this.APIConfiguration.apiKeys && this.APIConfiguration.apiKeys["{{keyParamName}}"]) { queryParameters.push("{{paramName}}="+encodeURIComponent(String(this.APIConfiguration.apiKeys["{{keyParamName}}"]))); } {{/isKeyInQuery}} diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/typescriptnode/TypeScriptNodeClientCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/typescriptnode/TypeScriptNodeClientCodegenTest.java index 5183502601..908249e27f 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/typescriptnode/TypeScriptNodeClientCodegenTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/typescriptnode/TypeScriptNodeClientCodegenTest.java @@ -15,5 +15,6 @@ public class TypeScriptNodeClientCodegenTest { Assert.assertEquals(codegen.toVarName("user-name"), "userName"); Assert.assertEquals(codegen.toVarName("user_name"), "userName"); Assert.assertEquals(codegen.toVarName("user|name"), "userName"); + Assert.assertEquals(codegen.toVarName("user !\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~name"), "user$Name"); } } diff --git a/modules/openapi-generator/src/test/resources/2_0/petstore-security-test.yaml b/modules/openapi-generator/src/test/resources/2_0/petstore-security-test.yaml index f1400ad8c6..1a9f63770f 100644 --- a/modules/openapi-generator/src/test/resources/2_0/petstore-security-test.yaml +++ b/modules/openapi-generator/src/test/resources/2_0/petstore-security-test.yaml @@ -28,8 +28,7 @@ paths: description: To test code injection */ ' " =end -- \r\n \n \r operationId: testCodeInject */ ' " =end -- \r\n \n \r consumes: - - application/json - - "*/ ' \" =end -- \r\n \n \r" + - application/x-www-form-urlencoded produces: - application/json - "*/ ' \" =end -- \r\n \n \r" diff --git a/samples/client/petstore-security-test/typescript-angular/.openapi-generator/VERSION b/samples/client/petstore-security-test/typescript-angular/.openapi-generator/VERSION index 855ff9501e..afa6365606 100644 --- a/samples/client/petstore-security-test/typescript-angular/.openapi-generator/VERSION +++ b/samples/client/petstore-security-test/typescript-angular/.openapi-generator/VERSION @@ -1 +1 @@ -2.4.0-SNAPSHOT \ No newline at end of file +4.0.0-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 f679bcb132..b6c812a56e 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 @@ -10,11 +10,11 @@ npm run build ### publishing -First build the package than run ```npm publish``` +First build the package then 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: @@ -94,8 +101,8 @@ export class AppComponent { Note: The ApiModule is restricted to being instantiated once app wide. This is to ensure that all services are treated as singletons. -#### Using multiple swagger files / APIs / ApiModules -In order to use multiple `ApiModules` generated from different swagger files, +#### Using multiple OpenAPI files / APIs / ApiModules +In order to use multiple `ApiModules` generated from different OpenAPI files, you can create an alias name when importing the modules in order to avoid naming conflicts: ``` @@ -168,4 +175,4 @@ import { environment } from '../environments/environment'; bootstrap: [ AppComponent ] }) export class AppModule { } -``` \ No newline at end of file +``` 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 a95cda2523..867cee5c7b 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 d0047d78be..8f290b5e08 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 @@ -1,12 +1,12 @@ /** - * Swagger Petstore *_/ ' \" =end -- \\r\\n \\n \\r + * OpenAPI Petstore *_/ ' \" =end -- \\r\\n \\n \\r * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end -- * * OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r - * Contact: apiteam@swagger.io *_/ ' \" =end -- \\r\\n \\n \\r + * Contact: something@something.abc *_/ ' \" =end -- \\r\\n \\n \\r * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech * Do not edit the class manually. */ /* tslint:disable:no-unused-variable member-ordering */ @@ -26,17 +26,18 @@ import { Configuration } from '../configurat @Injectable() export class FakeService { - protected basePath = 'https://petstore.swagger.io *_/ ' \" =end -- \\r\\n \\n \\r/v2 *_/ ' \" =end -- \\r\\n \\n \\r'; + protected basePath = 'http://petstore.swagger.io *_/ ' \" =end -- \\r\\n \\n \\r/v2 *_/ ' \" =end -- \\r\\n \\n \\r'; public defaultHeaders = new HttpHeaders(); public configuration = new Configuration(); constructor(protected httpClient: HttpClient, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) { - if (basePath) { - this.basePath = basePath; - } + if (configuration) { this.configuration = configuration; - this.basePath = basePath || configuration.basePath || this.basePath; + this.configuration.basePath = configuration.basePath || basePath || this.basePath; + + } else { + this.configuration.basePath = basePath || this.basePath; } } @@ -46,7 +47,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; } @@ -57,8 +58,8 @@ export class FakeService { /** * To test code injection *_/ ' \" =end -- \\r\\n \\n \\r - * - * @param testCodeInjectEndRnNR To test code injection *_/ ' \" =end -- \\r\\n \\n \\r + * To test code injection *_/ ' \" =end -- \\r\\n \\n \\r + * @param testCodeInjectEndRnNR To test code injection *_/ ' \\\" =end -- \\\\r\\\\n \\\\n \\\\r * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. * @param reportProgress flag to report request and response progress. */ @@ -71,23 +72,20 @@ export class FakeService { // to determine the Accept header let httpHeaderAccepts: string[] = [ - 'application/json', - '*_/ =end -- ' ]; - let httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts); - if (httpHeaderAcceptSelected != undefined) { - headers = headers.set("Accept", httpHeaderAcceptSelected); + const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts); + if (httpHeaderAcceptSelected !== undefined) { + headers = headers.set('Accept', httpHeaderAcceptSelected); } // to determine the Content-Type header - let consumes: string[] = [ - 'application/json', - '*_/ =end -- ' + const consumes: string[] = [ + 'application/x-www-form-urlencoded' ]; const canConsumeForm = this.canConsumeForm(consumes); - let formParams: { append(param: string, value: any): void; }; + let formParams: { append(param: string, value: any): any; }; let useForm = false; let convertFormParamsToString = false; if (useForm) { @@ -100,7 +98,7 @@ export class FakeService { formParams = formParams.append('test code inject */ ' " =end -- \r\n \n \r', testCodeInjectEndRnNR) || formParams; } - return this.httpClient.put(`${this.basePath}/fake`, + return this.httpClient.put(`${this.configuration.basePath}/fake`, convertFormParamsToString ? formParams.toString() : formParams, { withCredentials: this.configuration.withCredentials, diff --git a/samples/client/petstore-security-test/typescript-angular/configuration.ts b/samples/client/petstore-security-test/typescript-angular/configuration.ts index 2ee1824f5f..5dac132393 100644 --- a/samples/client/petstore-security-test/typescript-angular/configuration.ts +++ b/samples/client/petstore-security-test/typescript-angular/configuration.ts @@ -28,11 +28,11 @@ 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) { + if (contentTypes.length === 0) { return undefined; } @@ -47,11 +47,11 @@ 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) { + if (accepts.length === 0) { return undefined; } @@ -69,11 +69,11 @@ 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'); - return mime != null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json'); + return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json'); } } diff --git a/samples/client/petstore-security-test/typescript-angular/git_push.sh b/samples/client/petstore-security-test/typescript-angular/git_push.sh index ae01b182ae..8442b80bb4 100644 --- a/samples/client/petstore-security-test/typescript-angular/git_push.sh +++ b/samples/client/petstore-security-test/typescript-angular/git_push.sh @@ -1,7 +1,7 @@ #!/bin/sh # ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ # -# Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update" +# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" git_user_id=$1 git_repo_id=$2 diff --git a/samples/client/petstore-security-test/typescript-angular/model/models.ts b/samples/client/petstore-security-test/typescript-angular/model/models.ts index bca4c78d6b..472428482c 100644 --- a/samples/client/petstore-security-test/typescript-angular/model/models.ts +++ b/samples/client/petstore-security-test/typescript-angular/model/models.ts @@ -1 +1 @@ -export * from './modelReturn'; +export * from './return'; diff --git a/samples/client/petstore-security-test/typescript-angular/model/return.ts b/samples/client/petstore-security-test/typescript-angular/model/return.ts new file mode 100644 index 0000000000..442d1b5a10 --- /dev/null +++ b/samples/client/petstore-security-test/typescript-angular/model/return.ts @@ -0,0 +1,22 @@ +/** + * OpenAPI Petstore *_/ ' \" =end -- \\r\\n \\n \\r + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end -- + * + * OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r + * Contact: something@something.abc *_/ ' \" =end -- \\r\\n \\n \\r + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +/** + * Model for testing reserved words *_/ ' \" =end -- \\r\\n \\n \\r + */ +export interface Return { + /** + * property description *_/ ' \" =end -- \\r\\n \\n \\r + */ + _return?: number; +} diff --git a/samples/client/petstore-security-test/typescript-angular2/.openapi-generator/VERSION b/samples/client/petstore-security-test/typescript-angular2/.openapi-generator/VERSION index 855ff9501e..afa6365606 100644 --- a/samples/client/petstore-security-test/typescript-angular2/.openapi-generator/VERSION +++ b/samples/client/petstore-security-test/typescript-angular2/.openapi-generator/VERSION @@ -1 +1 @@ -2.4.0-SNAPSHOT \ No newline at end of file +4.0.0-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore-security-test/typescript-angular2/README.md b/samples/client/petstore-security-test/typescript-angular2/README.md index f679bcb132..b6c812a56e 100644 --- a/samples/client/petstore-security-test/typescript-angular2/README.md +++ b/samples/client/petstore-security-test/typescript-angular2/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 @@ -10,11 +10,11 @@ npm run build ### publishing -First build the package than run ```npm publish``` +First build the package then 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: @@ -94,8 +101,8 @@ export class AppComponent { Note: The ApiModule is restricted to being instantiated once app wide. This is to ensure that all services are treated as singletons. -#### Using multiple swagger files / APIs / ApiModules -In order to use multiple `ApiModules` generated from different swagger files, +#### Using multiple OpenAPI files / APIs / ApiModules +In order to use multiple `ApiModules` generated from different OpenAPI files, you can create an alias name when importing the modules in order to avoid naming conflicts: ``` @@ -168,4 +175,4 @@ import { environment } from '../environments/environment'; bootstrap: [ AppComponent ] }) export class AppModule { } -``` \ No newline at end of file +``` diff --git a/samples/client/petstore-security-test/typescript-angular2/api.module.ts b/samples/client/petstore-security-test/typescript-angular2/api.module.ts index a95cda2523..867cee5c7b 100644 --- a/samples/client/petstore-security-test/typescript-angular2/api.module.ts +++ b/samples/client/petstore-security-test/typescript-angular2/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-angular2/api/fake.service.ts b/samples/client/petstore-security-test/typescript-angular2/api/fake.service.ts index d0047d78be..8f290b5e08 100644 --- a/samples/client/petstore-security-test/typescript-angular2/api/fake.service.ts +++ b/samples/client/petstore-security-test/typescript-angular2/api/fake.service.ts @@ -1,12 +1,12 @@ /** - * Swagger Petstore *_/ ' \" =end -- \\r\\n \\n \\r + * OpenAPI Petstore *_/ ' \" =end -- \\r\\n \\n \\r * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end -- * * OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r - * Contact: apiteam@swagger.io *_/ ' \" =end -- \\r\\n \\n \\r + * Contact: something@something.abc *_/ ' \" =end -- \\r\\n \\n \\r * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech * Do not edit the class manually. */ /* tslint:disable:no-unused-variable member-ordering */ @@ -26,17 +26,18 @@ import { Configuration } from '../configurat @Injectable() export class FakeService { - protected basePath = 'https://petstore.swagger.io *_/ ' \" =end -- \\r\\n \\n \\r/v2 *_/ ' \" =end -- \\r\\n \\n \\r'; + protected basePath = 'http://petstore.swagger.io *_/ ' \" =end -- \\r\\n \\n \\r/v2 *_/ ' \" =end -- \\r\\n \\n \\r'; public defaultHeaders = new HttpHeaders(); public configuration = new Configuration(); constructor(protected httpClient: HttpClient, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) { - if (basePath) { - this.basePath = basePath; - } + if (configuration) { this.configuration = configuration; - this.basePath = basePath || configuration.basePath || this.basePath; + this.configuration.basePath = configuration.basePath || basePath || this.basePath; + + } else { + this.configuration.basePath = basePath || this.basePath; } } @@ -46,7 +47,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; } @@ -57,8 +58,8 @@ export class FakeService { /** * To test code injection *_/ ' \" =end -- \\r\\n \\n \\r - * - * @param testCodeInjectEndRnNR To test code injection *_/ ' \" =end -- \\r\\n \\n \\r + * To test code injection *_/ ' \" =end -- \\r\\n \\n \\r + * @param testCodeInjectEndRnNR To test code injection *_/ ' \\\" =end -- \\\\r\\\\n \\\\n \\\\r * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. * @param reportProgress flag to report request and response progress. */ @@ -71,23 +72,20 @@ export class FakeService { // to determine the Accept header let httpHeaderAccepts: string[] = [ - 'application/json', - '*_/ =end -- ' ]; - let httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts); - if (httpHeaderAcceptSelected != undefined) { - headers = headers.set("Accept", httpHeaderAcceptSelected); + const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts); + if (httpHeaderAcceptSelected !== undefined) { + headers = headers.set('Accept', httpHeaderAcceptSelected); } // to determine the Content-Type header - let consumes: string[] = [ - 'application/json', - '*_/ =end -- ' + const consumes: string[] = [ + 'application/x-www-form-urlencoded' ]; const canConsumeForm = this.canConsumeForm(consumes); - let formParams: { append(param: string, value: any): void; }; + let formParams: { append(param: string, value: any): any; }; let useForm = false; let convertFormParamsToString = false; if (useForm) { @@ -100,7 +98,7 @@ export class FakeService { formParams = formParams.append('test code inject */ ' " =end -- \r\n \n \r', testCodeInjectEndRnNR) || formParams; } - return this.httpClient.put(`${this.basePath}/fake`, + return this.httpClient.put(`${this.configuration.basePath}/fake`, convertFormParamsToString ? formParams.toString() : formParams, { withCredentials: this.configuration.withCredentials, diff --git a/samples/client/petstore-security-test/typescript-angular2/configuration.ts b/samples/client/petstore-security-test/typescript-angular2/configuration.ts index 2ee1824f5f..5dac132393 100644 --- a/samples/client/petstore-security-test/typescript-angular2/configuration.ts +++ b/samples/client/petstore-security-test/typescript-angular2/configuration.ts @@ -28,11 +28,11 @@ 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) { + if (contentTypes.length === 0) { return undefined; } @@ -47,11 +47,11 @@ 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) { + if (accepts.length === 0) { return undefined; } @@ -69,11 +69,11 @@ 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'); - return mime != null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json'); + return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json'); } } diff --git a/samples/client/petstore-security-test/typescript-angular2/git_push.sh b/samples/client/petstore-security-test/typescript-angular2/git_push.sh index ae01b182ae..8442b80bb4 100644 --- a/samples/client/petstore-security-test/typescript-angular2/git_push.sh +++ b/samples/client/petstore-security-test/typescript-angular2/git_push.sh @@ -1,7 +1,7 @@ #!/bin/sh # ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ # -# Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update" +# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" git_user_id=$1 git_repo_id=$2 diff --git a/samples/client/petstore-security-test/typescript-angular2/model/models.ts b/samples/client/petstore-security-test/typescript-angular2/model/models.ts index bca4c78d6b..472428482c 100644 --- a/samples/client/petstore-security-test/typescript-angular2/model/models.ts +++ b/samples/client/petstore-security-test/typescript-angular2/model/models.ts @@ -1 +1 @@ -export * from './modelReturn'; +export * from './return'; diff --git a/samples/client/petstore-security-test/typescript-angular2/model/return.ts b/samples/client/petstore-security-test/typescript-angular2/model/return.ts new file mode 100644 index 0000000000..442d1b5a10 --- /dev/null +++ b/samples/client/petstore-security-test/typescript-angular2/model/return.ts @@ -0,0 +1,22 @@ +/** + * OpenAPI Petstore *_/ ' \" =end -- \\r\\n \\n \\r + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end -- + * + * OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r + * Contact: something@something.abc *_/ ' \" =end -- \\r\\n \\n \\r + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +/** + * Model for testing reserved words *_/ ' \" =end -- \\r\\n \\n \\r + */ +export interface Return { + /** + * property description *_/ ' \" =end -- \\r\\n \\n \\r + */ + _return?: number; +} diff --git a/samples/client/petstore-security-test/typescript-fetch/.openapi-generator/VERSION b/samples/client/petstore-security-test/typescript-fetch/.openapi-generator/VERSION index 0f58aa0414..afa6365606 100644 --- a/samples/client/petstore-security-test/typescript-fetch/.openapi-generator/VERSION +++ b/samples/client/petstore-security-test/typescript-fetch/.openapi-generator/VERSION @@ -1 +1 @@ -3.1.2-SNAPSHOT \ No newline at end of file +4.0.0-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore-security-test/typescript-fetch/apis/FakeApi.ts b/samples/client/petstore-security-test/typescript-fetch/apis/FakeApi.ts new file mode 100644 index 0000000000..9e35a8e6dd --- /dev/null +++ b/samples/client/petstore-security-test/typescript-fetch/apis/FakeApi.ts @@ -0,0 +1,56 @@ +// tslint:disable +/** + * OpenAPI Petstore *_/ ' \" =end -- \\r\\n \\n \\r + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end -- + * + * OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r + * Contact: something@something.abc *_/ ' \" =end -- \\r\\n \\n \\r + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +import * as runtime from '../runtime'; + +export interface TestCodeInjectEndRnNRRequest { + testCodeInjectEndRnNR?: string; +} + +/** + * no description + */ +export class FakeApi extends runtime.BaseAPI { + + /** + * To test code injection *_/ ' \" =end -- \\r\\n \\n \\r + * To test code injection *_/ ' \" =end -- \\r\\n \\n \\r + */ + async testCodeInjectEndRnNRRaw(requestParameters: TestCodeInjectEndRnNRRequest): Promise> { + const headerParameters: runtime.HTTPHeaders = {}; + + const formData = new FormData(); + if (requestParameters.testCodeInjectEndRnNR !== undefined) { + formData.append('test code inject */ ' " =end -- \r\n \n \r', requestParameters.testCodeInjectEndRnNR as any); + } + + const response = await this.request({ + path: `/fake`, + method: 'PUT', + headers: headerParameters, + body: formData, + }); + + return new runtime.VoidApiResponse(response); + } + + /** + * To test code injection *_/ ' \" =end -- \\r\\n \\n \\r + * To test code injection *_/ ' \" =end -- \\r\\n \\n \\r + */ + async testCodeInjectEndRnNR(requestParameters: TestCodeInjectEndRnNRRequest): Promise { + await this.testCodeInjectEndRnNRRaw(requestParameters); + } + +} diff --git a/samples/client/petstore-security-test/typescript-fetch/apis/index.ts b/samples/client/petstore-security-test/typescript-fetch/apis/index.ts new file mode 100644 index 0000000000..9525ab8512 --- /dev/null +++ b/samples/client/petstore-security-test/typescript-fetch/apis/index.ts @@ -0,0 +1 @@ +export * from './FakeApi'; diff --git a/samples/client/petstore-security-test/typescript-fetch/index.ts b/samples/client/petstore-security-test/typescript-fetch/index.ts index 06529df41e..848ecfa4d1 100644 --- a/samples/client/petstore-security-test/typescript-fetch/index.ts +++ b/samples/client/petstore-security-test/typescript-fetch/index.ts @@ -1,16 +1,3 @@ -// tslint:disable -/** - * OpenAPI Petstore *_/ ' \" =end -- \\r\\n \\n \\r - * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end -- - * - * OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r - * Contact: something@something.abc *_/ ' \" =end -- \\r\\n \\n \\r - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - - -export * from "./api"; -export * from "./configuration"; +export * from './runtime'; +export * from './apis'; +export * from './models'; diff --git a/samples/client/petstore-security-test/typescript-fetch/models/Return.ts b/samples/client/petstore-security-test/typescript-fetch/models/Return.ts new file mode 100644 index 0000000000..2c7c5bde63 --- /dev/null +++ b/samples/client/petstore-security-test/typescript-fetch/models/Return.ts @@ -0,0 +1,44 @@ +// tslint:disable +/** + * OpenAPI Petstore *_/ ' \" =end -- \\r\\n \\n \\r + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end -- + * + * OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r + * Contact: something@something.abc *_/ ' \" =end -- \\r\\n \\n \\r + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists } from '../runtime'; +/** + * Model for testing reserved words *_/ ' \" =end -- \\r\\n \\n \\r + * @export + * @interface Return + */ +export interface Return { + /** + * property description *_/ ' \" =end -- \\r\\n \\n \\r + * @type {number} + * @memberof Return + */ + _return?: number; +} + +export function ReturnFromJSON(json: any): Return { + return { + '_return': !exists(json, 'return') ? undefined : json['return'], + }; +} + +export function ReturnToJSON(value?: Return): any { + if (value === undefined) { + return undefined; + } + return { + 'return': value._return, + }; +} + + diff --git a/samples/client/petstore-security-test/typescript-fetch/models/index.ts b/samples/client/petstore-security-test/typescript-fetch/models/index.ts new file mode 100644 index 0000000000..8d45f62a1d --- /dev/null +++ b/samples/client/petstore-security-test/typescript-fetch/models/index.ts @@ -0,0 +1 @@ +export * from './Return'; diff --git a/samples/client/petstore-security-test/typescript-fetch/runtime.ts b/samples/client/petstore-security-test/typescript-fetch/runtime.ts new file mode 100644 index 0000000000..95664acaf5 --- /dev/null +++ b/samples/client/petstore-security-test/typescript-fetch/runtime.ts @@ -0,0 +1,267 @@ +// tslint:disable +/** + * OpenAPI Petstore *_/ ' \" =end -- \\r\\n \\n \\r + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end -- + * + * OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r + * Contact: something@something.abc *_/ ' \" =end -- \\r\\n \\n \\r + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +export const BASE_PATH = "http://petstore.swagger.io *_/ ' \" =end -- \\r\\n \\n \\r/v2 *_/ ' \" =end -- \\r\\n \\n \\r".replace(/\/+$/, ""); + +/** + * This is the base class for all generated API classes. + */ +export class BaseAPI { + + private middleware: Middleware[]; + + constructor(protected configuration = new Configuration()) { + this.middleware = configuration.middleware; + } + + withMiddleware(this: T, ...middlewares: Middleware[]) { + const next = this.clone(); + next.middleware = next.middleware.concat(...middlewares); + return next; + } + + withPreMiddleware(this: T, ...preMiddlewares: Array) { + const middlewares = preMiddlewares.map((pre) => ({ pre })); + return this.withMiddleware(...middlewares); + } + + withPostMiddleware(this: T, ...postMiddlewares: Array) { + const middlewares = postMiddlewares.map((post) => ({ post })); + return this.withMiddleware(...middlewares); + } + + protected async request(context: RequestOpts): Promise { + const { url, init } = this.createFetchParams(context); + const response = await this.fetchApi(url, init); + if (response.status >= 200 && response.status < 300) { + return response; + } + throw response; + } + + private createFetchParams(context: RequestOpts) { + let url = this.configuration.basePath + context.path; + if (context.query !== undefined && Object.keys(context.query).length !== 0) { + // only add the querystring to the URL if there are query parameters. + // this is done to avoid urls ending with a "?" character which buggy webservers + // do not handle correctly sometimes. + url += '?' + querystring(context.query); + } + const body = context.body instanceof FormData ? context.body : JSON.stringify(context.body); + const init = { + method: context.method, + headers: context.headers, + body, + }; + return { url, init }; + } + + private fetchApi = async (url: string, init: RequestInit) => { + let fetchParams = { url, init }; + for (const middleware of this.middleware) { + if (middleware.pre) { + fetchParams = await middleware.pre({ + fetch: this.fetchApi, + ...fetchParams, + }) || fetchParams; + } + } + let response = await this.configuration.fetchApi(fetchParams.url, fetchParams.init); + for (const middleware of this.middleware) { + if (middleware.post) { + response = await middleware.post({ + fetch: this.fetchApi, + url, + init, + response: response.clone(), + }) || response; + } + } + return response; + } + + /** + * Create a shallow clone of `this` by constructing a new instance + * and then shallow cloning data members. + */ + private clone(this: T): T { + const constructor = this.constructor as any; + const next = new constructor(this.configuration); + next.middleware = this.middleware.slice(); + return next; + } +}; + +export class RequiredError extends Error { + name: "RequiredError" = "RequiredError"; + constructor(public field: string, msg?: string) { + super(msg); + } +} + +export const COLLECTION_FORMATS = { + csv: ",", + ssv: " ", + tsv: "\t", + pipes: "|", +}; + +export type FetchAPI = GlobalFetch['fetch']; + +export interface ConfigurationParameters { + basePath?: string; // override base path + fetchApi?: FetchAPI; // override for fetch implementation + middleware?: Middleware[]; // middleware to apply before/after fetch requests + username?: string; // parameter for basic security + password?: string; // parameter for basic security + apiKey?: string | ((name: string) => string); // parameter for apiKey security + accessToken?: string | ((name: string, scopes?: string[]) => string); // parameter for oauth2 security +} + +export class Configuration { + constructor(private configuration: ConfigurationParameters = {}) {} + + get basePath(): string { + return this.configuration.basePath || BASE_PATH; + } + + get fetchApi(): FetchAPI { + return this.configuration.fetchApi || window.fetch.bind(window); + } + + get middleware(): Middleware[] { + return this.configuration.middleware || []; + } + + get username(): string | undefined { + return this.configuration.username; + } + + get password(): string | undefined { + return this.configuration.password; + } + + get apiKey(): ((name: string) => string) | undefined { + const apiKey = this.configuration.apiKey; + if (apiKey) { + return typeof apiKey === 'function' ? apiKey : () => apiKey; + } + return undefined; + } + + get accessToken(): ((name: string, scopes?: string[]) => string) | undefined { + const accessToken = this.configuration.accessToken; + if (accessToken) { + return typeof accessToken === 'function' ? accessToken : () => accessToken; + } + return undefined; + } +} + +export type Json = any; +export type HTTPMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS'; +export type HTTPHeaders = { [key: string]: string }; +export type HTTPQuery = { [key: string]: string | number | null | boolean | Array }; +export type HTTPBody = Json | FormData; +export type ModelPropertyNaming = 'camelCase' | 'snake_case' | 'PascalCase' | 'original'; + +export interface FetchParams { + url: string; + init: RequestInit; +} + +export interface RequestOpts { + path: string; + method: HTTPMethod; + headers: HTTPHeaders; + query?: HTTPQuery; + body?: HTTPBody; +} + +export function exists(json: any, key: string) { + const value = json[key]; + return value !== null && value !== undefined; +} + +export function querystring(params: HTTPQuery) { + return Object.keys(params) + .map((key) => { + const value = params[key]; + if (value instanceof Array) { + const multiValue = value.join(`&${encodeURIComponent(key)}=`); + return `${encodeURIComponent(key)}=${multiValue}`; + } + return `${encodeURIComponent(key)}=${encodeURIComponent(String(value))}` + }) + .join('&'); +} + +export interface RequestContext { + fetch: FetchAPI; + url: string; + init: RequestInit; +} + +export interface ResponseContext { + fetch: FetchAPI; + url: string; + init: RequestInit; + response: Response; +} + +export interface Middleware { + pre?(context: RequestContext): Promise; + post?(context: ResponseContext): Promise; +} + +export interface ApiResponse { + raw: Response; + value(): Promise; +} + +export interface ResponseTransformer { + (json: any): T; +} + +export class JSONApiResponse { + constructor(public raw: Response, private transformer: ResponseTransformer = (jsonValue: any) => jsonValue) {} + + async value() { + return this.transformer(await this.raw.json()); + } +} + +export class VoidApiResponse { + constructor(public raw: Response) {} + + async value() { + return undefined; + } +} + +export class BlobApiResponse { + constructor(public raw: Response) {} + + async value() { + return await this.raw.blob(); + }; +} + +export class TextApiResponse { + constructor(public raw: Response) {} + + async value() { + return await this.raw.text(); + }; +} diff --git a/samples/client/petstore-security-test/typescript-fetch/tsconfig.json b/samples/client/petstore-security-test/typescript-fetch/tsconfig.json new file mode 100644 index 0000000000..5a7e3c1935 --- /dev/null +++ b/samples/client/petstore-security-test/typescript-fetch/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "declaration": true, + "target": "es5", + "module": "commonjs", + "outDir": "dist", + "rootDir": ".", + "lib": [ + "es6", + "dom" + ] + }, + "exclude": [ + "dist", + "node_modules" + ] +} diff --git a/samples/client/petstore-security-test/typescript-inversify/.openapi-generator/VERSION b/samples/client/petstore-security-test/typescript-inversify/.openapi-generator/VERSION index 855ff9501e..afa6365606 100644 --- a/samples/client/petstore-security-test/typescript-inversify/.openapi-generator/VERSION +++ b/samples/client/petstore-security-test/typescript-inversify/.openapi-generator/VERSION @@ -1 +1 @@ -2.4.0-SNAPSHOT \ No newline at end of file +4.0.0-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore-security-test/typescript-inversify/api/fake.service.ts b/samples/client/petstore-security-test/typescript-inversify/api/fake.service.ts index 418d247b15..f3bf6b579e 100644 --- a/samples/client/petstore-security-test/typescript-inversify/api/fake.service.ts +++ b/samples/client/petstore-security-test/typescript-inversify/api/fake.service.ts @@ -1,12 +1,12 @@ /** - * Swagger Petstore *_/ ' \" =end -- \\r\\n \\n \\r + * OpenAPI Petstore *_/ ' \" =end -- \\r\\n \\n \\r * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end -- * * OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r - * Contact: apiteam@swagger.io *_/ ' \" =end -- \\r\\n \\n \\r + * Contact: something@something.abc *_/ ' \" =end -- \\r\\n \\n \\r * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech * Do not edit the class manually. */ /* tslint:disable:no-unused-variable member-ordering */ @@ -27,7 +27,7 @@ import { COLLECTION_FORMATS } from '../variables'; @injectable() export class FakeService { - private basePath: string = 'https://petstore.swagger.io *_/ ' \" =end -- \\r\\n \\n \\r/v2 *_/ ' \" =end -- \\r\\n \\n \\r'; + private basePath: string = 'http://petstore.swagger.io *_/ ' \" =end -- \\r\\n \\n \\r/v2 *_/ ' \" =end -- \\r\\n \\n \\r'; constructor(@inject("IApiHttpClient") private httpClient: IHttpClient, @inject("IAPIConfiguration") private APIConfiguration: IAPIConfiguration ) { @@ -37,8 +37,8 @@ export class FakeService { /** * To test code injection *_/ ' \" =end -- \\r\\n \\n \\r - * - * @param testCodeInjectEndRnNR To test code injection *_/ ' \" =end -- \\r\\n \\n \\r + * To test code injection *_/ ' \" =end -- \\r\\n \\n \\r + * @param testCodeInjectEndRnNR To test code injection *_/ ' \\\" =end -- \\\\r\\\\n \\\\n \\\\r */ public testCodeInjectEndRnNR(testCodeInjectEndRnNR?: string, observe?: 'body', headers?: Headers): Observable; diff --git a/samples/client/petstore-security-test/typescript-inversify/model/return.ts b/samples/client/petstore-security-test/typescript-inversify/model/return.ts new file mode 100644 index 0000000000..442d1b5a10 --- /dev/null +++ b/samples/client/petstore-security-test/typescript-inversify/model/return.ts @@ -0,0 +1,22 @@ +/** + * OpenAPI Petstore *_/ ' \" =end -- \\r\\n \\n \\r + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end -- + * + * OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r + * Contact: something@something.abc *_/ ' \" =end -- \\r\\n \\n \\r + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +/** + * Model for testing reserved words *_/ ' \" =end -- \\r\\n \\n \\r + */ +export interface Return { + /** + * property description *_/ ' \" =end -- \\r\\n \\n \\r + */ + _return?: number; +} diff --git a/samples/client/petstore-security-test/typescript-node/.openapi-generator/VERSION b/samples/client/petstore-security-test/typescript-node/.openapi-generator/VERSION index 82602aa419..afa6365606 100644 --- a/samples/client/petstore-security-test/typescript-node/.openapi-generator/VERSION +++ b/samples/client/petstore-security-test/typescript-node/.openapi-generator/VERSION @@ -1 +1 @@ -3.0.3-SNAPSHOT \ No newline at end of file +4.0.0-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore-security-test/typescript-node/api/fakeApi.ts b/samples/client/petstore-security-test/typescript-node/api/fakeApi.ts index e40f35702d..ce68adb739 100644 --- a/samples/client/petstore-security-test/typescript-node/api/fakeApi.ts +++ b/samples/client/petstore-security-test/typescript-node/api/fakeApi.ts @@ -18,7 +18,7 @@ import Promise = require('bluebird'); import { ObjectSerializer, Authentication, HttpBasicAuth, ApiKeyAuth, OAuth, VoidAuth } from '../model/models'; -let defaultBasePath = 'petstore.swagger.io *_/ ' \" =end -- \\r\\n \\n \\r/v2 *_/ ' \" =end -- \\r\\n \\n \\r'; +let defaultBasePath = 'http://petstore.swagger.io *_/ ' \" =end -- \\r\\n \\n \\r/v2 *_/ ' \" =end -- \\r\\n \\n \\r'; // =============================================== // This file is autogenerated - Please do not edit @@ -70,11 +70,11 @@ export class FakeApi { } /** - * + * To test code injection *_/ ' \" =end -- \\r\\n \\n \\r * @summary To test code injection *_/ ' \" =end -- \\r\\n \\n \\r - * @param UNKNOWN_BASE_TYPE + * @param testCodeInjectEndRnNR To test code injection *_/ ' \\\" =end -- \\\\r\\\\n \\\\n \\\\r */ - public testCodeInjectEndRnNR (UNKNOWN_BASE_TYPE?: any) : Promise<{ response: http.ClientResponse; body?: any; }> { + public testCodeInjectEndRnNR (testCodeInjectEndRnNR?: string) : Promise<{ response: http.ClientResponse; body?: any; }> { const localVarPath = this.basePath + '/fake'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -83,6 +83,10 @@ export class FakeApi { let localVarUseFormData = false; + if (testCodeInjectEndRnNR !== undefined) { + localVarFormParams['test code inject */ ' " =end -- \r\n \n \r'] = ObjectSerializer.serialize(testCodeInjectEndRnNR, "string"); + } + let localVarRequestOptions: localVarRequest.Options = { method: 'PUT', qs: localVarQueryParameters, @@ -90,7 +94,6 @@ export class FakeApi { uri: localVarPath, useQuerystring: this._useQuerystring, json: true, - body: ObjectSerializer.serialize(UNKNOWN_BASE_TYPE, "any") }; this.authentications.default.applyToRequest(localVarRequestOptions); diff --git a/samples/client/petstore-security-test/typescript-node/model/models.ts b/samples/client/petstore-security-test/typescript-node/model/models.ts index 37288a0f18..b278ea07e6 100644 --- a/samples/client/petstore-security-test/typescript-node/model/models.ts +++ b/samples/client/petstore-security-test/typescript-node/model/models.ts @@ -1,8 +1,8 @@ -export * from './modelReturn'; +export * from './return'; import localVarRequest = require('request'); -import { ModelReturn } from './modelReturn'; +import { Return } from './return'; /* tslint:disable:no-unused-variable */ let primitives = [ @@ -20,7 +20,7 @@ let enumsMap: {[index: string]: any} = { } let typeMap: {[index: string]: any} = { - "ModelReturn": ModelReturn, + "Return": Return, } export class ObjectSerializer { @@ -74,7 +74,7 @@ export class ObjectSerializer { } return transformedData; } else if (type === "Date") { - return data.toString(); + return data.toISOString(); } else { if (enumsMap[type]) { return data; diff --git a/samples/client/petstore-security-test/typescript-node/model/return.ts b/samples/client/petstore-security-test/typescript-node/model/return.ts new file mode 100644 index 0000000000..1f8181f239 --- /dev/null +++ b/samples/client/petstore-security-test/typescript-node/model/return.ts @@ -0,0 +1,36 @@ +/** + * OpenAPI Petstore *_/ ' \" =end -- \\r\\n \\n \\r + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end -- + * + * OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r + * Contact: something@something.abc *_/ ' \" =end -- \\r\\n \\n \\r + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +/** +* Model for testing reserved words *_/ ' \" =end -- \\r\\n \\n \\r +*/ +export class Return { + /** + * property description *_/ ' \" =end -- \\r\\n \\n \\r + */ + '_return'?: number; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "_return", + "baseName": "return", + "type": "number" + } ]; + + static getAttributeTypeMap() { + return Return.attributeTypeMap; + } +} + 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 6692083bc3..f15094ee11 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 @@ -418,7 +418,7 @@ export class PetService { let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845 // authentication (api_key) required - if (this.configuration.apiKeys["api_key"]) { + if (this.configuration.apiKeys && this.configuration.apiKeys["api_key"]) { headers.set('api_key', this.configuration.apiKeys["api_key"]); } 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 01ad2dd7e3..53e52d1acc 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 @@ -170,7 +170,7 @@ export class StoreService { let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845 // authentication (api_key) required - if (this.configuration.apiKeys["api_key"]) { + if (this.configuration.apiKeys && this.configuration.apiKeys["api_key"]) { headers.set('api_key', this.configuration.apiKeys["api_key"]); } 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 6692083bc3..f15094ee11 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 @@ -418,7 +418,7 @@ export class PetService { let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845 // authentication (api_key) required - if (this.configuration.apiKeys["api_key"]) { + if (this.configuration.apiKeys && this.configuration.apiKeys["api_key"]) { headers.set('api_key', this.configuration.apiKeys["api_key"]); } 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 01ad2dd7e3..53e52d1acc 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 @@ -170,7 +170,7 @@ export class StoreService { let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845 // authentication (api_key) required - if (this.configuration.apiKeys["api_key"]) { + if (this.configuration.apiKeys && this.configuration.apiKeys["api_key"]) { headers.set('api_key', this.configuration.apiKeys["api_key"]); } 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 ce0fff0717..8b5a9dc9b1 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 @@ -419,7 +419,7 @@ export class PetService implements PetServiceInterface { let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845 // authentication (api_key) required - if (this.configuration.apiKeys["api_key"]) { + if (this.configuration.apiKeys && this.configuration.apiKeys["api_key"]) { headers.set('api_key', this.configuration.apiKeys["api_key"]); } 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 8a09472ef0..14a080468e 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 @@ -171,7 +171,7 @@ export class StoreService implements StoreServiceInterface { let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845 // authentication (api_key) required - if (this.configuration.apiKeys["api_key"]) { + if (this.configuration.apiKeys && this.configuration.apiKeys["api_key"]) { headers.set('api_key', this.configuration.apiKeys["api_key"]); } 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 a982e41956..b8859f688a 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 @@ -291,7 +291,7 @@ export class PetService { let headers = this.defaultHeaders; // authentication (api_key) required - if (this.configuration.apiKeys["api_key"]) { + if (this.configuration.apiKeys && this.configuration.apiKeys["api_key"]) { headers = headers.set('api_key', this.configuration.apiKeys["api_key"]); } 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 460e1e5904..225138a71f 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 @@ -110,7 +110,7 @@ export class StoreService { let headers = this.defaultHeaders; // authentication (api_key) required - if (this.configuration.apiKeys["api_key"]) { + if (this.configuration.apiKeys && this.configuration.apiKeys["api_key"]) { headers = headers.set('api_key', this.configuration.apiKeys["api_key"]); } 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 6692083bc3..f15094ee11 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 @@ -418,7 +418,7 @@ export class PetService { let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845 // authentication (api_key) required - if (this.configuration.apiKeys["api_key"]) { + if (this.configuration.apiKeys && this.configuration.apiKeys["api_key"]) { headers.set('api_key', this.configuration.apiKeys["api_key"]); } 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 01ad2dd7e3..53e52d1acc 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 @@ -170,7 +170,7 @@ export class StoreService { let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845 // authentication (api_key) required - if (this.configuration.apiKeys["api_key"]) { + if (this.configuration.apiKeys && this.configuration.apiKeys["api_key"]) { headers.set('api_key', this.configuration.apiKeys["api_key"]); } diff --git a/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/default/api/pet.service.ts b/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/default/api/pet.service.ts index 82575f519a..b434fd2cd1 100644 --- a/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/default/api/pet.service.ts +++ b/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/default/api/pet.service.ts @@ -291,7 +291,7 @@ export class PetService { let headers = this.defaultHeaders; // authentication (api_key) required - if (this.configuration.apiKeys["api_key"]) { + if (this.configuration.apiKeys && this.configuration.apiKeys["api_key"]) { headers = headers.set('api_key', this.configuration.apiKeys["api_key"]); } diff --git a/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/default/api/store.service.ts b/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/default/api/store.service.ts index 1f1abb0b9e..b1e7651cc8 100644 --- a/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/default/api/store.service.ts +++ b/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/default/api/store.service.ts @@ -110,7 +110,7 @@ export class StoreService { let headers = this.defaultHeaders; // authentication (api_key) required - if (this.configuration.apiKeys["api_key"]) { + if (this.configuration.apiKeys && this.configuration.apiKeys["api_key"]) { headers = headers.set('api_key', this.configuration.apiKeys["api_key"]); } diff --git a/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/with-npm/api/pet.service.ts b/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/with-npm/api/pet.service.ts index 82575f519a..b434fd2cd1 100644 --- a/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/with-npm/api/pet.service.ts +++ b/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/with-npm/api/pet.service.ts @@ -291,7 +291,7 @@ export class PetService { let headers = this.defaultHeaders; // authentication (api_key) required - if (this.configuration.apiKeys["api_key"]) { + if (this.configuration.apiKeys && this.configuration.apiKeys["api_key"]) { headers = headers.set('api_key', this.configuration.apiKeys["api_key"]); } diff --git a/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/with-npm/api/store.service.ts b/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/with-npm/api/store.service.ts index 1f1abb0b9e..b1e7651cc8 100644 --- a/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/with-npm/api/store.service.ts +++ b/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/with-npm/api/store.service.ts @@ -110,7 +110,7 @@ export class StoreService { let headers = this.defaultHeaders; // authentication (api_key) required - if (this.configuration.apiKeys["api_key"]) { + if (this.configuration.apiKeys && this.configuration.apiKeys["api_key"]) { headers = headers.set('api_key', this.configuration.apiKeys["api_key"]); } diff --git a/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/default/api/pet.service.ts b/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/default/api/pet.service.ts index e002c9a15c..3da62e0e5f 100644 --- a/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/default/api/pet.service.ts +++ b/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/default/api/pet.service.ts @@ -293,7 +293,7 @@ export class PetService { let headers = this.defaultHeaders; // authentication (api_key) required - if (this.configuration.apiKeys["api_key"]) { + if (this.configuration.apiKeys && this.configuration.apiKeys["api_key"]) { headers = headers.set('api_key', this.configuration.apiKeys["api_key"]); } diff --git a/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/default/api/store.service.ts b/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/default/api/store.service.ts index cae817406d..efe62c694a 100644 --- a/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/default/api/store.service.ts +++ b/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/default/api/store.service.ts @@ -112,7 +112,7 @@ export class StoreService { let headers = this.defaultHeaders; // authentication (api_key) required - if (this.configuration.apiKeys["api_key"]) { + if (this.configuration.apiKeys && this.configuration.apiKeys["api_key"]) { headers = headers.set('api_key', this.configuration.apiKeys["api_key"]); } diff --git a/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/with-npm/api/pet.service.ts b/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/with-npm/api/pet.service.ts index e002c9a15c..3da62e0e5f 100644 --- a/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/with-npm/api/pet.service.ts +++ b/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/with-npm/api/pet.service.ts @@ -293,7 +293,7 @@ export class PetService { let headers = this.defaultHeaders; // authentication (api_key) required - if (this.configuration.apiKeys["api_key"]) { + if (this.configuration.apiKeys && this.configuration.apiKeys["api_key"]) { headers = headers.set('api_key', this.configuration.apiKeys["api_key"]); } diff --git a/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/with-npm/api/store.service.ts b/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/with-npm/api/store.service.ts index cae817406d..efe62c694a 100644 --- a/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/with-npm/api/store.service.ts +++ b/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/with-npm/api/store.service.ts @@ -112,7 +112,7 @@ export class StoreService { let headers = this.defaultHeaders; // authentication (api_key) required - if (this.configuration.apiKeys["api_key"]) { + if (this.configuration.apiKeys && this.configuration.apiKeys["api_key"]) { headers = headers.set('api_key', this.configuration.apiKeys["api_key"]); } diff --git a/samples/client/petstore/typescript-inversify/api/pet.service.ts b/samples/client/petstore/typescript-inversify/api/pet.service.ts index 34879a5c4d..2846274530 100644 --- a/samples/client/petstore/typescript-inversify/api/pet.service.ts +++ b/samples/client/petstore/typescript-inversify/api/pet.service.ts @@ -187,7 +187,7 @@ export class PetService { } // authentication (api_key) required - if (this.APIConfiguration.apiKeys["api_key"]) { + if (this.APIConfiguration.apiKeys && this.APIConfiguration.apiKeys["api_key"]) { headers['api_key'] = this.APIConfiguration.apiKeys["api_key"]; } headers['Accept'] = 'application/xml'; diff --git a/samples/client/petstore/typescript-inversify/api/store.service.ts b/samples/client/petstore/typescript-inversify/api/store.service.ts index 45e65c489b..f72d5bf1f2 100644 --- a/samples/client/petstore/typescript-inversify/api/store.service.ts +++ b/samples/client/petstore/typescript-inversify/api/store.service.ts @@ -68,7 +68,7 @@ export class StoreService { public getInventory(observe?: 'response', headers?: Headers): Observable>; public getInventory(observe: any = 'body', headers: Headers = {}): Observable { // authentication (api_key) required - if (this.APIConfiguration.apiKeys["api_key"]) { + if (this.APIConfiguration.apiKeys && this.APIConfiguration.apiKeys["api_key"]) { headers['api_key'] = this.APIConfiguration.apiKeys["api_key"]; } headers['Accept'] = 'application/json';