From 626b2c5720aef827458375a3a43e2918b9f6e0e6 Mon Sep 17 00:00:00 2001 From: Richard Naeve Date: Wed, 11 Jan 2017 11:24:06 +0100 Subject: [PATCH 1/3] ISSUE-4531 Arrays are now serialized according to the different collection formats. All api classes are also exported in a const array to make handling of large api libraries easier. --- .../typescript-angular2/api.mustache | 41 +++++++++++++++++-- .../typescript-angular2/apis.mustache | 2 + .../typescript-angular2/variables.mustache | 8 +++- 3 files changed, 47 insertions(+), 4 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/typescript-angular2/api.mustache b/modules/swagger-codegen/src/main/resources/typescript-angular2/api.mustache index 8700083b63d..c0b361f0c23 100644 --- a/modules/swagger-codegen/src/main/resources/typescript-angular2/api.mustache +++ b/modules/swagger-codegen/src/main/resources/typescript-angular2/api.mustache @@ -8,7 +8,7 @@ import { Observable } from 'rxjs/Observab import 'rxjs/add/operator/map'; import * as models from '../model/models'; -import { BASE_PATH } from '../variables'; +import { BASE_PATH, COLLECTION_FORMATS } from '../variables'; import { Configuration } from '../configuration'; /* tslint:disable:no-unused-variable member-ordering */ @@ -94,12 +94,33 @@ export class {{classname}} { {{/allParams}} {{#queryParams}} if ({{paramName}} !== undefined) { + {{#isListContainer}} + if({{paramName}}){ + {{#isCollectionFormatMulti}} + {{paramName}}.forEach((element) => { + queryParameters.append('{{baseName}}', element); + }) + {{/isCollectionFormatMulti}} + {{^isCollectionFormatMulti}} + queryParameters.set('{{baseName}}', {{paramName}}.join(COLLECTION_FORMATS['{{collectionFormat}}'])); + {{/isCollectionFormatMulti}} + } + {{/isListContainer}} + {{^isListContainer}} queryParameters.set('{{baseName}}', {{paramName}}); + {{/isListContainer}} } {{/queryParams}} {{#headerParams}} - headers.set('{{baseName}}', String({{paramName}})); + {{#isListContainer}} + if({{paramName}}){ + headers.set('{{baseName}}', {{paramName}}.join(COLLECTION_FORMATS['{{collectionFormat}}'])); + } + {{/isListContainer}} + {{^isListContainer}} + headers.set('{{baseName}}', String({{paramName}})); + {{/isListContainer}} {{/headerParams}} // to determine the Content-Type header @@ -161,7 +182,21 @@ export class {{classname}} { {{#formParams}} if ({{paramName}} !== undefined) { - formParams.set('{{baseName}}', {{paramName}}); + {{#isListContainer}} + if({{paramName}}){ + {{#isCollectionFormatMulti}} + {{paramName}}.forEach((element) => { + formParams.append('{{baseName}}', element); + }) + {{/isCollectionFormatMulti}} + {{^isCollectionFormatMulti}} + formParams.set('{{baseName}}', {{paramName}}.join(COLLECTION_FORMATS['{{collectionFormat}}'])); + {{/isCollectionFormatMulti}} + } + {{/isListContainer}} + {{^isListContainer}} + formParams.set('{{baseName}}', {{paramName}}); + {{/isListContainer}} } {{/formParams}} diff --git a/modules/swagger-codegen/src/main/resources/typescript-angular2/apis.mustache b/modules/swagger-codegen/src/main/resources/typescript-angular2/apis.mustache index 9a39b864538..6a37b83354e 100644 --- a/modules/swagger-codegen/src/main/resources/typescript-angular2/apis.mustache +++ b/modules/swagger-codegen/src/main/resources/typescript-angular2/apis.mustache @@ -2,6 +2,8 @@ {{#apis}} {{#operations}} export * from './{{ classname }}'; +import { {{ classname }} } from './{{ classname }}'; {{/operations}} {{/apis}} +export const APIS = [{{#apis}}{{#operations}}{{ classname }},{{/operations}}{{/apis}}]; {{/apiInfo}} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/typescript-angular2/variables.mustache b/modules/swagger-codegen/src/main/resources/typescript-angular2/variables.mustache index 27b987e9b23..944e688f1b1 100644 --- a/modules/swagger-codegen/src/main/resources/typescript-angular2/variables.mustache +++ b/modules/swagger-codegen/src/main/resources/typescript-angular2/variables.mustache @@ -1,3 +1,9 @@ import { OpaqueToken } from '@angular/core'; -export const BASE_PATH = new OpaqueToken('basePath'); \ No newline at end of file +export const BASE_PATH = new OpaqueToken('basePath'); +export const COLLECTION_FORMATS = { + 'csv': ',', + 'tsv': ' ', + 'ssv': ' ', + 'pipes': '|' +} \ No newline at end of file From 06ac53dc56971de566ecf5f5eff81854961f8246 Mon Sep 17 00:00:00 2001 From: Richard Naeve Date: Wed, 11 Jan 2017 11:40:59 +0100 Subject: [PATCH 2/3] Added petstore samples --- .../typescript-angular2/default/api/PetApi.ts | 34 ++++++++++++------- .../default/api/StoreApi.ts | 2 +- .../default/api/UserApi.ts | 2 +- .../typescript-angular2/default/api/api.ts | 4 +++ .../typescript-angular2/default/variables.ts | 8 ++++- .../typescript-angular2/npm/README.md | 4 +-- .../typescript-angular2/npm/api/PetApi.ts | 34 ++++++++++++------- .../typescript-angular2/npm/api/StoreApi.ts | 2 +- .../typescript-angular2/npm/api/UserApi.ts | 2 +- .../typescript-angular2/npm/api/api.ts | 4 +++ .../typescript-angular2/npm/package.json | 2 +- .../typescript-angular2/npm/variables.ts | 8 ++++- 12 files changed, 71 insertions(+), 35 deletions(-) diff --git a/samples/client/petstore/typescript-angular2/default/api/PetApi.ts b/samples/client/petstore/typescript-angular2/default/api/PetApi.ts index 5751b452369..64b31c01779 100644 --- a/samples/client/petstore/typescript-angular2/default/api/PetApi.ts +++ b/samples/client/petstore/typescript-angular2/default/api/PetApi.ts @@ -19,7 +19,7 @@ import { Observable } from 'rxjs/Observab import 'rxjs/add/operator/map'; import * as models from '../model/models'; -import { BASE_PATH } from '../variables'; +import { BASE_PATH, COLLECTION_FORMATS } from '../variables'; import { Configuration } from '../configuration'; /* tslint:disable:no-unused-variable member-ordering */ @@ -258,7 +258,7 @@ export class PetApi { throw new Error('Required parameter petId was null or undefined when calling deletePet.'); } - headers.set('api_key', String(apiKey)); + headers.set('api_key', String(apiKey)); // to determine the Content-Type header let consumes: string[] = [ @@ -308,7 +308,11 @@ export class PetApi { let queryParameters = new URLSearchParams(); let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845 if (status !== undefined) { - queryParameters.set('status', status); + if(status){ + status.forEach((element) => { + queryParameters.append('status', element); + }) + } } @@ -360,7 +364,11 @@ export class PetApi { let queryParameters = new URLSearchParams(); let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845 if (tags !== undefined) { - queryParameters.set('tags', tags); + if(tags){ + tags.forEach((element) => { + queryParameters.append('tags', element); + }) + } } @@ -427,6 +435,11 @@ export class PetApi { 'application/xml' ]; + // authentication (api_key) required + if (this.configuration.apiKey) + { + headers.set('api_key', this.configuration.apiKey); + } // authentication (petstore_auth) required // oauth required if (this.configuration.accessToken) @@ -436,11 +449,6 @@ export class PetApi { : this.configuration.accessToken; headers.set('Authorization', 'Bearer ' + accessToken); } - // authentication (api_key) required - if (this.configuration.apiKey) - { - headers.set('api_key', this.configuration.apiKey); - } @@ -557,10 +565,10 @@ export class PetApi { if (name !== undefined) { - formParams.set('name', name); + formParams.set('name', name); } if (status !== undefined) { - formParams.set('status', status); + formParams.set('status', status); } let requestOptions: RequestOptionsArgs = new RequestOptions({ @@ -623,10 +631,10 @@ export class PetApi { if (additionalMetadata !== undefined) { - formParams.set('additionalMetadata', additionalMetadata); + formParams.set('additionalMetadata', additionalMetadata); } if (file !== undefined) { - formParams.set('file', file); + formParams.set('file', file); } let requestOptions: RequestOptionsArgs = new RequestOptions({ diff --git a/samples/client/petstore/typescript-angular2/default/api/StoreApi.ts b/samples/client/petstore/typescript-angular2/default/api/StoreApi.ts index 484d5e56fde..b7204c6fad4 100644 --- a/samples/client/petstore/typescript-angular2/default/api/StoreApi.ts +++ b/samples/client/petstore/typescript-angular2/default/api/StoreApi.ts @@ -19,7 +19,7 @@ import { Observable } from 'rxjs/Observab import 'rxjs/add/operator/map'; import * as models from '../model/models'; -import { BASE_PATH } from '../variables'; +import { BASE_PATH, COLLECTION_FORMATS } from '../variables'; import { Configuration } from '../configuration'; /* tslint:disable:no-unused-variable member-ordering */ diff --git a/samples/client/petstore/typescript-angular2/default/api/UserApi.ts b/samples/client/petstore/typescript-angular2/default/api/UserApi.ts index 8dda0cf8377..dd350ba6ab6 100644 --- a/samples/client/petstore/typescript-angular2/default/api/UserApi.ts +++ b/samples/client/petstore/typescript-angular2/default/api/UserApi.ts @@ -19,7 +19,7 @@ import { Observable } from 'rxjs/Observab import 'rxjs/add/operator/map'; import * as models from '../model/models'; -import { BASE_PATH } from '../variables'; +import { BASE_PATH, COLLECTION_FORMATS } from '../variables'; import { Configuration } from '../configuration'; /* tslint:disable:no-unused-variable member-ordering */ diff --git a/samples/client/petstore/typescript-angular2/default/api/api.ts b/samples/client/petstore/typescript-angular2/default/api/api.ts index 056206bfaca..dc2c6e4fafb 100644 --- a/samples/client/petstore/typescript-angular2/default/api/api.ts +++ b/samples/client/petstore/typescript-angular2/default/api/api.ts @@ -1,3 +1,7 @@ export * from './PetApi'; +import { PetApi } from './PetApi'; export * from './StoreApi'; +import { StoreApi } from './StoreApi'; export * from './UserApi'; +import { UserApi } from './UserApi'; +export const APIS = [PetApi,StoreApi,UserApi,]; diff --git a/samples/client/petstore/typescript-angular2/default/variables.ts b/samples/client/petstore/typescript-angular2/default/variables.ts index 27b987e9b23..944e688f1b1 100644 --- a/samples/client/petstore/typescript-angular2/default/variables.ts +++ b/samples/client/petstore/typescript-angular2/default/variables.ts @@ -1,3 +1,9 @@ import { OpaqueToken } from '@angular/core'; -export const BASE_PATH = new OpaqueToken('basePath'); \ No newline at end of file +export const BASE_PATH = new OpaqueToken('basePath'); +export const COLLECTION_FORMATS = { + 'csv': ',', + 'tsv': ' ', + 'ssv': ' ', + 'pipes': '|' +} \ No newline at end of file diff --git a/samples/client/petstore/typescript-angular2/npm/README.md b/samples/client/petstore/typescript-angular2/npm/README.md index 5f176a7b484..d992edd4238 100644 --- a/samples/client/petstore/typescript-angular2/npm/README.md +++ b/samples/client/petstore/typescript-angular2/npm/README.md @@ -1,4 +1,4 @@ -## @swagger/angular2-typescript-petstore@0.0.1-SNAPSHOT.201612150011 +## @swagger/angular2-typescript-petstore@0.0.1-SNAPSHOT.201701111140 ### Building @@ -19,7 +19,7 @@ navigate to the folder of your consuming project and run one of next commando's. _published:_ ``` -npm install @swagger/angular2-typescript-petstore@0.0.1-SNAPSHOT.201612150011 --save +npm install @swagger/angular2-typescript-petstore@0.0.1-SNAPSHOT.201701111140 --save ``` _unPublished (not recommended):_ diff --git a/samples/client/petstore/typescript-angular2/npm/api/PetApi.ts b/samples/client/petstore/typescript-angular2/npm/api/PetApi.ts index 5751b452369..64b31c01779 100644 --- a/samples/client/petstore/typescript-angular2/npm/api/PetApi.ts +++ b/samples/client/petstore/typescript-angular2/npm/api/PetApi.ts @@ -19,7 +19,7 @@ import { Observable } from 'rxjs/Observab import 'rxjs/add/operator/map'; import * as models from '../model/models'; -import { BASE_PATH } from '../variables'; +import { BASE_PATH, COLLECTION_FORMATS } from '../variables'; import { Configuration } from '../configuration'; /* tslint:disable:no-unused-variable member-ordering */ @@ -258,7 +258,7 @@ export class PetApi { throw new Error('Required parameter petId was null or undefined when calling deletePet.'); } - headers.set('api_key', String(apiKey)); + headers.set('api_key', String(apiKey)); // to determine the Content-Type header let consumes: string[] = [ @@ -308,7 +308,11 @@ export class PetApi { let queryParameters = new URLSearchParams(); let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845 if (status !== undefined) { - queryParameters.set('status', status); + if(status){ + status.forEach((element) => { + queryParameters.append('status', element); + }) + } } @@ -360,7 +364,11 @@ export class PetApi { let queryParameters = new URLSearchParams(); let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845 if (tags !== undefined) { - queryParameters.set('tags', tags); + if(tags){ + tags.forEach((element) => { + queryParameters.append('tags', element); + }) + } } @@ -427,6 +435,11 @@ export class PetApi { 'application/xml' ]; + // authentication (api_key) required + if (this.configuration.apiKey) + { + headers.set('api_key', this.configuration.apiKey); + } // authentication (petstore_auth) required // oauth required if (this.configuration.accessToken) @@ -436,11 +449,6 @@ export class PetApi { : this.configuration.accessToken; headers.set('Authorization', 'Bearer ' + accessToken); } - // authentication (api_key) required - if (this.configuration.apiKey) - { - headers.set('api_key', this.configuration.apiKey); - } @@ -557,10 +565,10 @@ export class PetApi { if (name !== undefined) { - formParams.set('name', name); + formParams.set('name', name); } if (status !== undefined) { - formParams.set('status', status); + formParams.set('status', status); } let requestOptions: RequestOptionsArgs = new RequestOptions({ @@ -623,10 +631,10 @@ export class PetApi { if (additionalMetadata !== undefined) { - formParams.set('additionalMetadata', additionalMetadata); + formParams.set('additionalMetadata', additionalMetadata); } if (file !== undefined) { - formParams.set('file', file); + formParams.set('file', file); } let requestOptions: RequestOptionsArgs = new RequestOptions({ diff --git a/samples/client/petstore/typescript-angular2/npm/api/StoreApi.ts b/samples/client/petstore/typescript-angular2/npm/api/StoreApi.ts index 484d5e56fde..b7204c6fad4 100644 --- a/samples/client/petstore/typescript-angular2/npm/api/StoreApi.ts +++ b/samples/client/petstore/typescript-angular2/npm/api/StoreApi.ts @@ -19,7 +19,7 @@ import { Observable } from 'rxjs/Observab import 'rxjs/add/operator/map'; import * as models from '../model/models'; -import { BASE_PATH } from '../variables'; +import { BASE_PATH, COLLECTION_FORMATS } from '../variables'; import { Configuration } from '../configuration'; /* tslint:disable:no-unused-variable member-ordering */ diff --git a/samples/client/petstore/typescript-angular2/npm/api/UserApi.ts b/samples/client/petstore/typescript-angular2/npm/api/UserApi.ts index 8dda0cf8377..dd350ba6ab6 100644 --- a/samples/client/petstore/typescript-angular2/npm/api/UserApi.ts +++ b/samples/client/petstore/typescript-angular2/npm/api/UserApi.ts @@ -19,7 +19,7 @@ import { Observable } from 'rxjs/Observab import 'rxjs/add/operator/map'; import * as models from '../model/models'; -import { BASE_PATH } from '../variables'; +import { BASE_PATH, COLLECTION_FORMATS } from '../variables'; import { Configuration } from '../configuration'; /* tslint:disable:no-unused-variable member-ordering */ diff --git a/samples/client/petstore/typescript-angular2/npm/api/api.ts b/samples/client/petstore/typescript-angular2/npm/api/api.ts index 056206bfaca..dc2c6e4fafb 100644 --- a/samples/client/petstore/typescript-angular2/npm/api/api.ts +++ b/samples/client/petstore/typescript-angular2/npm/api/api.ts @@ -1,3 +1,7 @@ export * from './PetApi'; +import { PetApi } from './PetApi'; export * from './StoreApi'; +import { StoreApi } from './StoreApi'; export * from './UserApi'; +import { UserApi } from './UserApi'; +export const APIS = [PetApi,StoreApi,UserApi,]; diff --git a/samples/client/petstore/typescript-angular2/npm/package.json b/samples/client/petstore/typescript-angular2/npm/package.json index 6dd91bb3f86..4746328a611 100644 --- a/samples/client/petstore/typescript-angular2/npm/package.json +++ b/samples/client/petstore/typescript-angular2/npm/package.json @@ -1,6 +1,6 @@ { "name": "@swagger/angular2-typescript-petstore", - "version": "0.0.1-SNAPSHOT.201612150011", + "version": "0.0.1-SNAPSHOT.201701111140", "description": "swagger client for @swagger/angular2-typescript-petstore", "author": "Swagger Codegen Contributors", "keywords": [ diff --git a/samples/client/petstore/typescript-angular2/npm/variables.ts b/samples/client/petstore/typescript-angular2/npm/variables.ts index 27b987e9b23..944e688f1b1 100644 --- a/samples/client/petstore/typescript-angular2/npm/variables.ts +++ b/samples/client/petstore/typescript-angular2/npm/variables.ts @@ -1,3 +1,9 @@ import { OpaqueToken } from '@angular/core'; -export const BASE_PATH = new OpaqueToken('basePath'); \ No newline at end of file +export const BASE_PATH = new OpaqueToken('basePath'); +export const COLLECTION_FORMATS = { + 'csv': ',', + 'tsv': ' ', + 'ssv': ' ', + 'pipes': '|' +} \ No newline at end of file From b862ed738b373600efeecca80209d163c2871db6 Mon Sep 17 00:00:00 2001 From: Richard Naeve Date: Wed, 11 Jan 2017 14:40:35 +0100 Subject: [PATCH 3/3] Fixed indentations and coding style --- .../typescript-angular2/api.mustache | 101 +++++++++-------- .../typescript-angular2/apis.mustache | 2 +- .../typescript-angular2/default/api/PetApi.ts | 103 ++++++------------ .../default/api/StoreApi.ts | 33 +----- .../default/api/UserApi.ts | 60 ++-------- .../typescript-angular2/default/api/api.ts | 2 +- .../typescript-angular2/npm/README.md | 4 +- .../typescript-angular2/npm/api/PetApi.ts | 103 ++++++------------ .../typescript-angular2/npm/api/StoreApi.ts | 33 +----- .../typescript-angular2/npm/api/UserApi.ts | 60 ++-------- .../typescript-angular2/npm/api/api.ts | 2 +- .../typescript-angular2/npm/package.json | 2 +- 12 files changed, 146 insertions(+), 359 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/typescript-angular2/api.mustache b/modules/swagger-codegen/src/main/resources/typescript-angular2/api.mustache index c0b361f0c23..d62224930ef 100644 --- a/modules/swagger-codegen/src/main/resources/typescript-angular2/api.mustache +++ b/modules/swagger-codegen/src/main/resources/typescript-angular2/api.mustache @@ -93,36 +93,36 @@ export class {{classname}} { {{/required}} {{/allParams}} {{#queryParams}} + {{#isListContainer}} + if ({{paramName}}) { + {{#isCollectionFormatMulti}} + {{paramName}}.forEach((element) => { + queryParameters.append('{{baseName}}', element); + }) + {{/isCollectionFormatMulti}} + {{^isCollectionFormatMulti}} + queryParameters.set('{{baseName}}', {{paramName}}.join(COLLECTION_FORMATS['{{collectionFormat}}'])); + {{/isCollectionFormatMulti}} + } + {{/isListContainer}} + {{^isListContainer}} if ({{paramName}} !== undefined) { - {{#isListContainer}} - if({{paramName}}){ - {{#isCollectionFormatMulti}} - {{paramName}}.forEach((element) => { - queryParameters.append('{{baseName}}', element); - }) - {{/isCollectionFormatMulti}} - {{^isCollectionFormatMulti}} - queryParameters.set('{{baseName}}', {{paramName}}.join(COLLECTION_FORMATS['{{collectionFormat}}'])); - {{/isCollectionFormatMulti}} - } - {{/isListContainer}} - {{^isListContainer}} queryParameters.set('{{baseName}}', {{paramName}}); - {{/isListContainer}} } -{{/queryParams}} + {{/isListContainer}} +{{/queryParams}} {{#headerParams}} - {{#isListContainer}} - if({{paramName}}){ - headers.set('{{baseName}}', {{paramName}}.join(COLLECTION_FORMATS['{{collectionFormat}}'])); - } - {{/isListContainer}} - {{^isListContainer}} - headers.set('{{baseName}}', String({{paramName}})); - {{/isListContainer}} -{{/headerParams}} + {{#isListContainer}} + if ({{paramName}}) { + headers.set('{{baseName}}', {{paramName}}.join(COLLECTION_FORMATS['{{collectionFormat}}'])); + } + {{/isListContainer}} + {{^isListContainer}} + headers.set('{{baseName}}', String({{paramName}})); + {{/isListContainer}} +{{/headerParams}} // to determine the Content-Type header let consumes: string[] = [ {{#consumes}} @@ -141,65 +141,64 @@ export class {{classname}} { // authentication ({{name}}) required {{#isApiKey}} {{#isKeyInHeader}} - if (this.configuration.apiKey) - { + if (this.configuration.apiKey) { headers.set('{{keyParamName}}', this.configuration.apiKey); } + {{/isKeyInHeader}} {{#isKeyInQuery}} - if (this.configuration.apiKey) - { + if (this.configuration.apiKey) { formParams.set('{{keyParamName}}', this.configuration.apiKey); } + {{/isKeyInQuery}} {{/isApiKey}} {{#isBasic}} // http basic authentication required - if (this.configuration.username || this.configuration.password) - { + if (this.configuration.username || this.configuration.password) { headers.set('Authorization', 'Basic ' + btoa(this.configuration.username + ':' + this.configuration.password)); } + {{/isBasic}} {{#isOAuth}} // oauth required - if (this.configuration.accessToken) - { + if (this.configuration.accessToken) { let accessToken = typeof this.configuration.accessToken === 'function' ? this.configuration.accessToken() : this.configuration.accessToken; headers.set('Authorization', 'Bearer ' + accessToken); } + {{/isOAuth}} {{/authMethods}} - {{#hasFormParams}} headers.set('Content-Type', 'application/x-www-form-urlencoded'); -{{/hasFormParams}} +{{/hasFormParams}} {{#bodyParam}} headers.set('Content-Type', 'application/json'); -{{/bodyParam}} +{{/bodyParam}} {{#formParams}} + {{#isListContainer}} + if ({{paramName}}) { + {{#isCollectionFormatMulti}} + {{paramName}}.forEach((element) => { + formParams.append('{{baseName}}', element); + }) + {{/isCollectionFormatMulti}} + {{^isCollectionFormatMulti}} + formParams.set('{{baseName}}', {{paramName}}.join(COLLECTION_FORMATS['{{collectionFormat}}'])); + {{/isCollectionFormatMulti}} + } + {{/isListContainer}} + {{^isListContainer}} if ({{paramName}} !== undefined) { - {{#isListContainer}} - if({{paramName}}){ - {{#isCollectionFormatMulti}} - {{paramName}}.forEach((element) => { - formParams.append('{{baseName}}', element); - }) - {{/isCollectionFormatMulti}} - {{^isCollectionFormatMulti}} - formParams.set('{{baseName}}', {{paramName}}.join(COLLECTION_FORMATS['{{collectionFormat}}'])); - {{/isCollectionFormatMulti}} - } - {{/isListContainer}} - {{^isListContainer}} formParams.set('{{baseName}}', {{paramName}}); - {{/isListContainer}} } -{{/formParams}} + {{/isListContainer}} +{{/formParams}} let requestOptions: RequestOptionsArgs = new RequestOptions({ method: {{httpMethod}}, headers: headers, @@ -219,7 +218,7 @@ export class {{classname}} { return this.http.request(path, requestOptions); } - + {{/operation}} } {{/operations}} diff --git a/modules/swagger-codegen/src/main/resources/typescript-angular2/apis.mustache b/modules/swagger-codegen/src/main/resources/typescript-angular2/apis.mustache index 6a37b83354e..85522cf6c58 100644 --- a/modules/swagger-codegen/src/main/resources/typescript-angular2/apis.mustache +++ b/modules/swagger-codegen/src/main/resources/typescript-angular2/apis.mustache @@ -5,5 +5,5 @@ export * from './{{ classname }}'; import { {{ classname }} } from './{{ classname }}'; {{/operations}} {{/apis}} -export const APIS = [{{#apis}}{{#operations}}{{ classname }},{{/operations}}{{/apis}}]; +export const APIS = [ {{#apis}}{{#operations}}{{ classname }}, {{/operations}}{{/apis}}]; {{/apiInfo}} \ No newline at end of file diff --git a/samples/client/petstore/typescript-angular2/default/api/PetApi.ts b/samples/client/petstore/typescript-angular2/default/api/PetApi.ts index 64b31c01779..535d21d66d0 100644 --- a/samples/client/petstore/typescript-angular2/default/api/PetApi.ts +++ b/samples/client/petstore/typescript-angular2/default/api/PetApi.ts @@ -199,8 +199,6 @@ export class PetApi { let queryParameters = new URLSearchParams(); let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845 - - // to determine the Content-Type header let consumes: string[] = [ 'application/json', @@ -215,18 +213,15 @@ export class PetApi { // authentication (petstore_auth) required // oauth required - if (this.configuration.accessToken) - { + if (this.configuration.accessToken) { let accessToken = typeof this.configuration.accessToken === 'function' ? this.configuration.accessToken() : this.configuration.accessToken; headers.set('Authorization', 'Bearer ' + accessToken); } - headers.set('Content-Type', 'application/json'); - let requestOptions: RequestOptionsArgs = new RequestOptions({ method: RequestMethod.Post, headers: headers, @@ -241,7 +236,7 @@ export class PetApi { return this.http.request(path, requestOptions); } - + /** * Deletes a pet * @@ -257,8 +252,7 @@ export class PetApi { if (petId === null || petId === undefined) { throw new Error('Required parameter petId was null or undefined when calling deletePet.'); } - - headers.set('api_key', String(apiKey)); + headers.set('api_key', String(apiKey)); // to determine the Content-Type header let consumes: string[] = [ @@ -272,16 +266,12 @@ export class PetApi { // authentication (petstore_auth) required // oauth required - if (this.configuration.accessToken) - { + if (this.configuration.accessToken) { let accessToken = typeof this.configuration.accessToken === 'function' ? this.configuration.accessToken() : this.configuration.accessToken; headers.set('Authorization', 'Bearer ' + accessToken); } - - - let requestOptions: RequestOptionsArgs = new RequestOptions({ method: RequestMethod.Delete, @@ -296,7 +286,7 @@ export class PetApi { return this.http.request(path, requestOptions); } - + /** * Finds Pets by status * Multiple status values can be provided with comma separated strings @@ -307,15 +297,12 @@ export class PetApi { let queryParameters = new URLSearchParams(); let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845 - if (status !== undefined) { - if(status){ - status.forEach((element) => { - queryParameters.append('status', element); - }) - } + if (status) { + status.forEach((element) => { + queryParameters.append('status', element); + }) } - // to determine the Content-Type header let consumes: string[] = [ ]; @@ -328,16 +315,12 @@ export class PetApi { // authentication (petstore_auth) required // oauth required - if (this.configuration.accessToken) - { + if (this.configuration.accessToken) { let accessToken = typeof this.configuration.accessToken === 'function' ? this.configuration.accessToken() : this.configuration.accessToken; headers.set('Authorization', 'Bearer ' + accessToken); } - - - let requestOptions: RequestOptionsArgs = new RequestOptions({ method: RequestMethod.Get, @@ -352,7 +335,7 @@ export class PetApi { return this.http.request(path, requestOptions); } - + /** * Finds Pets by tags * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. @@ -363,15 +346,12 @@ export class PetApi { let queryParameters = new URLSearchParams(); let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845 - if (tags !== undefined) { - if(tags){ - tags.forEach((element) => { - queryParameters.append('tags', element); - }) - } + if (tags) { + tags.forEach((element) => { + queryParameters.append('tags', element); + }) } - // to determine the Content-Type header let consumes: string[] = [ ]; @@ -384,16 +364,12 @@ export class PetApi { // authentication (petstore_auth) required // oauth required - if (this.configuration.accessToken) - { + if (this.configuration.accessToken) { let accessToken = typeof this.configuration.accessToken === 'function' ? this.configuration.accessToken() : this.configuration.accessToken; headers.set('Authorization', 'Bearer ' + accessToken); } - - - let requestOptions: RequestOptionsArgs = new RequestOptions({ method: RequestMethod.Get, @@ -408,7 +384,7 @@ export class PetApi { return this.http.request(path, requestOptions); } - + /** * Find pet by ID * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions @@ -423,8 +399,6 @@ export class PetApi { if (petId === null || petId === undefined) { throw new Error('Required parameter petId was null or undefined when calling getPetById.'); } - - // to determine the Content-Type header let consumes: string[] = [ ]; @@ -436,22 +410,18 @@ export class PetApi { ]; // authentication (api_key) required - if (this.configuration.apiKey) - { + if (this.configuration.apiKey) { headers.set('api_key', this.configuration.apiKey); } + // authentication (petstore_auth) required // oauth required - if (this.configuration.accessToken) - { + if (this.configuration.accessToken) { let accessToken = typeof this.configuration.accessToken === 'function' ? this.configuration.accessToken() : this.configuration.accessToken; headers.set('Authorization', 'Bearer ' + accessToken); } - - - let requestOptions: RequestOptionsArgs = new RequestOptions({ method: RequestMethod.Get, @@ -466,7 +436,7 @@ export class PetApi { return this.http.request(path, requestOptions); } - + /** * Update an existing pet * @@ -477,8 +447,6 @@ export class PetApi { let queryParameters = new URLSearchParams(); let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845 - - // to determine the Content-Type header let consumes: string[] = [ 'application/json', @@ -493,18 +461,15 @@ export class PetApi { // authentication (petstore_auth) required // oauth required - if (this.configuration.accessToken) - { + if (this.configuration.accessToken) { let accessToken = typeof this.configuration.accessToken === 'function' ? this.configuration.accessToken() : this.configuration.accessToken; headers.set('Authorization', 'Bearer ' + accessToken); } - headers.set('Content-Type', 'application/json'); - let requestOptions: RequestOptionsArgs = new RequestOptions({ method: RequestMethod.Put, headers: headers, @@ -519,7 +484,7 @@ export class PetApi { return this.http.request(path, requestOptions); } - + /** * Updates a pet in the store with form data * @@ -538,8 +503,6 @@ export class PetApi { if (petId === null || petId === undefined) { throw new Error('Required parameter petId was null or undefined when calling updatePetWithForm.'); } - - // to determine the Content-Type header let consumes: string[] = [ 'application/x-www-form-urlencoded' @@ -553,20 +516,19 @@ export class PetApi { // authentication (petstore_auth) required // oauth required - if (this.configuration.accessToken) - { + if (this.configuration.accessToken) { let accessToken = typeof this.configuration.accessToken === 'function' ? this.configuration.accessToken() : this.configuration.accessToken; headers.set('Authorization', 'Bearer ' + accessToken); } - - headers.set('Content-Type', 'application/x-www-form-urlencoded'); + headers.set('Content-Type', 'application/x-www-form-urlencoded'); if (name !== undefined) { formParams.set('name', name); } + if (status !== undefined) { formParams.set('status', status); } @@ -585,7 +547,7 @@ export class PetApi { return this.http.request(path, requestOptions); } - + /** * uploads an image * @@ -604,8 +566,6 @@ export class PetApi { if (petId === null || petId === undefined) { throw new Error('Required parameter petId was null or undefined when calling uploadFile.'); } - - // to determine the Content-Type header let consumes: string[] = [ 'multipart/form-data' @@ -619,20 +579,19 @@ export class PetApi { // authentication (petstore_auth) required // oauth required - if (this.configuration.accessToken) - { + if (this.configuration.accessToken) { let accessToken = typeof this.configuration.accessToken === 'function' ? this.configuration.accessToken() : this.configuration.accessToken; headers.set('Authorization', 'Bearer ' + accessToken); } - - headers.set('Content-Type', 'application/x-www-form-urlencoded'); + headers.set('Content-Type', 'application/x-www-form-urlencoded'); if (additionalMetadata !== undefined) { formParams.set('additionalMetadata', additionalMetadata); } + if (file !== undefined) { formParams.set('file', file); } @@ -651,5 +610,5 @@ export class PetApi { return this.http.request(path, requestOptions); } - + } diff --git a/samples/client/petstore/typescript-angular2/default/api/StoreApi.ts b/samples/client/petstore/typescript-angular2/default/api/StoreApi.ts index b7204c6fad4..344d1f1b257 100644 --- a/samples/client/petstore/typescript-angular2/default/api/StoreApi.ts +++ b/samples/client/petstore/typescript-angular2/default/api/StoreApi.ts @@ -133,8 +133,6 @@ export class StoreApi { if (orderId === null || orderId === undefined) { throw new Error('Required parameter orderId was null or undefined when calling deleteOrder.'); } - - // to determine the Content-Type header let consumes: string[] = [ ]; @@ -145,10 +143,6 @@ export class StoreApi { 'application/xml' ]; - - - - let requestOptions: RequestOptionsArgs = new RequestOptions({ method: RequestMethod.Delete, headers: headers, @@ -162,7 +156,7 @@ export class StoreApi { return this.http.request(path, requestOptions); } - + /** * Returns pet inventories by status * Returns a map of status codes to quantities @@ -172,8 +166,6 @@ export class StoreApi { let queryParameters = new URLSearchParams(); let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845 - - // to determine the Content-Type header let consumes: string[] = [ ]; @@ -185,13 +177,9 @@ export class StoreApi { ]; // authentication (api_key) required - if (this.configuration.apiKey) - { + if (this.configuration.apiKey) { headers.set('api_key', this.configuration.apiKey); } - - - let requestOptions: RequestOptionsArgs = new RequestOptions({ method: RequestMethod.Get, @@ -206,7 +194,7 @@ export class StoreApi { return this.http.request(path, requestOptions); } - + /** * Find purchase order by ID * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions @@ -221,8 +209,6 @@ export class StoreApi { if (orderId === null || orderId === undefined) { throw new Error('Required parameter orderId was null or undefined when calling getOrderById.'); } - - // to determine the Content-Type header let consumes: string[] = [ ]; @@ -233,10 +219,6 @@ export class StoreApi { 'application/xml' ]; - - - - let requestOptions: RequestOptionsArgs = new RequestOptions({ method: RequestMethod.Get, headers: headers, @@ -250,7 +232,7 @@ export class StoreApi { return this.http.request(path, requestOptions); } - + /** * Place an order for a pet * @@ -261,8 +243,6 @@ export class StoreApi { let queryParameters = new URLSearchParams(); let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845 - - // to determine the Content-Type header let consumes: string[] = [ ]; @@ -273,11 +253,8 @@ export class StoreApi { 'application/xml' ]; - - headers.set('Content-Type', 'application/json'); - let requestOptions: RequestOptionsArgs = new RequestOptions({ method: RequestMethod.Post, headers: headers, @@ -292,5 +269,5 @@ export class StoreApi { return this.http.request(path, requestOptions); } - + } diff --git a/samples/client/petstore/typescript-angular2/default/api/UserApi.ts b/samples/client/petstore/typescript-angular2/default/api/UserApi.ts index dd350ba6ab6..bb7884ea636 100644 --- a/samples/client/petstore/typescript-angular2/default/api/UserApi.ts +++ b/samples/client/petstore/typescript-angular2/default/api/UserApi.ts @@ -195,8 +195,6 @@ export class UserApi { let queryParameters = new URLSearchParams(); let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845 - - // to determine the Content-Type header let consumes: string[] = [ ]; @@ -207,11 +205,8 @@ export class UserApi { 'application/xml' ]; - - headers.set('Content-Type', 'application/json'); - let requestOptions: RequestOptionsArgs = new RequestOptions({ method: RequestMethod.Post, headers: headers, @@ -226,7 +221,7 @@ export class UserApi { return this.http.request(path, requestOptions); } - + /** * Creates list of users with given input array * @@ -237,8 +232,6 @@ export class UserApi { let queryParameters = new URLSearchParams(); let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845 - - // to determine the Content-Type header let consumes: string[] = [ ]; @@ -249,11 +242,8 @@ export class UserApi { 'application/xml' ]; - - headers.set('Content-Type', 'application/json'); - let requestOptions: RequestOptionsArgs = new RequestOptions({ method: RequestMethod.Post, headers: headers, @@ -268,7 +258,7 @@ export class UserApi { return this.http.request(path, requestOptions); } - + /** * Creates list of users with given input array * @@ -279,8 +269,6 @@ export class UserApi { let queryParameters = new URLSearchParams(); let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845 - - // to determine the Content-Type header let consumes: string[] = [ ]; @@ -291,11 +279,8 @@ export class UserApi { 'application/xml' ]; - - headers.set('Content-Type', 'application/json'); - let requestOptions: RequestOptionsArgs = new RequestOptions({ method: RequestMethod.Post, headers: headers, @@ -310,7 +295,7 @@ export class UserApi { return this.http.request(path, requestOptions); } - + /** * Delete user * This can only be done by the logged in user. @@ -325,8 +310,6 @@ export class UserApi { if (username === null || username === undefined) { throw new Error('Required parameter username was null or undefined when calling deleteUser.'); } - - // to determine the Content-Type header let consumes: string[] = [ ]; @@ -337,10 +320,6 @@ export class UserApi { 'application/xml' ]; - - - - let requestOptions: RequestOptionsArgs = new RequestOptions({ method: RequestMethod.Delete, headers: headers, @@ -354,7 +333,7 @@ export class UserApi { return this.http.request(path, requestOptions); } - + /** * Get user by user name * @@ -369,8 +348,6 @@ export class UserApi { if (username === null || username === undefined) { throw new Error('Required parameter username was null or undefined when calling getUserByName.'); } - - // to determine the Content-Type header let consumes: string[] = [ ]; @@ -381,10 +358,6 @@ export class UserApi { 'application/xml' ]; - - - - let requestOptions: RequestOptionsArgs = new RequestOptions({ method: RequestMethod.Get, headers: headers, @@ -398,7 +371,7 @@ export class UserApi { return this.http.request(path, requestOptions); } - + /** * Logs user into the system * @@ -413,11 +386,11 @@ export class UserApi { if (username !== undefined) { queryParameters.set('username', username); } + if (password !== undefined) { queryParameters.set('password', password); } - // to determine the Content-Type header let consumes: string[] = [ ]; @@ -428,10 +401,6 @@ export class UserApi { 'application/xml' ]; - - - - let requestOptions: RequestOptionsArgs = new RequestOptions({ method: RequestMethod.Get, headers: headers, @@ -445,7 +414,7 @@ export class UserApi { return this.http.request(path, requestOptions); } - + /** * Logs out current logged in user session * @@ -455,8 +424,6 @@ export class UserApi { let queryParameters = new URLSearchParams(); let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845 - - // to determine the Content-Type header let consumes: string[] = [ ]; @@ -467,10 +434,6 @@ export class UserApi { 'application/xml' ]; - - - - let requestOptions: RequestOptionsArgs = new RequestOptions({ method: RequestMethod.Get, headers: headers, @@ -484,7 +447,7 @@ export class UserApi { return this.http.request(path, requestOptions); } - + /** * Updated user * This can only be done by the logged in user. @@ -500,8 +463,6 @@ export class UserApi { if (username === null || username === undefined) { throw new Error('Required parameter username was null or undefined when calling updateUser.'); } - - // to determine the Content-Type header let consumes: string[] = [ ]; @@ -512,11 +473,8 @@ export class UserApi { 'application/xml' ]; - - headers.set('Content-Type', 'application/json'); - let requestOptions: RequestOptionsArgs = new RequestOptions({ method: RequestMethod.Put, headers: headers, @@ -531,5 +489,5 @@ export class UserApi { return this.http.request(path, requestOptions); } - + } diff --git a/samples/client/petstore/typescript-angular2/default/api/api.ts b/samples/client/petstore/typescript-angular2/default/api/api.ts index dc2c6e4fafb..0d1e9f047fd 100644 --- a/samples/client/petstore/typescript-angular2/default/api/api.ts +++ b/samples/client/petstore/typescript-angular2/default/api/api.ts @@ -4,4 +4,4 @@ export * from './StoreApi'; import { StoreApi } from './StoreApi'; export * from './UserApi'; import { UserApi } from './UserApi'; -export const APIS = [PetApi,StoreApi,UserApi,]; +export const APIS = [ PetApi, StoreApi, UserApi, ]; diff --git a/samples/client/petstore/typescript-angular2/npm/README.md b/samples/client/petstore/typescript-angular2/npm/README.md index d992edd4238..b1cac56e5e8 100644 --- a/samples/client/petstore/typescript-angular2/npm/README.md +++ b/samples/client/petstore/typescript-angular2/npm/README.md @@ -1,4 +1,4 @@ -## @swagger/angular2-typescript-petstore@0.0.1-SNAPSHOT.201701111140 +## @swagger/angular2-typescript-petstore@0.0.1-SNAPSHOT.201701111439 ### Building @@ -19,7 +19,7 @@ navigate to the folder of your consuming project and run one of next commando's. _published:_ ``` -npm install @swagger/angular2-typescript-petstore@0.0.1-SNAPSHOT.201701111140 --save +npm install @swagger/angular2-typescript-petstore@0.0.1-SNAPSHOT.201701111439 --save ``` _unPublished (not recommended):_ diff --git a/samples/client/petstore/typescript-angular2/npm/api/PetApi.ts b/samples/client/petstore/typescript-angular2/npm/api/PetApi.ts index 64b31c01779..535d21d66d0 100644 --- a/samples/client/petstore/typescript-angular2/npm/api/PetApi.ts +++ b/samples/client/petstore/typescript-angular2/npm/api/PetApi.ts @@ -199,8 +199,6 @@ export class PetApi { let queryParameters = new URLSearchParams(); let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845 - - // to determine the Content-Type header let consumes: string[] = [ 'application/json', @@ -215,18 +213,15 @@ export class PetApi { // authentication (petstore_auth) required // oauth required - if (this.configuration.accessToken) - { + if (this.configuration.accessToken) { let accessToken = typeof this.configuration.accessToken === 'function' ? this.configuration.accessToken() : this.configuration.accessToken; headers.set('Authorization', 'Bearer ' + accessToken); } - headers.set('Content-Type', 'application/json'); - let requestOptions: RequestOptionsArgs = new RequestOptions({ method: RequestMethod.Post, headers: headers, @@ -241,7 +236,7 @@ export class PetApi { return this.http.request(path, requestOptions); } - + /** * Deletes a pet * @@ -257,8 +252,7 @@ export class PetApi { if (petId === null || petId === undefined) { throw new Error('Required parameter petId was null or undefined when calling deletePet.'); } - - headers.set('api_key', String(apiKey)); + headers.set('api_key', String(apiKey)); // to determine the Content-Type header let consumes: string[] = [ @@ -272,16 +266,12 @@ export class PetApi { // authentication (petstore_auth) required // oauth required - if (this.configuration.accessToken) - { + if (this.configuration.accessToken) { let accessToken = typeof this.configuration.accessToken === 'function' ? this.configuration.accessToken() : this.configuration.accessToken; headers.set('Authorization', 'Bearer ' + accessToken); } - - - let requestOptions: RequestOptionsArgs = new RequestOptions({ method: RequestMethod.Delete, @@ -296,7 +286,7 @@ export class PetApi { return this.http.request(path, requestOptions); } - + /** * Finds Pets by status * Multiple status values can be provided with comma separated strings @@ -307,15 +297,12 @@ export class PetApi { let queryParameters = new URLSearchParams(); let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845 - if (status !== undefined) { - if(status){ - status.forEach((element) => { - queryParameters.append('status', element); - }) - } + if (status) { + status.forEach((element) => { + queryParameters.append('status', element); + }) } - // to determine the Content-Type header let consumes: string[] = [ ]; @@ -328,16 +315,12 @@ export class PetApi { // authentication (petstore_auth) required // oauth required - if (this.configuration.accessToken) - { + if (this.configuration.accessToken) { let accessToken = typeof this.configuration.accessToken === 'function' ? this.configuration.accessToken() : this.configuration.accessToken; headers.set('Authorization', 'Bearer ' + accessToken); } - - - let requestOptions: RequestOptionsArgs = new RequestOptions({ method: RequestMethod.Get, @@ -352,7 +335,7 @@ export class PetApi { return this.http.request(path, requestOptions); } - + /** * Finds Pets by tags * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. @@ -363,15 +346,12 @@ export class PetApi { let queryParameters = new URLSearchParams(); let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845 - if (tags !== undefined) { - if(tags){ - tags.forEach((element) => { - queryParameters.append('tags', element); - }) - } + if (tags) { + tags.forEach((element) => { + queryParameters.append('tags', element); + }) } - // to determine the Content-Type header let consumes: string[] = [ ]; @@ -384,16 +364,12 @@ export class PetApi { // authentication (petstore_auth) required // oauth required - if (this.configuration.accessToken) - { + if (this.configuration.accessToken) { let accessToken = typeof this.configuration.accessToken === 'function' ? this.configuration.accessToken() : this.configuration.accessToken; headers.set('Authorization', 'Bearer ' + accessToken); } - - - let requestOptions: RequestOptionsArgs = new RequestOptions({ method: RequestMethod.Get, @@ -408,7 +384,7 @@ export class PetApi { return this.http.request(path, requestOptions); } - + /** * Find pet by ID * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions @@ -423,8 +399,6 @@ export class PetApi { if (petId === null || petId === undefined) { throw new Error('Required parameter petId was null or undefined when calling getPetById.'); } - - // to determine the Content-Type header let consumes: string[] = [ ]; @@ -436,22 +410,18 @@ export class PetApi { ]; // authentication (api_key) required - if (this.configuration.apiKey) - { + if (this.configuration.apiKey) { headers.set('api_key', this.configuration.apiKey); } + // authentication (petstore_auth) required // oauth required - if (this.configuration.accessToken) - { + if (this.configuration.accessToken) { let accessToken = typeof this.configuration.accessToken === 'function' ? this.configuration.accessToken() : this.configuration.accessToken; headers.set('Authorization', 'Bearer ' + accessToken); } - - - let requestOptions: RequestOptionsArgs = new RequestOptions({ method: RequestMethod.Get, @@ -466,7 +436,7 @@ export class PetApi { return this.http.request(path, requestOptions); } - + /** * Update an existing pet * @@ -477,8 +447,6 @@ export class PetApi { let queryParameters = new URLSearchParams(); let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845 - - // to determine the Content-Type header let consumes: string[] = [ 'application/json', @@ -493,18 +461,15 @@ export class PetApi { // authentication (petstore_auth) required // oauth required - if (this.configuration.accessToken) - { + if (this.configuration.accessToken) { let accessToken = typeof this.configuration.accessToken === 'function' ? this.configuration.accessToken() : this.configuration.accessToken; headers.set('Authorization', 'Bearer ' + accessToken); } - headers.set('Content-Type', 'application/json'); - let requestOptions: RequestOptionsArgs = new RequestOptions({ method: RequestMethod.Put, headers: headers, @@ -519,7 +484,7 @@ export class PetApi { return this.http.request(path, requestOptions); } - + /** * Updates a pet in the store with form data * @@ -538,8 +503,6 @@ export class PetApi { if (petId === null || petId === undefined) { throw new Error('Required parameter petId was null or undefined when calling updatePetWithForm.'); } - - // to determine the Content-Type header let consumes: string[] = [ 'application/x-www-form-urlencoded' @@ -553,20 +516,19 @@ export class PetApi { // authentication (petstore_auth) required // oauth required - if (this.configuration.accessToken) - { + if (this.configuration.accessToken) { let accessToken = typeof this.configuration.accessToken === 'function' ? this.configuration.accessToken() : this.configuration.accessToken; headers.set('Authorization', 'Bearer ' + accessToken); } - - headers.set('Content-Type', 'application/x-www-form-urlencoded'); + headers.set('Content-Type', 'application/x-www-form-urlencoded'); if (name !== undefined) { formParams.set('name', name); } + if (status !== undefined) { formParams.set('status', status); } @@ -585,7 +547,7 @@ export class PetApi { return this.http.request(path, requestOptions); } - + /** * uploads an image * @@ -604,8 +566,6 @@ export class PetApi { if (petId === null || petId === undefined) { throw new Error('Required parameter petId was null or undefined when calling uploadFile.'); } - - // to determine the Content-Type header let consumes: string[] = [ 'multipart/form-data' @@ -619,20 +579,19 @@ export class PetApi { // authentication (petstore_auth) required // oauth required - if (this.configuration.accessToken) - { + if (this.configuration.accessToken) { let accessToken = typeof this.configuration.accessToken === 'function' ? this.configuration.accessToken() : this.configuration.accessToken; headers.set('Authorization', 'Bearer ' + accessToken); } - - headers.set('Content-Type', 'application/x-www-form-urlencoded'); + headers.set('Content-Type', 'application/x-www-form-urlencoded'); if (additionalMetadata !== undefined) { formParams.set('additionalMetadata', additionalMetadata); } + if (file !== undefined) { formParams.set('file', file); } @@ -651,5 +610,5 @@ export class PetApi { return this.http.request(path, requestOptions); } - + } diff --git a/samples/client/petstore/typescript-angular2/npm/api/StoreApi.ts b/samples/client/petstore/typescript-angular2/npm/api/StoreApi.ts index b7204c6fad4..344d1f1b257 100644 --- a/samples/client/petstore/typescript-angular2/npm/api/StoreApi.ts +++ b/samples/client/petstore/typescript-angular2/npm/api/StoreApi.ts @@ -133,8 +133,6 @@ export class StoreApi { if (orderId === null || orderId === undefined) { throw new Error('Required parameter orderId was null or undefined when calling deleteOrder.'); } - - // to determine the Content-Type header let consumes: string[] = [ ]; @@ -145,10 +143,6 @@ export class StoreApi { 'application/xml' ]; - - - - let requestOptions: RequestOptionsArgs = new RequestOptions({ method: RequestMethod.Delete, headers: headers, @@ -162,7 +156,7 @@ export class StoreApi { return this.http.request(path, requestOptions); } - + /** * Returns pet inventories by status * Returns a map of status codes to quantities @@ -172,8 +166,6 @@ export class StoreApi { let queryParameters = new URLSearchParams(); let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845 - - // to determine the Content-Type header let consumes: string[] = [ ]; @@ -185,13 +177,9 @@ export class StoreApi { ]; // authentication (api_key) required - if (this.configuration.apiKey) - { + if (this.configuration.apiKey) { headers.set('api_key', this.configuration.apiKey); } - - - let requestOptions: RequestOptionsArgs = new RequestOptions({ method: RequestMethod.Get, @@ -206,7 +194,7 @@ export class StoreApi { return this.http.request(path, requestOptions); } - + /** * Find purchase order by ID * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions @@ -221,8 +209,6 @@ export class StoreApi { if (orderId === null || orderId === undefined) { throw new Error('Required parameter orderId was null or undefined when calling getOrderById.'); } - - // to determine the Content-Type header let consumes: string[] = [ ]; @@ -233,10 +219,6 @@ export class StoreApi { 'application/xml' ]; - - - - let requestOptions: RequestOptionsArgs = new RequestOptions({ method: RequestMethod.Get, headers: headers, @@ -250,7 +232,7 @@ export class StoreApi { return this.http.request(path, requestOptions); } - + /** * Place an order for a pet * @@ -261,8 +243,6 @@ export class StoreApi { let queryParameters = new URLSearchParams(); let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845 - - // to determine the Content-Type header let consumes: string[] = [ ]; @@ -273,11 +253,8 @@ export class StoreApi { 'application/xml' ]; - - headers.set('Content-Type', 'application/json'); - let requestOptions: RequestOptionsArgs = new RequestOptions({ method: RequestMethod.Post, headers: headers, @@ -292,5 +269,5 @@ export class StoreApi { return this.http.request(path, requestOptions); } - + } diff --git a/samples/client/petstore/typescript-angular2/npm/api/UserApi.ts b/samples/client/petstore/typescript-angular2/npm/api/UserApi.ts index dd350ba6ab6..bb7884ea636 100644 --- a/samples/client/petstore/typescript-angular2/npm/api/UserApi.ts +++ b/samples/client/petstore/typescript-angular2/npm/api/UserApi.ts @@ -195,8 +195,6 @@ export class UserApi { let queryParameters = new URLSearchParams(); let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845 - - // to determine the Content-Type header let consumes: string[] = [ ]; @@ -207,11 +205,8 @@ export class UserApi { 'application/xml' ]; - - headers.set('Content-Type', 'application/json'); - let requestOptions: RequestOptionsArgs = new RequestOptions({ method: RequestMethod.Post, headers: headers, @@ -226,7 +221,7 @@ export class UserApi { return this.http.request(path, requestOptions); } - + /** * Creates list of users with given input array * @@ -237,8 +232,6 @@ export class UserApi { let queryParameters = new URLSearchParams(); let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845 - - // to determine the Content-Type header let consumes: string[] = [ ]; @@ -249,11 +242,8 @@ export class UserApi { 'application/xml' ]; - - headers.set('Content-Type', 'application/json'); - let requestOptions: RequestOptionsArgs = new RequestOptions({ method: RequestMethod.Post, headers: headers, @@ -268,7 +258,7 @@ export class UserApi { return this.http.request(path, requestOptions); } - + /** * Creates list of users with given input array * @@ -279,8 +269,6 @@ export class UserApi { let queryParameters = new URLSearchParams(); let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845 - - // to determine the Content-Type header let consumes: string[] = [ ]; @@ -291,11 +279,8 @@ export class UserApi { 'application/xml' ]; - - headers.set('Content-Type', 'application/json'); - let requestOptions: RequestOptionsArgs = new RequestOptions({ method: RequestMethod.Post, headers: headers, @@ -310,7 +295,7 @@ export class UserApi { return this.http.request(path, requestOptions); } - + /** * Delete user * This can only be done by the logged in user. @@ -325,8 +310,6 @@ export class UserApi { if (username === null || username === undefined) { throw new Error('Required parameter username was null or undefined when calling deleteUser.'); } - - // to determine the Content-Type header let consumes: string[] = [ ]; @@ -337,10 +320,6 @@ export class UserApi { 'application/xml' ]; - - - - let requestOptions: RequestOptionsArgs = new RequestOptions({ method: RequestMethod.Delete, headers: headers, @@ -354,7 +333,7 @@ export class UserApi { return this.http.request(path, requestOptions); } - + /** * Get user by user name * @@ -369,8 +348,6 @@ export class UserApi { if (username === null || username === undefined) { throw new Error('Required parameter username was null or undefined when calling getUserByName.'); } - - // to determine the Content-Type header let consumes: string[] = [ ]; @@ -381,10 +358,6 @@ export class UserApi { 'application/xml' ]; - - - - let requestOptions: RequestOptionsArgs = new RequestOptions({ method: RequestMethod.Get, headers: headers, @@ -398,7 +371,7 @@ export class UserApi { return this.http.request(path, requestOptions); } - + /** * Logs user into the system * @@ -413,11 +386,11 @@ export class UserApi { if (username !== undefined) { queryParameters.set('username', username); } + if (password !== undefined) { queryParameters.set('password', password); } - // to determine the Content-Type header let consumes: string[] = [ ]; @@ -428,10 +401,6 @@ export class UserApi { 'application/xml' ]; - - - - let requestOptions: RequestOptionsArgs = new RequestOptions({ method: RequestMethod.Get, headers: headers, @@ -445,7 +414,7 @@ export class UserApi { return this.http.request(path, requestOptions); } - + /** * Logs out current logged in user session * @@ -455,8 +424,6 @@ export class UserApi { let queryParameters = new URLSearchParams(); let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845 - - // to determine the Content-Type header let consumes: string[] = [ ]; @@ -467,10 +434,6 @@ export class UserApi { 'application/xml' ]; - - - - let requestOptions: RequestOptionsArgs = new RequestOptions({ method: RequestMethod.Get, headers: headers, @@ -484,7 +447,7 @@ export class UserApi { return this.http.request(path, requestOptions); } - + /** * Updated user * This can only be done by the logged in user. @@ -500,8 +463,6 @@ export class UserApi { if (username === null || username === undefined) { throw new Error('Required parameter username was null or undefined when calling updateUser.'); } - - // to determine the Content-Type header let consumes: string[] = [ ]; @@ -512,11 +473,8 @@ export class UserApi { 'application/xml' ]; - - headers.set('Content-Type', 'application/json'); - let requestOptions: RequestOptionsArgs = new RequestOptions({ method: RequestMethod.Put, headers: headers, @@ -531,5 +489,5 @@ export class UserApi { return this.http.request(path, requestOptions); } - + } diff --git a/samples/client/petstore/typescript-angular2/npm/api/api.ts b/samples/client/petstore/typescript-angular2/npm/api/api.ts index dc2c6e4fafb..0d1e9f047fd 100644 --- a/samples/client/petstore/typescript-angular2/npm/api/api.ts +++ b/samples/client/petstore/typescript-angular2/npm/api/api.ts @@ -4,4 +4,4 @@ export * from './StoreApi'; import { StoreApi } from './StoreApi'; export * from './UserApi'; import { UserApi } from './UserApi'; -export const APIS = [PetApi,StoreApi,UserApi,]; +export const APIS = [ PetApi, StoreApi, UserApi, ]; diff --git a/samples/client/petstore/typescript-angular2/npm/package.json b/samples/client/petstore/typescript-angular2/npm/package.json index 4746328a611..e6d3d71d494 100644 --- a/samples/client/petstore/typescript-angular2/npm/package.json +++ b/samples/client/petstore/typescript-angular2/npm/package.json @@ -1,6 +1,6 @@ { "name": "@swagger/angular2-typescript-petstore", - "version": "0.0.1-SNAPSHOT.201701111140", + "version": "0.0.1-SNAPSHOT.201701111439", "description": "swagger client for @swagger/angular2-typescript-petstore", "author": "Swagger Codegen Contributors", "keywords": [