Issue 4531 (#4539)

* 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.

* Added petstore samples

* Fixed indentations and coding style
This commit is contained in:
Richard Naeve 2017-01-13 16:41:54 +01:00 committed by wing328
parent d40f7a41b6
commit 2e7e25801d
15 changed files with 194 additions and 328 deletions

View File

@ -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 */
@ -93,15 +93,36 @@ export class {{classname}} {
{{/required}}
{{/allParams}}
{{#queryParams}}
{{#isListContainer}}
if ({{paramName}}) {
{{#isCollectionFormatMulti}}
{{paramName}}.forEach((element) => {
queryParameters.append('{{baseName}}', <any>element);
})
{{/isCollectionFormatMulti}}
{{^isCollectionFormatMulti}}
queryParameters.set('{{baseName}}', {{paramName}}.join(COLLECTION_FORMATS['{{collectionFormat}}']));
{{/isCollectionFormatMulti}}
}
{{/isListContainer}}
{{^isListContainer}}
if ({{paramName}} !== undefined) {
queryParameters.set('{{baseName}}', <any>{{paramName}});
}
{{/isListContainer}}
{{/queryParams}}
{{#headerParams}}
{{#isListContainer}}
if ({{paramName}}) {
headers.set('{{baseName}}', {{paramName}}.join(COLLECTION_FORMATS['{{collectionFormat}}']));
}
{{/isListContainer}}
{{^isListContainer}}
headers.set('{{baseName}}', String({{paramName}}));
{{/headerParams}}
{{/isListContainer}}
{{/headerParams}}
// to determine the Content-Type header
let consumes: string[] = [
{{#consumes}}
@ -120,51 +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}}', <any>element);
})
{{/isCollectionFormatMulti}}
{{^isCollectionFormatMulti}}
formParams.set('{{baseName}}', {{paramName}}.join(COLLECTION_FORMATS['{{collectionFormat}}']));
{{/isCollectionFormatMulti}}
}
{{/isListContainer}}
{{^isListContainer}}
if ({{paramName}} !== undefined) {
formParams.set('{{baseName}}', <any>{{paramName}});
}
{{/formParams}}
{{/isListContainer}}
{{/formParams}}
let requestOptions: RequestOptionsArgs = new RequestOptions({
method: {{httpMethod}},
headers: headers,

View File

@ -2,6 +2,8 @@
{{#apis}}
{{#operations}}
export * from './{{ classname }}';
import { {{ classname }} } from './{{ classname }}';
{{/operations}}
{{/apis}}
export const APIS = [ {{#apis}}{{#operations}}{{ classname }}, {{/operations}}{{/apis}}];
{{/apiInfo}}

View File

@ -1,3 +1,9 @@
import { OpaqueToken } from '@angular/core';
export const BASE_PATH = new OpaqueToken('basePath');
export const COLLECTION_FORMATS = {
'csv': ',',
'tsv': ' ',
'ssv': ' ',
'pipes': '|'
}

View File

@ -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 */
@ -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,
@ -257,7 +252,6 @@ 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));
// to determine the Content-Type header
@ -272,17 +266,13 @@ 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,
headers: headers,
@ -307,11 +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) {
queryParameters.set('status', <any>status);
if (status) {
status.forEach((element) => {
queryParameters.append('status', <any>element);
})
}
// to determine the Content-Type header
let consumes: string[] = [
];
@ -324,17 +315,13 @@ 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,
headers: headers,
@ -359,11 +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) {
queryParameters.set('tags', <any>tags);
if (tags) {
tags.forEach((element) => {
queryParameters.append('tags', <any>element);
})
}
// to determine the Content-Type header
let consumes: string[] = [
];
@ -376,17 +364,13 @@ 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,
headers: headers,
@ -415,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[] = [
];
@ -427,23 +409,19 @@ 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)
{
if (this.configuration.accessToken) {
let accessToken = typeof this.configuration.accessToken === 'function'
? this.configuration.accessToken()
: this.configuration.accessToken;
headers.set('Authorization', 'Bearer ' + accessToken);
}
// authentication (api_key) required
if (this.configuration.apiKey)
{
headers.set('api_key', this.configuration.apiKey);
}
let requestOptions: RequestOptionsArgs = new RequestOptions({
method: RequestMethod.Get,
@ -469,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',
@ -485,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,
@ -530,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'
@ -545,8 +516,7 @@ 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;
@ -555,10 +525,10 @@ export class PetApi {
headers.set('Content-Type', 'application/x-www-form-urlencoded');
if (name !== undefined) {
formParams.set('name', <any>name);
}
if (status !== undefined) {
formParams.set('status', <any>status);
}
@ -596,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'
@ -611,8 +579,7 @@ 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;
@ -621,10 +588,10 @@ export class PetApi {
headers.set('Content-Type', 'application/x-www-form-urlencoded');
if (additionalMetadata !== undefined) {
formParams.set('additionalMetadata', <any>additionalMetadata);
}
if (file !== undefined) {
formParams.set('file', <any>file);
}

View File

@ -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 */
@ -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,
@ -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,14 +177,10 @@ 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,
headers: headers,
@ -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,
@ -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,

View File

@ -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 */
@ -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,
@ -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,
@ -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,
@ -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,
@ -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,
@ -413,11 +386,11 @@ export class UserApi {
if (username !== undefined) {
queryParameters.set('username', <any>username);
}
if (password !== undefined) {
queryParameters.set('password', <any>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,
@ -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,
@ -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,

View File

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

View File

@ -1,3 +1,9 @@
import { OpaqueToken } from '@angular/core';
export const BASE_PATH = new OpaqueToken('basePath');
export const COLLECTION_FORMATS = {
'csv': ',',
'tsv': ' ',
'ssv': ' ',
'pipes': '|'
}

View File

@ -1,4 +1,4 @@
## @swagger/angular2-typescript-petstore@0.0.1-SNAPSHOT.201612150011
## @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.201612150011 --save
npm install @swagger/angular2-typescript-petstore@0.0.1-SNAPSHOT.201701111439 --save
```
_unPublished (not recommended):_

View File

@ -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 */
@ -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,
@ -257,7 +252,6 @@ 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));
// to determine the Content-Type header
@ -272,17 +266,13 @@ 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,
headers: headers,
@ -307,11 +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) {
queryParameters.set('status', <any>status);
if (status) {
status.forEach((element) => {
queryParameters.append('status', <any>element);
})
}
// to determine the Content-Type header
let consumes: string[] = [
];
@ -324,17 +315,13 @@ 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,
headers: headers,
@ -359,11 +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) {
queryParameters.set('tags', <any>tags);
if (tags) {
tags.forEach((element) => {
queryParameters.append('tags', <any>element);
})
}
// to determine the Content-Type header
let consumes: string[] = [
];
@ -376,17 +364,13 @@ 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,
headers: headers,
@ -415,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[] = [
];
@ -427,23 +409,19 @@ 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)
{
if (this.configuration.accessToken) {
let accessToken = typeof this.configuration.accessToken === 'function'
? this.configuration.accessToken()
: this.configuration.accessToken;
headers.set('Authorization', 'Bearer ' + accessToken);
}
// authentication (api_key) required
if (this.configuration.apiKey)
{
headers.set('api_key', this.configuration.apiKey);
}
let requestOptions: RequestOptionsArgs = new RequestOptions({
method: RequestMethod.Get,
@ -469,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',
@ -485,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,
@ -530,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'
@ -545,8 +516,7 @@ 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;
@ -555,10 +525,10 @@ export class PetApi {
headers.set('Content-Type', 'application/x-www-form-urlencoded');
if (name !== undefined) {
formParams.set('name', <any>name);
}
if (status !== undefined) {
formParams.set('status', <any>status);
}
@ -596,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'
@ -611,8 +579,7 @@ 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;
@ -621,10 +588,10 @@ export class PetApi {
headers.set('Content-Type', 'application/x-www-form-urlencoded');
if (additionalMetadata !== undefined) {
formParams.set('additionalMetadata', <any>additionalMetadata);
}
if (file !== undefined) {
formParams.set('file', <any>file);
}

View File

@ -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 */
@ -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,
@ -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,14 +177,10 @@ 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,
headers: headers,
@ -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,
@ -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,

View File

@ -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 */
@ -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,
@ -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,
@ -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,
@ -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,
@ -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,
@ -413,11 +386,11 @@ export class UserApi {
if (username !== undefined) {
queryParameters.set('username', <any>username);
}
if (password !== undefined) {
queryParameters.set('password', <any>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,
@ -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,
@ -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,

View File

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

View File

@ -1,6 +1,6 @@
{
"name": "@swagger/angular2-typescript-petstore",
"version": "0.0.1-SNAPSHOT.201612150011",
"version": "0.0.1-SNAPSHOT.201701111439",
"description": "swagger client for @swagger/angular2-typescript-petstore",
"author": "Swagger Codegen Contributors",
"keywords": [

View File

@ -1,3 +1,9 @@
import { OpaqueToken } from '@angular/core';
export const BASE_PATH = new OpaqueToken('basePath');
export const COLLECTION_FORMATS = {
'csv': ',',
'tsv': ' ',
'ssv': ' ',
'pipes': '|'
}