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}}
{{#formParams}}
if ({{paramName}} !== undefined) {
formParams.set('{{baseName}}', <any>{{paramName}});
{{#isListContainer}}
if ({{paramName}}) {
{{#isCollectionFormatMulti}}
{{paramName}}.forEach((element) => {
formParams.append('{{baseName}}', <any>element);
})
{{/isCollectionFormatMulti}}
{{^isCollectionFormatMulti}}
formParams.set('{{baseName}}', {{paramName}}.join(COLLECTION_FORMATS['{{collectionFormat}}']));
{{/isCollectionFormatMulti}}
}
{{/formParams}}
{{/isListContainer}}
{{^isListContainer}}
if ({{paramName}} !== undefined) {
formParams.set('{{baseName}}', <any>{{paramName}});
}
{{/isListContainer}}
{{/formParams}}
let requestOptions: RequestOptionsArgs = new RequestOptions({
method: {{httpMethod}},
headers: headers,
@ -184,7 +218,7 @@ export class {{classname}} {
return this.http.request(path, requestOptions);
}
{{/operation}}
}
{{/operations}}

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 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,
@ -241,7 +236,7 @@ export class PetApi {
return this.http.request(path, requestOptions);
}
/**
* Deletes a pet
*
@ -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,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,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,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,
@ -348,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.
@ -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,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,
@ -400,7 +384,7 @@ export class PetApi {
return this.http.request(path, requestOptions);
}
/**
* Find pet by ID
* Returns a pet when ID &lt; 10. ID &gt; 10 or nonintegers will simulate API error conditions
@ -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,
@ -458,7 +436,7 @@ export class PetApi {
return this.http.request(path, requestOptions);
}
/**
* Update an existing pet
*
@ -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,
@ -511,7 +484,7 @@ export class PetApi {
return this.http.request(path, requestOptions);
}
/**
* Updates a pet in the store with form data
*
@ -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,22 +516,21 @@ 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');
if (name !== undefined) {
formParams.set('name', <any>name);
formParams.set('name', <any>name);
}
if (status !== undefined) {
formParams.set('status', <any>status);
formParams.set('status', <any>status);
}
let requestOptions: RequestOptionsArgs = new RequestOptions({
@ -577,7 +547,7 @@ export class PetApi {
return this.http.request(path, requestOptions);
}
/**
* uploads an image
*
@ -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,22 +579,21 @@ 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');
if (additionalMetadata !== undefined) {
formParams.set('additionalMetadata', <any>additionalMetadata);
formParams.set('additionalMetadata', <any>additionalMetadata);
}
if (file !== undefined) {
formParams.set('file', <any>file);
formParams.set('file', <any>file);
}
let requestOptions: RequestOptionsArgs = new RequestOptions({
@ -643,5 +610,5 @@ export class PetApi {
return this.http.request(path, requestOptions);
}
}

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,
@ -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 &lt;&#x3D; 5 or &gt; 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);
}
}

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

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 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,
@ -241,7 +236,7 @@ export class PetApi {
return this.http.request(path, requestOptions);
}
/**
* Deletes a pet
*
@ -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,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,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,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,
@ -348,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.
@ -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,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,
@ -400,7 +384,7 @@ export class PetApi {
return this.http.request(path, requestOptions);
}
/**
* Find pet by ID
* Returns a pet when ID &lt; 10. ID &gt; 10 or nonintegers will simulate API error conditions
@ -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,
@ -458,7 +436,7 @@ export class PetApi {
return this.http.request(path, requestOptions);
}
/**
* Update an existing pet
*
@ -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,
@ -511,7 +484,7 @@ export class PetApi {
return this.http.request(path, requestOptions);
}
/**
* Updates a pet in the store with form data
*
@ -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,22 +516,21 @@ 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');
if (name !== undefined) {
formParams.set('name', <any>name);
formParams.set('name', <any>name);
}
if (status !== undefined) {
formParams.set('status', <any>status);
formParams.set('status', <any>status);
}
let requestOptions: RequestOptionsArgs = new RequestOptions({
@ -577,7 +547,7 @@ export class PetApi {
return this.http.request(path, requestOptions);
}
/**
* uploads an image
*
@ -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,22 +579,21 @@ 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');
if (additionalMetadata !== undefined) {
formParams.set('additionalMetadata', <any>additionalMetadata);
formParams.set('additionalMetadata', <any>additionalMetadata);
}
if (file !== undefined) {
formParams.set('file', <any>file);
formParams.set('file', <any>file);
}
let requestOptions: RequestOptionsArgs = new RequestOptions({
@ -643,5 +610,5 @@ export class PetApi {
return this.http.request(path, requestOptions);
}
}

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,
@ -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 &lt;&#x3D; 5 or &gt; 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);
}
}

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

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 BASE_PATH = new OpaqueToken('basePath');
export const COLLECTION_FORMATS = {
'csv': ',',
'tsv': ' ',
'ssv': ' ',
'pipes': '|'
}