[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
This commit is contained in:
Atsushi Hanaoka 2018-12-06 18:10:45 +09:00 committed by William Cheng
parent 314b4cc54f
commit ced6e0502e
56 changed files with 636 additions and 148 deletions

View File

@ -161,7 +161,7 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
@Override @Override
public String toParamName(String name) { public String toParamName(String name) {
// sanitize name // sanitize name
name = sanitizeName(name, "\\W-[\\$]"); name = sanitizeName(name, "[^\\w$]");
if ("_".equals(name)) { if ("_".equals(name)) {
name = "_u"; name = "_u";

View File

@ -192,13 +192,13 @@ export class {{classname}} {
// authentication ({{name}}) required // authentication ({{name}}) required
{{#isApiKey}} {{#isApiKey}}
{{#isKeyInHeader}} {{#isKeyInHeader}}
if (this.configuration.apiKeys["{{keyParamName}}"]) { if (this.configuration.apiKeys && this.configuration.apiKeys["{{keyParamName}}"]) {
{{#useHttpClient}}headers = {{/useHttpClient}}headers.set('{{keyParamName}}', this.configuration.apiKeys["{{keyParamName}}"]); {{#useHttpClient}}headers = {{/useHttpClient}}headers.set('{{keyParamName}}', this.configuration.apiKeys["{{keyParamName}}"]);
} }
{{/isKeyInHeader}} {{/isKeyInHeader}}
{{#isKeyInQuery}} {{#isKeyInQuery}}
if (this.configuration.apiKeys["{{keyParamName}}"]) { if (this.configuration.apiKeys && this.configuration.apiKeys["{{keyParamName}}"]) {
{{#useHttpClient}}queryParameters = {{/useHttpClient}}queryParameters.set('{{keyParamName}}', this.configuration.apiKeys["{{keyParamName}}"]); {{#useHttpClient}}queryParameters = {{/useHttpClient}}queryParameters.set('{{keyParamName}}', this.configuration.apiKeys["{{keyParamName}}"]);
} }

View File

@ -106,12 +106,12 @@ export class {{classname}} {
// authentication ({{name}}) required // authentication ({{name}}) required
{{#isApiKey}} {{#isApiKey}}
{{#isKeyInHeader}} {{#isKeyInHeader}}
if (this.APIConfiguration.apiKeys["{{keyParamName}}"]) { if (this.APIConfiguration.apiKeys && this.APIConfiguration.apiKeys["{{keyParamName}}"]) {
headers['{{keyParamName}}'] = this.APIConfiguration.apiKeys["{{keyParamName}}"]; headers['{{keyParamName}}'] = this.APIConfiguration.apiKeys["{{keyParamName}}"];
} }
{{/isKeyInHeader}} {{/isKeyInHeader}}
{{#isKeyInQuery}} {{#isKeyInQuery}}
if (this.APIConfiguration.apiKeys["{{keyParamName}}"]) { if (this.APIConfiguration.apiKeys && this.APIConfiguration.apiKeys["{{keyParamName}}"]) {
queryParameters.push("{{paramName}}="+encodeURIComponent(String(this.APIConfiguration.apiKeys["{{keyParamName}}"]))); queryParameters.push("{{paramName}}="+encodeURIComponent(String(this.APIConfiguration.apiKeys["{{keyParamName}}"])));
} }
{{/isKeyInQuery}} {{/isKeyInQuery}}

View File

@ -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"), "userName");
Assert.assertEquals(codegen.toVarName("user|name"), "userName"); Assert.assertEquals(codegen.toVarName("user|name"), "userName");
Assert.assertEquals(codegen.toVarName("user !\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~name"), "user$Name");
} }
} }

View File

@ -28,8 +28,7 @@ paths:
description: To test code injection */ ' " =end -- \r\n \n \r description: To test code injection */ ' " =end -- \r\n \n \r
operationId: testCodeInject */ ' " =end -- \r\n \n \r operationId: testCodeInject */ ' " =end -- \r\n \n \r
consumes: consumes:
- application/json - application/x-www-form-urlencoded
- "*/ ' \" =end -- \r\n \n \r"
produces: produces:
- application/json - application/json
- "*/ ' \" =end -- \r\n \n \r" - "*/ ' \" =end -- \r\n \n \r"

View File

@ -1 +1 @@
2.4.0-SNAPSHOT 4.0.0-SNAPSHOT

View File

@ -2,7 +2,7 @@
### Building ### 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 install
npm run build npm run build
@ -10,11 +10,11 @@ npm run build
### publishing ### publishing
First build the package than run ```npm publish``` First build the package then run ```npm publish```
### consuming ### 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:_ _published:_
@ -22,7 +22,7 @@ _published:_
npm install @ --save npm install @ --save
``` ```
_unPublished (not recommended):_ _without publishing (not recommended):_
``` ```
npm install PATH_TO_GENERATED_PACKAGE --save npm install PATH_TO_GENERATED_PACKAGE --save
@ -37,9 +37,16 @@ npm link
In your project: 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: In your Angular project:
@ -94,8 +101,8 @@ export class AppComponent {
Note: The ApiModule is restricted to being instantiated once app wide. Note: The ApiModule is restricted to being instantiated once app wide.
This is to ensure that all services are treated as singletons. This is to ensure that all services are treated as singletons.
#### Using multiple swagger files / APIs / ApiModules #### Using multiple OpenAPI files / APIs / ApiModules
In order to use multiple `ApiModules` generated from different swagger files, In order to use multiple `ApiModules` generated from different OpenAPI files,
you can create an alias name when importing the modules you can create an alias name when importing the modules
in order to avoid naming conflicts: in order to avoid naming conflicts:
``` ```

View File

@ -17,7 +17,7 @@ export class ApiModule {
return { return {
ngModule: ApiModule, ngModule: ApiModule,
providers: [ { provide: Configuration, useFactory: configurationFactory } ] providers: [ { provide: Configuration, useFactory: configurationFactory } ]
} };
} }
constructor( @Optional() @SkipSelf() parentModule: ApiModule, constructor( @Optional() @SkipSelf() parentModule: ApiModule,

View File

@ -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 -- * 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 * 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. * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://github.com/swagger-api/swagger-codegen.git * https://openapi-generator.tech
* Do not edit the class manually. * Do not edit the class manually.
*/ */
/* tslint:disable:no-unused-variable member-ordering */ /* tslint:disable:no-unused-variable member-ordering */
@ -26,17 +26,18 @@ import { Configuration } from '../configurat
@Injectable() @Injectable()
export class FakeService { 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 defaultHeaders = new HttpHeaders();
public configuration = new Configuration(); public configuration = new Configuration();
constructor(protected httpClient: HttpClient, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) { constructor(protected httpClient: HttpClient, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) {
if (basePath) {
this.basePath = basePath;
}
if (configuration) { if (configuration) {
this.configuration = 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 { private canConsumeForm(consumes: string[]): boolean {
const form = 'multipart/form-data'; const form = 'multipart/form-data';
for (let consume of consumes) { for (const consume of consumes) {
if (form === consume) { if (form === consume) {
return true; return true;
} }
@ -57,8 +58,8 @@ export class FakeService {
/** /**
* To test code injection *_/ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r * To test code injection *_/ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r
* * To test code injection *_/ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r
* @param testCodeInjectEndRnNR To test code injection *_/ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r * @param testCodeInjectEndRnNR To test code injection *_/ &#39; \\\&quot; &#x3D;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 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. * @param reportProgress flag to report request and response progress.
*/ */
@ -71,23 +72,20 @@ export class FakeService {
// to determine the Accept header // to determine the Accept header
let httpHeaderAccepts: string[] = [ let httpHeaderAccepts: string[] = [
'application/json',
'*_/ =end -- '
]; ];
let httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts); const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
if (httpHeaderAcceptSelected != undefined) { if (httpHeaderAcceptSelected !== undefined) {
headers = headers.set("Accept", httpHeaderAcceptSelected); headers = headers.set('Accept', httpHeaderAcceptSelected);
} }
// to determine the Content-Type header // to determine the Content-Type header
let consumes: string[] = [ const consumes: string[] = [
'application/json', 'application/x-www-form-urlencoded'
'*_/ =end -- '
]; ];
const canConsumeForm = this.canConsumeForm(consumes); 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 useForm = false;
let convertFormParamsToString = false; let convertFormParamsToString = false;
if (useForm) { if (useForm) {
@ -100,7 +98,7 @@ export class FakeService {
formParams = formParams.append('test code inject */ &#39; &quot; &#x3D;end -- \r\n \n \r', <any>testCodeInjectEndRnNR) || formParams; formParams = formParams.append('test code inject */ &#39; &quot; &#x3D;end -- \r\n \n \r', <any>testCodeInjectEndRnNR) || formParams;
} }
return this.httpClient.put<any>(`${this.basePath}/fake`, return this.httpClient.put<any>(`${this.configuration.basePath}/fake`,
convertFormParamsToString ? formParams.toString() : formParams, convertFormParamsToString ? formParams.toString() : formParams,
{ {
withCredentials: this.configuration.withCredentials, withCredentials: this.configuration.withCredentials,

View File

@ -28,11 +28,11 @@ export class Configuration {
* Select the correct content-type to use for a request. * Select the correct content-type to use for a request.
* Uses {@link Configuration#isJsonMime} to determine the correct content-type. * 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 * 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 * @param contentTypes - the array of content types that are available for selection
* @returns {string} the selected content-type or <code>undefined</code> if no selection could be made. * @returns the selected content-type or <code>undefined</code> if no selection could be made.
*/ */
public selectHeaderContentType (contentTypes: string[]): string | undefined { public selectHeaderContentType (contentTypes: string[]): string | undefined {
if (contentTypes.length == 0) { if (contentTypes.length === 0) {
return undefined; return undefined;
} }
@ -47,11 +47,11 @@ export class Configuration {
* Select the correct accept content-type to use for a request. * Select the correct accept content-type to use for a request.
* Uses {@link Configuration#isJsonMime} to determine the correct accept content-type. * 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 * 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. * @param accepts - the array of content types that are available for selection.
* @returns {string} the selected content-type or <code>undefined</code> if no selection could be made. * @returns the selected content-type or <code>undefined</code> if no selection could be made.
*/ */
public selectHeaderAccept(accepts: string[]): string | undefined { public selectHeaderAccept(accepts: string[]): string | undefined {
if (accepts.length == 0) { if (accepts.length === 0) {
return undefined; return undefined;
} }
@ -69,11 +69,11 @@ export class Configuration {
* application/json; charset=UTF8 * application/json; charset=UTF8
* APPLICATION/JSON * APPLICATION/JSON
* application/vnd.company+json * application/vnd.company+json
* @param {string} mime - MIME (Multipurpose Internet Mail Extensions) * @param mime - MIME (Multipurpose Internet Mail Extensions)
* @return {boolean} True if the given MIME is JSON, false otherwise. * @return True if the given MIME is JSON, false otherwise.
*/ */
public isJsonMime(mime: string): boolean { public isJsonMime(mime: string): boolean {
const jsonMime: RegExp = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i'); 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');
} }
} }

View File

@ -1,7 +1,7 @@
#!/bin/sh #!/bin/sh
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ # 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_user_id=$1
git_repo_id=$2 git_repo_id=$2

View File

@ -1 +1 @@
export * from './modelReturn'; export * from './return';

View File

@ -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;
}

View File

@ -1 +1 @@
2.4.0-SNAPSHOT 4.0.0-SNAPSHOT

View File

@ -2,7 +2,7 @@
### Building ### 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 install
npm run build npm run build
@ -10,11 +10,11 @@ npm run build
### publishing ### publishing
First build the package than run ```npm publish``` First build the package then run ```npm publish```
### consuming ### 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:_ _published:_
@ -22,7 +22,7 @@ _published:_
npm install @ --save npm install @ --save
``` ```
_unPublished (not recommended):_ _without publishing (not recommended):_
``` ```
npm install PATH_TO_GENERATED_PACKAGE --save npm install PATH_TO_GENERATED_PACKAGE --save
@ -37,9 +37,16 @@ npm link
In your project: 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: In your Angular project:
@ -94,8 +101,8 @@ export class AppComponent {
Note: The ApiModule is restricted to being instantiated once app wide. Note: The ApiModule is restricted to being instantiated once app wide.
This is to ensure that all services are treated as singletons. This is to ensure that all services are treated as singletons.
#### Using multiple swagger files / APIs / ApiModules #### Using multiple OpenAPI files / APIs / ApiModules
In order to use multiple `ApiModules` generated from different swagger files, In order to use multiple `ApiModules` generated from different OpenAPI files,
you can create an alias name when importing the modules you can create an alias name when importing the modules
in order to avoid naming conflicts: in order to avoid naming conflicts:
``` ```

View File

@ -17,7 +17,7 @@ export class ApiModule {
return { return {
ngModule: ApiModule, ngModule: ApiModule,
providers: [ { provide: Configuration, useFactory: configurationFactory } ] providers: [ { provide: Configuration, useFactory: configurationFactory } ]
} };
} }
constructor( @Optional() @SkipSelf() parentModule: ApiModule, constructor( @Optional() @SkipSelf() parentModule: ApiModule,

View File

@ -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 -- * 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 * 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. * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://github.com/swagger-api/swagger-codegen.git * https://openapi-generator.tech
* Do not edit the class manually. * Do not edit the class manually.
*/ */
/* tslint:disable:no-unused-variable member-ordering */ /* tslint:disable:no-unused-variable member-ordering */
@ -26,17 +26,18 @@ import { Configuration } from '../configurat
@Injectable() @Injectable()
export class FakeService { 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 defaultHeaders = new HttpHeaders();
public configuration = new Configuration(); public configuration = new Configuration();
constructor(protected httpClient: HttpClient, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) { constructor(protected httpClient: HttpClient, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) {
if (basePath) {
this.basePath = basePath;
}
if (configuration) { if (configuration) {
this.configuration = 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 { private canConsumeForm(consumes: string[]): boolean {
const form = 'multipart/form-data'; const form = 'multipart/form-data';
for (let consume of consumes) { for (const consume of consumes) {
if (form === consume) { if (form === consume) {
return true; return true;
} }
@ -57,8 +58,8 @@ export class FakeService {
/** /**
* To test code injection *_/ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r * To test code injection *_/ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r
* * To test code injection *_/ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r
* @param testCodeInjectEndRnNR To test code injection *_/ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r * @param testCodeInjectEndRnNR To test code injection *_/ &#39; \\\&quot; &#x3D;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 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. * @param reportProgress flag to report request and response progress.
*/ */
@ -71,23 +72,20 @@ export class FakeService {
// to determine the Accept header // to determine the Accept header
let httpHeaderAccepts: string[] = [ let httpHeaderAccepts: string[] = [
'application/json',
'*_/ =end -- '
]; ];
let httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts); const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
if (httpHeaderAcceptSelected != undefined) { if (httpHeaderAcceptSelected !== undefined) {
headers = headers.set("Accept", httpHeaderAcceptSelected); headers = headers.set('Accept', httpHeaderAcceptSelected);
} }
// to determine the Content-Type header // to determine the Content-Type header
let consumes: string[] = [ const consumes: string[] = [
'application/json', 'application/x-www-form-urlencoded'
'*_/ =end -- '
]; ];
const canConsumeForm = this.canConsumeForm(consumes); 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 useForm = false;
let convertFormParamsToString = false; let convertFormParamsToString = false;
if (useForm) { if (useForm) {
@ -100,7 +98,7 @@ export class FakeService {
formParams = formParams.append('test code inject */ &#39; &quot; &#x3D;end -- \r\n \n \r', <any>testCodeInjectEndRnNR) || formParams; formParams = formParams.append('test code inject */ &#39; &quot; &#x3D;end -- \r\n \n \r', <any>testCodeInjectEndRnNR) || formParams;
} }
return this.httpClient.put<any>(`${this.basePath}/fake`, return this.httpClient.put<any>(`${this.configuration.basePath}/fake`,
convertFormParamsToString ? formParams.toString() : formParams, convertFormParamsToString ? formParams.toString() : formParams,
{ {
withCredentials: this.configuration.withCredentials, withCredentials: this.configuration.withCredentials,

View File

@ -28,11 +28,11 @@ export class Configuration {
* Select the correct content-type to use for a request. * Select the correct content-type to use for a request.
* Uses {@link Configuration#isJsonMime} to determine the correct content-type. * 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 * 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 * @param contentTypes - the array of content types that are available for selection
* @returns {string} the selected content-type or <code>undefined</code> if no selection could be made. * @returns the selected content-type or <code>undefined</code> if no selection could be made.
*/ */
public selectHeaderContentType (contentTypes: string[]): string | undefined { public selectHeaderContentType (contentTypes: string[]): string | undefined {
if (contentTypes.length == 0) { if (contentTypes.length === 0) {
return undefined; return undefined;
} }
@ -47,11 +47,11 @@ export class Configuration {
* Select the correct accept content-type to use for a request. * Select the correct accept content-type to use for a request.
* Uses {@link Configuration#isJsonMime} to determine the correct accept content-type. * 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 * 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. * @param accepts - the array of content types that are available for selection.
* @returns {string} the selected content-type or <code>undefined</code> if no selection could be made. * @returns the selected content-type or <code>undefined</code> if no selection could be made.
*/ */
public selectHeaderAccept(accepts: string[]): string | undefined { public selectHeaderAccept(accepts: string[]): string | undefined {
if (accepts.length == 0) { if (accepts.length === 0) {
return undefined; return undefined;
} }
@ -69,11 +69,11 @@ export class Configuration {
* application/json; charset=UTF8 * application/json; charset=UTF8
* APPLICATION/JSON * APPLICATION/JSON
* application/vnd.company+json * application/vnd.company+json
* @param {string} mime - MIME (Multipurpose Internet Mail Extensions) * @param mime - MIME (Multipurpose Internet Mail Extensions)
* @return {boolean} True if the given MIME is JSON, false otherwise. * @return True if the given MIME is JSON, false otherwise.
*/ */
public isJsonMime(mime: string): boolean { public isJsonMime(mime: string): boolean {
const jsonMime: RegExp = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i'); 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');
} }
} }

View File

@ -1,7 +1,7 @@
#!/bin/sh #!/bin/sh
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ # 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_user_id=$1
git_repo_id=$2 git_repo_id=$2

View File

@ -1 +1 @@
export * from './modelReturn'; export * from './return';

View File

@ -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;
}

View File

@ -1 +1 @@
3.1.2-SNAPSHOT 4.0.0-SNAPSHOT

View File

@ -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<runtime.ApiResponse<void>> {
const headerParameters: runtime.HTTPHeaders = {};
const formData = new FormData();
if (requestParameters.testCodeInjectEndRnNR !== undefined) {
formData.append('test code inject */ &#39; &quot; &#x3D;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<void> {
await this.testCodeInjectEndRnNRRaw(requestParameters);
}
}

View File

@ -0,0 +1 @@
export * from './FakeApi';

View File

@ -1,16 +1,3 @@
// tslint:disable export * from './runtime';
/** export * from './apis';
* OpenAPI Petstore *_/ ' \" =end -- \\r\\n \\n \\r export * from './models';
* 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";

View File

@ -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,
};
}

View File

@ -0,0 +1 @@
export * from './Return';

View File

@ -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<T extends BaseAPI>(this: T, ...middlewares: Middleware[]) {
const next = this.clone<T>();
next.middleware = next.middleware.concat(...middlewares);
return next;
}
withPreMiddleware<T extends BaseAPI>(this: T, ...preMiddlewares: Array<Middleware['pre']>) {
const middlewares = preMiddlewares.map((pre) => ({ pre }));
return this.withMiddleware<T>(...middlewares);
}
withPostMiddleware<T extends BaseAPI>(this: T, ...postMiddlewares: Array<Middleware['post']>) {
const middlewares = postMiddlewares.map((post) => ({ post }));
return this.withMiddleware<T>(...middlewares);
}
protected async request(context: RequestOpts): Promise<Response> {
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<T extends BaseAPI>(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<string | number | null | boolean> };
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<FetchParams | void>;
post?(context: ResponseContext): Promise<Response | void>;
}
export interface ApiResponse<T> {
raw: Response;
value(): Promise<T>;
}
export interface ResponseTransformer<T> {
(json: any): T;
}
export class JSONApiResponse<T> {
constructor(public raw: Response, private transformer: ResponseTransformer<T> = (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();
};
}

View File

@ -0,0 +1,17 @@
{
"compilerOptions": {
"declaration": true,
"target": "es5",
"module": "commonjs",
"outDir": "dist",
"rootDir": ".",
"lib": [
"es6",
"dom"
]
},
"exclude": [
"dist",
"node_modules"
]
}

View File

@ -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 -- * 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 * 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. * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://github.com/swagger-api/swagger-codegen.git * https://openapi-generator.tech
* Do not edit the class manually. * Do not edit the class manually.
*/ */
/* tslint:disable:no-unused-variable member-ordering */ /* tslint:disable:no-unused-variable member-ordering */
@ -27,7 +27,7 @@ import { COLLECTION_FORMATS } from '../variables';
@injectable() @injectable()
export class FakeService { 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, constructor(@inject("IApiHttpClient") private httpClient: IHttpClient,
@inject("IAPIConfiguration") private APIConfiguration: IAPIConfiguration ) { @inject("IAPIConfiguration") private APIConfiguration: IAPIConfiguration ) {
@ -37,8 +37,8 @@ export class FakeService {
/** /**
* To test code injection *_/ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r * To test code injection *_/ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r
* * To test code injection *_/ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r
* @param testCodeInjectEndRnNR To test code injection *_/ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r * @param testCodeInjectEndRnNR To test code injection *_/ &#39; \\\&quot; &#x3D;end -- \\\\r\\\\n \\\\n \\\\r
*/ */
public testCodeInjectEndRnNR(testCodeInjectEndRnNR?: string, observe?: 'body', headers?: Headers): Observable<any>; public testCodeInjectEndRnNR(testCodeInjectEndRnNR?: string, observe?: 'body', headers?: Headers): Observable<any>;

View File

@ -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;
}

View File

@ -1 +1 @@
3.0.3-SNAPSHOT 4.0.0-SNAPSHOT

View File

@ -18,7 +18,7 @@ import Promise = require('bluebird');
import { ObjectSerializer, Authentication, HttpBasicAuth, ApiKeyAuth, OAuth, VoidAuth } from '../model/models'; 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 // 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 * @summary To test code injection *_/ ' \" =end -- \\r\\n \\n \\r
* @param UNKNOWN_BASE_TYPE * @param testCodeInjectEndRnNR To test code injection *_/ &#39; \\\&quot; &#x3D;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'; const localVarPath = this.basePath + '/fake';
let localVarQueryParameters: any = {}; let localVarQueryParameters: any = {};
let localVarHeaderParams: any = (<any>Object).assign({}, this.defaultHeaders); let localVarHeaderParams: any = (<any>Object).assign({}, this.defaultHeaders);
@ -83,6 +83,10 @@ export class FakeApi {
let localVarUseFormData = false; let localVarUseFormData = false;
if (testCodeInjectEndRnNR !== undefined) {
localVarFormParams['test code inject */ &#39; &quot; &#x3D;end -- \r\n \n \r'] = ObjectSerializer.serialize(testCodeInjectEndRnNR, "string");
}
let localVarRequestOptions: localVarRequest.Options = { let localVarRequestOptions: localVarRequest.Options = {
method: 'PUT', method: 'PUT',
qs: localVarQueryParameters, qs: localVarQueryParameters,
@ -90,7 +94,6 @@ export class FakeApi {
uri: localVarPath, uri: localVarPath,
useQuerystring: this._useQuerystring, useQuerystring: this._useQuerystring,
json: true, json: true,
body: ObjectSerializer.serialize(UNKNOWN_BASE_TYPE, "any")
}; };
this.authentications.default.applyToRequest(localVarRequestOptions); this.authentications.default.applyToRequest(localVarRequestOptions);

View File

@ -1,8 +1,8 @@
export * from './modelReturn'; export * from './return';
import localVarRequest = require('request'); import localVarRequest = require('request');
import { ModelReturn } from './modelReturn'; import { Return } from './return';
/* tslint:disable:no-unused-variable */ /* tslint:disable:no-unused-variable */
let primitives = [ let primitives = [
@ -20,7 +20,7 @@ let enumsMap: {[index: string]: any} = {
} }
let typeMap: {[index: string]: any} = { let typeMap: {[index: string]: any} = {
"ModelReturn": ModelReturn, "Return": Return,
} }
export class ObjectSerializer { export class ObjectSerializer {
@ -74,7 +74,7 @@ export class ObjectSerializer {
} }
return transformedData; return transformedData;
} else if (type === "Date") { } else if (type === "Date") {
return data.toString(); return data.toISOString();
} else { } else {
if (enumsMap[type]) { if (enumsMap[type]) {
return data; return data;

View File

@ -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;
}
}

View File

@ -418,7 +418,7 @@ export class PetService {
let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845 let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845
// authentication (api_key) required // 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"]); headers.set('api_key', this.configuration.apiKeys["api_key"]);
} }

View File

@ -170,7 +170,7 @@ export class StoreService {
let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845 let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845
// authentication (api_key) required // 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"]); headers.set('api_key', this.configuration.apiKeys["api_key"]);
} }

View File

@ -418,7 +418,7 @@ export class PetService {
let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845 let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845
// authentication (api_key) required // 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"]); headers.set('api_key', this.configuration.apiKeys["api_key"]);
} }

View File

@ -170,7 +170,7 @@ export class StoreService {
let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845 let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845
// authentication (api_key) required // 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"]); headers.set('api_key', this.configuration.apiKeys["api_key"]);
} }

View File

@ -419,7 +419,7 @@ export class PetService implements PetServiceInterface {
let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845 let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845
// authentication (api_key) required // 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"]); headers.set('api_key', this.configuration.apiKeys["api_key"]);
} }

View File

@ -171,7 +171,7 @@ export class StoreService implements StoreServiceInterface {
let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845 let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845
// authentication (api_key) required // 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"]); headers.set('api_key', this.configuration.apiKeys["api_key"]);
} }

View File

@ -291,7 +291,7 @@ export class PetService {
let headers = this.defaultHeaders; let headers = this.defaultHeaders;
// authentication (api_key) required // 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"]); headers = headers.set('api_key', this.configuration.apiKeys["api_key"]);
} }

View File

@ -110,7 +110,7 @@ export class StoreService {
let headers = this.defaultHeaders; let headers = this.defaultHeaders;
// authentication (api_key) required // 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"]); headers = headers.set('api_key', this.configuration.apiKeys["api_key"]);
} }

View File

@ -418,7 +418,7 @@ export class PetService {
let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845 let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845
// authentication (api_key) required // 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"]); headers.set('api_key', this.configuration.apiKeys["api_key"]);
} }

View File

@ -170,7 +170,7 @@ export class StoreService {
let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845 let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845
// authentication (api_key) required // 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"]); headers.set('api_key', this.configuration.apiKeys["api_key"]);
} }

View File

@ -291,7 +291,7 @@ export class PetService {
let headers = this.defaultHeaders; let headers = this.defaultHeaders;
// authentication (api_key) required // 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"]); headers = headers.set('api_key', this.configuration.apiKeys["api_key"]);
} }

View File

@ -110,7 +110,7 @@ export class StoreService {
let headers = this.defaultHeaders; let headers = this.defaultHeaders;
// authentication (api_key) required // 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"]); headers = headers.set('api_key', this.configuration.apiKeys["api_key"]);
} }

View File

@ -291,7 +291,7 @@ export class PetService {
let headers = this.defaultHeaders; let headers = this.defaultHeaders;
// authentication (api_key) required // 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"]); headers = headers.set('api_key', this.configuration.apiKeys["api_key"]);
} }

View File

@ -110,7 +110,7 @@ export class StoreService {
let headers = this.defaultHeaders; let headers = this.defaultHeaders;
// authentication (api_key) required // 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"]); headers = headers.set('api_key', this.configuration.apiKeys["api_key"]);
} }

View File

@ -293,7 +293,7 @@ export class PetService {
let headers = this.defaultHeaders; let headers = this.defaultHeaders;
// authentication (api_key) required // 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"]); headers = headers.set('api_key', this.configuration.apiKeys["api_key"]);
} }

View File

@ -112,7 +112,7 @@ export class StoreService {
let headers = this.defaultHeaders; let headers = this.defaultHeaders;
// authentication (api_key) required // 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"]); headers = headers.set('api_key', this.configuration.apiKeys["api_key"]);
} }

View File

@ -293,7 +293,7 @@ export class PetService {
let headers = this.defaultHeaders; let headers = this.defaultHeaders;
// authentication (api_key) required // 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"]); headers = headers.set('api_key', this.configuration.apiKeys["api_key"]);
} }

View File

@ -112,7 +112,7 @@ export class StoreService {
let headers = this.defaultHeaders; let headers = this.defaultHeaders;
// authentication (api_key) required // 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"]); headers = headers.set('api_key', this.configuration.apiKeys["api_key"]);
} }

View File

@ -187,7 +187,7 @@ export class PetService {
} }
// authentication (api_key) required // 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['api_key'] = this.APIConfiguration.apiKeys["api_key"];
} }
headers['Accept'] = 'application/xml'; headers['Accept'] = 'application/xml';

View File

@ -68,7 +68,7 @@ export class StoreService {
public getInventory(observe?: 'response', headers?: Headers): Observable<HttpResponse<{ [key: string]: number; }>>; public getInventory(observe?: 'response', headers?: Headers): Observable<HttpResponse<{ [key: string]: number; }>>;
public getInventory(observe: any = 'body', headers: Headers = {}): Observable<any> { public getInventory(observe: any = 'body', headers: Headers = {}): Observable<any> {
// authentication (api_key) required // 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['api_key'] = this.APIConfiguration.apiKeys["api_key"];
} }
headers['Accept'] = 'application/json'; headers['Accept'] = 'application/json';