forked from loafle/openapi-generator-original
* fix map usage in api generation #3694 * fix map usage in api generation #3695 * close impl gap between queryParam and formParam, to be more consistent
This commit is contained in:
parent
f751e50e2e
commit
59891c7f66
@ -55,10 +55,10 @@ export class {{classname}} {
|
||||
{{/allParams}}
|
||||
{{#queryParams}}
|
||||
if ({{paramName}} !== undefined) {
|
||||
queryParameters.set('{{baseName}}', String({{paramName}}));
|
||||
queryParameters.set('{{baseName}}', <any>{{paramName}});
|
||||
}
|
||||
|
||||
{{/queryParams}}
|
||||
|
||||
{{#headers}}
|
||||
headers.set('{{baseName}}', String({{paramName}}));
|
||||
|
||||
@ -80,16 +80,18 @@ export class {{classname}} {
|
||||
|
||||
{{#hasFormParams}}
|
||||
headers.set('Content-Type', 'application/x-www-form-urlencoded');
|
||||
|
||||
{{/hasFormParams}}
|
||||
|
||||
{{#bodyParam}}
|
||||
headers.set('Content-Type', 'application/json');
|
||||
|
||||
{{/bodyParam}}
|
||||
{{#formParams}}
|
||||
formParams['{{baseName}}'] = {{paramName}};
|
||||
|
||||
{{#formParams}}
|
||||
if ({{paramName}} !== undefined) {
|
||||
formParams.set('{{baseName}}', <any>{{paramName}});
|
||||
}
|
||||
{{/formParams}}
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: {{httpMethod}},
|
||||
headers: headers,
|
||||
@ -115,4 +117,4 @@ export class {{classname}} {
|
||||
|
||||
{{/operation}}
|
||||
}
|
||||
{{/operations}}
|
||||
{{/operations}}
|
@ -22,22 +22,26 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {Http, Headers, RequestOptionsArgs, Response, URLSearchParams} from '@angular/http';
|
||||
import {Injectable, Optional} from '@angular/core';
|
||||
import {Observable} from 'rxjs/Observable';
|
||||
import * as models from '../model/models';
|
||||
import 'rxjs/Rx';
|
||||
import { Inject, Injectable, Optional } from '@angular/core';
|
||||
import { Http, Headers, URLSearchParams } from '@angular/http';
|
||||
import { RequestMethod, RequestOptions, RequestOptionsArgs } from '@angular/http';
|
||||
import { Response, ResponseContentType } from '@angular/http';
|
||||
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import 'rxjs/add/operator/map';
|
||||
|
||||
import * as models from '../model/models';
|
||||
import { BASE_PATH } from '../variables';
|
||||
|
||||
/* tslint:disable:no-unused-variable member-ordering */
|
||||
|
||||
'use strict';
|
||||
|
||||
@Injectable()
|
||||
export class PetApi {
|
||||
protected basePath = 'http://petstore.swagger.io/v2';
|
||||
public defaultHeaders : Headers = new Headers();
|
||||
public defaultHeaders: Headers = new Headers();
|
||||
|
||||
constructor(protected http: Http, @Optional() basePath: string) {
|
||||
constructor(protected http: Http, @Optional()@Inject(BASE_PATH) basePath: string) {
|
||||
if (basePath) {
|
||||
this.basePath = basePath;
|
||||
}
|
||||
@ -48,17 +52,37 @@ export class PetApi {
|
||||
*
|
||||
* @param body Pet object that needs to be added to the store
|
||||
*/
|
||||
public addPet (body?: models.Pet, extraHttpRequestParams?: any ) : Observable<{}> {
|
||||
const path = this.basePath + '/pet';
|
||||
public addPet(body?: models.Pet, extraHttpRequestParams?: any): Observable<{}> {
|
||||
const path = this.basePath + `/pet`;
|
||||
|
||||
let queryParameters = new URLSearchParams();
|
||||
let headerParams = this.defaultHeaders;
|
||||
let requestOptions: RequestOptionsArgs = {
|
||||
method: 'POST',
|
||||
headers: headerParams,
|
||||
search: queryParameters
|
||||
};
|
||||
requestOptions.body = JSON.stringify(body);
|
||||
let headers = new Headers(this.defaultHeaders.values()); // https://github.com/angular/angular/issues/6845
|
||||
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
'application/json',
|
||||
'application/xml'
|
||||
];
|
||||
|
||||
// to determine the Accept header
|
||||
let produces: string[] = [
|
||||
'application/json',
|
||||
'application/xml'
|
||||
];
|
||||
|
||||
|
||||
headers.set('Content-Type', 'application/json');
|
||||
|
||||
// add form parameters if provided
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Post,
|
||||
headers: headers,
|
||||
body: body == null ? '' : JSON.stringify(body), // https://github.com/angular/angular/issues/10612
|
||||
search: queryParameters,
|
||||
responseType: ResponseContentType.Json
|
||||
});
|
||||
|
||||
return this.http.request(path, requestOptions)
|
||||
.map((response: Response) => {
|
||||
@ -76,23 +100,37 @@ export class PetApi {
|
||||
* @param petId Pet id to delete
|
||||
* @param apiKey
|
||||
*/
|
||||
public deletePet (petId: number, apiKey?: string, extraHttpRequestParams?: any ) : Observable<{}> {
|
||||
const path = this.basePath + '/pet/{petId}'
|
||||
.replace('{' + 'petId' + '}', String(petId));
|
||||
public deletePet(petId: number, apiKey?: string, extraHttpRequestParams?: any): Observable<{}> {
|
||||
const path = this.basePath + `/pet/${petId}`;
|
||||
|
||||
let queryParameters = new URLSearchParams();
|
||||
let headerParams = this.defaultHeaders;
|
||||
let headers = new Headers(this.defaultHeaders.values()); // https://github.com/angular/angular/issues/6845
|
||||
// verify required parameter 'petId' is not null or undefined
|
||||
if (petId === null || petId === undefined) {
|
||||
throw new Error('Required parameter petId was null or undefined when calling deletePet.');
|
||||
}
|
||||
headerParams.set('api_key', String(apiKey));
|
||||
|
||||
let requestOptions: RequestOptionsArgs = {
|
||||
method: 'DELETE',
|
||||
headers: headerParams,
|
||||
search: queryParameters
|
||||
};
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
// to determine the Accept header
|
||||
let produces: string[] = [
|
||||
'application/json',
|
||||
'application/xml'
|
||||
];
|
||||
|
||||
|
||||
|
||||
// add form parameters if provided
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Delete,
|
||||
headers: headers,
|
||||
search: queryParameters,
|
||||
responseType: ResponseContentType.Json
|
||||
});
|
||||
|
||||
return this.http.request(path, requestOptions)
|
||||
.map((response: Response) => {
|
||||
@ -109,20 +147,36 @@ export class PetApi {
|
||||
* Multiple status values can be provided with comma separated strings
|
||||
* @param status Status values that need to be considered for filter
|
||||
*/
|
||||
public findPetsByStatus (status?: Array<string>, extraHttpRequestParams?: any ) : Observable<Array<models.Pet>> {
|
||||
const path = this.basePath + '/pet/findByStatus';
|
||||
public findPetsByStatus(status?: Array<string>, extraHttpRequestParams?: any): Observable<Array<models.Pet>> {
|
||||
const path = this.basePath + `/pet/findByStatus`;
|
||||
|
||||
let queryParameters = new URLSearchParams();
|
||||
let headerParams = this.defaultHeaders;
|
||||
let headers = new Headers(this.defaultHeaders.values()); // https://github.com/angular/angular/issues/6845
|
||||
if (status !== undefined) {
|
||||
queryParameters.set('status', String(status));
|
||||
queryParameters.set('status', <any>status);
|
||||
}
|
||||
|
||||
let requestOptions: RequestOptionsArgs = {
|
||||
method: 'GET',
|
||||
headers: headerParams,
|
||||
search: queryParameters
|
||||
};
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
// to determine the Accept header
|
||||
let produces: string[] = [
|
||||
'application/json',
|
||||
'application/xml'
|
||||
];
|
||||
|
||||
|
||||
|
||||
// add form parameters if provided
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Get,
|
||||
headers: headers,
|
||||
search: queryParameters,
|
||||
responseType: ResponseContentType.Json
|
||||
});
|
||||
|
||||
return this.http.request(path, requestOptions)
|
||||
.map((response: Response) => {
|
||||
@ -139,20 +193,36 @@ export class PetApi {
|
||||
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
||||
* @param tags Tags to filter by
|
||||
*/
|
||||
public findPetsByTags (tags?: Array<string>, extraHttpRequestParams?: any ) : Observable<Array<models.Pet>> {
|
||||
const path = this.basePath + '/pet/findByTags';
|
||||
public findPetsByTags(tags?: Array<string>, extraHttpRequestParams?: any): Observable<Array<models.Pet>> {
|
||||
const path = this.basePath + `/pet/findByTags`;
|
||||
|
||||
let queryParameters = new URLSearchParams();
|
||||
let headerParams = this.defaultHeaders;
|
||||
let headers = new Headers(this.defaultHeaders.values()); // https://github.com/angular/angular/issues/6845
|
||||
if (tags !== undefined) {
|
||||
queryParameters.set('tags', String(tags));
|
||||
queryParameters.set('tags', <any>tags);
|
||||
}
|
||||
|
||||
let requestOptions: RequestOptionsArgs = {
|
||||
method: 'GET',
|
||||
headers: headerParams,
|
||||
search: queryParameters
|
||||
};
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
// to determine the Accept header
|
||||
let produces: string[] = [
|
||||
'application/json',
|
||||
'application/xml'
|
||||
];
|
||||
|
||||
|
||||
|
||||
// add form parameters if provided
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Get,
|
||||
headers: headers,
|
||||
search: queryParameters,
|
||||
responseType: ResponseContentType.Json
|
||||
});
|
||||
|
||||
return this.http.request(path, requestOptions)
|
||||
.map((response: Response) => {
|
||||
@ -169,21 +239,37 @@ export class PetApi {
|
||||
* Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions
|
||||
* @param petId ID of pet that needs to be fetched
|
||||
*/
|
||||
public getPetById (petId: number, extraHttpRequestParams?: any ) : Observable<models.Pet> {
|
||||
const path = this.basePath + '/pet/{petId}'
|
||||
.replace('{' + 'petId' + '}', String(petId));
|
||||
public getPetById(petId: number, extraHttpRequestParams?: any): Observable<models.Pet> {
|
||||
const path = this.basePath + `/pet/${petId}`;
|
||||
|
||||
let queryParameters = new URLSearchParams();
|
||||
let headerParams = this.defaultHeaders;
|
||||
let headers = new Headers(this.defaultHeaders.values()); // https://github.com/angular/angular/issues/6845
|
||||
// verify required parameter 'petId' is not null or undefined
|
||||
if (petId === null || petId === undefined) {
|
||||
throw new Error('Required parameter petId was null or undefined when calling getPetById.');
|
||||
}
|
||||
let requestOptions: RequestOptionsArgs = {
|
||||
method: 'GET',
|
||||
headers: headerParams,
|
||||
search: queryParameters
|
||||
};
|
||||
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
// to determine the Accept header
|
||||
let produces: string[] = [
|
||||
'application/json',
|
||||
'application/xml'
|
||||
];
|
||||
|
||||
|
||||
|
||||
// add form parameters if provided
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Get,
|
||||
headers: headers,
|
||||
search: queryParameters,
|
||||
responseType: ResponseContentType.Json
|
||||
});
|
||||
|
||||
return this.http.request(path, requestOptions)
|
||||
.map((response: Response) => {
|
||||
@ -200,17 +286,37 @@ export class PetApi {
|
||||
*
|
||||
* @param body Pet object that needs to be added to the store
|
||||
*/
|
||||
public updatePet (body?: models.Pet, extraHttpRequestParams?: any ) : Observable<{}> {
|
||||
const path = this.basePath + '/pet';
|
||||
public updatePet(body?: models.Pet, extraHttpRequestParams?: any): Observable<{}> {
|
||||
const path = this.basePath + `/pet`;
|
||||
|
||||
let queryParameters = new URLSearchParams();
|
||||
let headerParams = this.defaultHeaders;
|
||||
let requestOptions: RequestOptionsArgs = {
|
||||
method: 'PUT',
|
||||
headers: headerParams,
|
||||
search: queryParameters
|
||||
};
|
||||
requestOptions.body = JSON.stringify(body);
|
||||
let headers = new Headers(this.defaultHeaders.values()); // https://github.com/angular/angular/issues/6845
|
||||
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
'application/json',
|
||||
'application/xml'
|
||||
];
|
||||
|
||||
// to determine the Accept header
|
||||
let produces: string[] = [
|
||||
'application/json',
|
||||
'application/xml'
|
||||
];
|
||||
|
||||
|
||||
headers.set('Content-Type', 'application/json');
|
||||
|
||||
// add form parameters if provided
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Put,
|
||||
headers: headers,
|
||||
body: body == null ? '' : JSON.stringify(body), // https://github.com/angular/angular/issues/10612
|
||||
search: queryParameters,
|
||||
responseType: ResponseContentType.Json
|
||||
});
|
||||
|
||||
return this.http.request(path, requestOptions)
|
||||
.map((response: Response) => {
|
||||
@ -229,30 +335,48 @@ export class PetApi {
|
||||
* @param name Updated name of the pet
|
||||
* @param status Updated status of the pet
|
||||
*/
|
||||
public updatePetWithForm (petId: string, name?: string, status?: string, extraHttpRequestParams?: any ) : Observable<{}> {
|
||||
const path = this.basePath + '/pet/{petId}'
|
||||
.replace('{' + 'petId' + '}', String(petId));
|
||||
public updatePetWithForm(petId: string, name?: string, status?: string, extraHttpRequestParams?: any): Observable<{}> {
|
||||
const path = this.basePath + `/pet/${petId}`;
|
||||
|
||||
let queryParameters = new URLSearchParams();
|
||||
let headerParams = this.defaultHeaders;
|
||||
let headers = new Headers(this.defaultHeaders.values()); // https://github.com/angular/angular/issues/6845
|
||||
let formParams = new URLSearchParams();
|
||||
|
||||
// verify required parameter 'petId' is not null or undefined
|
||||
if (petId === null || petId === undefined) {
|
||||
throw new Error('Required parameter petId was null or undefined when calling updatePetWithForm.');
|
||||
}
|
||||
headerParams.set('Content-Type', 'application/x-www-form-urlencoded');
|
||||
|
||||
formParams['name'] = name;
|
||||
|
||||
formParams['status'] = status;
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
'application/x-www-form-urlencoded'
|
||||
];
|
||||
|
||||
let requestOptions: RequestOptionsArgs = {
|
||||
method: 'POST',
|
||||
headers: headerParams,
|
||||
search: queryParameters
|
||||
};
|
||||
requestOptions.body = formParams.toString();
|
||||
// to determine the Accept header
|
||||
let produces: string[] = [
|
||||
'application/json',
|
||||
'application/xml'
|
||||
];
|
||||
|
||||
headers.set('Content-Type', 'application/x-www-form-urlencoded');
|
||||
|
||||
|
||||
// add form parameters if provided
|
||||
if (name !== undefined) {
|
||||
formParams.set('name', <any>name);
|
||||
}
|
||||
if (status !== undefined) {
|
||||
formParams.set('status', <any>status);
|
||||
}
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Post,
|
||||
headers: headers,
|
||||
body: formParams.toString(),
|
||||
search: queryParameters,
|
||||
responseType: ResponseContentType.Json
|
||||
});
|
||||
|
||||
return this.http.request(path, requestOptions)
|
||||
.map((response: Response) => {
|
||||
@ -271,30 +395,48 @@ export class PetApi {
|
||||
* @param additionalMetadata Additional data to pass to server
|
||||
* @param file file to upload
|
||||
*/
|
||||
public uploadFile (petId: number, additionalMetadata?: string, file?: any, extraHttpRequestParams?: any ) : Observable<{}> {
|
||||
const path = this.basePath + '/pet/{petId}/uploadImage'
|
||||
.replace('{' + 'petId' + '}', String(petId));
|
||||
public uploadFile(petId: number, additionalMetadata?: string, file?: any, extraHttpRequestParams?: any): Observable<{}> {
|
||||
const path = this.basePath + `/pet/${petId}/uploadImage`;
|
||||
|
||||
let queryParameters = new URLSearchParams();
|
||||
let headerParams = this.defaultHeaders;
|
||||
let headers = new Headers(this.defaultHeaders.values()); // https://github.com/angular/angular/issues/6845
|
||||
let formParams = new URLSearchParams();
|
||||
|
||||
// verify required parameter 'petId' is not null or undefined
|
||||
if (petId === null || petId === undefined) {
|
||||
throw new Error('Required parameter petId was null or undefined when calling uploadFile.');
|
||||
}
|
||||
headerParams.set('Content-Type', 'application/x-www-form-urlencoded');
|
||||
|
||||
formParams['additionalMetadata'] = additionalMetadata;
|
||||
|
||||
formParams['file'] = file;
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
'multipart/form-data'
|
||||
];
|
||||
|
||||
let requestOptions: RequestOptionsArgs = {
|
||||
method: 'POST',
|
||||
headers: headerParams,
|
||||
search: queryParameters
|
||||
};
|
||||
requestOptions.body = formParams.toString();
|
||||
// to determine the Accept header
|
||||
let produces: string[] = [
|
||||
'application/json',
|
||||
'application/xml'
|
||||
];
|
||||
|
||||
headers.set('Content-Type', 'application/x-www-form-urlencoded');
|
||||
|
||||
|
||||
// add form parameters if provided
|
||||
if (additionalMetadata !== undefined) {
|
||||
formParams.set('additionalMetadata', <any>additionalMetadata);
|
||||
}
|
||||
if (file !== undefined) {
|
||||
formParams.set('file', <any>file);
|
||||
}
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Post,
|
||||
headers: headers,
|
||||
body: formParams.toString(),
|
||||
search: queryParameters,
|
||||
responseType: ResponseContentType.Json
|
||||
});
|
||||
|
||||
return this.http.request(path, requestOptions)
|
||||
.map((response: Response) => {
|
||||
|
@ -22,22 +22,26 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {Http, Headers, RequestOptionsArgs, Response, URLSearchParams} from '@angular/http';
|
||||
import {Injectable, Optional} from '@angular/core';
|
||||
import {Observable} from 'rxjs/Observable';
|
||||
import * as models from '../model/models';
|
||||
import 'rxjs/Rx';
|
||||
import { Inject, Injectable, Optional } from '@angular/core';
|
||||
import { Http, Headers, URLSearchParams } from '@angular/http';
|
||||
import { RequestMethod, RequestOptions, RequestOptionsArgs } from '@angular/http';
|
||||
import { Response, ResponseContentType } from '@angular/http';
|
||||
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import 'rxjs/add/operator/map';
|
||||
|
||||
import * as models from '../model/models';
|
||||
import { BASE_PATH } from '../variables';
|
||||
|
||||
/* tslint:disable:no-unused-variable member-ordering */
|
||||
|
||||
'use strict';
|
||||
|
||||
@Injectable()
|
||||
export class StoreApi {
|
||||
protected basePath = 'http://petstore.swagger.io/v2';
|
||||
public defaultHeaders : Headers = new Headers();
|
||||
public defaultHeaders: Headers = new Headers();
|
||||
|
||||
constructor(protected http: Http, @Optional() basePath: string) {
|
||||
constructor(protected http: Http, @Optional()@Inject(BASE_PATH) basePath: string) {
|
||||
if (basePath) {
|
||||
this.basePath = basePath;
|
||||
}
|
||||
@ -48,21 +52,37 @@ export class StoreApi {
|
||||
* For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||
* @param orderId ID of the order that needs to be deleted
|
||||
*/
|
||||
public deleteOrder (orderId: string, extraHttpRequestParams?: any ) : Observable<{}> {
|
||||
const path = this.basePath + '/store/order/{orderId}'
|
||||
.replace('{' + 'orderId' + '}', String(orderId));
|
||||
public deleteOrder(orderId: string, extraHttpRequestParams?: any): Observable<{}> {
|
||||
const path = this.basePath + `/store/order/${orderId}`;
|
||||
|
||||
let queryParameters = new URLSearchParams();
|
||||
let headerParams = this.defaultHeaders;
|
||||
let headers = new Headers(this.defaultHeaders.values()); // https://github.com/angular/angular/issues/6845
|
||||
// verify required parameter 'orderId' is not null or undefined
|
||||
if (orderId === null || orderId === undefined) {
|
||||
throw new Error('Required parameter orderId was null or undefined when calling deleteOrder.');
|
||||
}
|
||||
let requestOptions: RequestOptionsArgs = {
|
||||
method: 'DELETE',
|
||||
headers: headerParams,
|
||||
search: queryParameters
|
||||
};
|
||||
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
// to determine the Accept header
|
||||
let produces: string[] = [
|
||||
'application/json',
|
||||
'application/xml'
|
||||
];
|
||||
|
||||
|
||||
|
||||
// add form parameters if provided
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Delete,
|
||||
headers: headers,
|
||||
search: queryParameters,
|
||||
responseType: ResponseContentType.Json
|
||||
});
|
||||
|
||||
return this.http.request(path, requestOptions)
|
||||
.map((response: Response) => {
|
||||
@ -78,16 +98,33 @@ export class StoreApi {
|
||||
* Returns pet inventories by status
|
||||
* Returns a map of status codes to quantities
|
||||
*/
|
||||
public getInventory (extraHttpRequestParams?: any ) : Observable<{ [key: string]: number; }> {
|
||||
const path = this.basePath + '/store/inventory';
|
||||
public getInventory(extraHttpRequestParams?: any): Observable<{ [key: string]: number; }> {
|
||||
const path = this.basePath + `/store/inventory`;
|
||||
|
||||
let queryParameters = new URLSearchParams();
|
||||
let headerParams = this.defaultHeaders;
|
||||
let requestOptions: RequestOptionsArgs = {
|
||||
method: 'GET',
|
||||
headers: headerParams,
|
||||
search: queryParameters
|
||||
};
|
||||
let headers = new Headers(this.defaultHeaders.values()); // https://github.com/angular/angular/issues/6845
|
||||
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
// to determine the Accept header
|
||||
let produces: string[] = [
|
||||
'application/json',
|
||||
'application/xml'
|
||||
];
|
||||
|
||||
|
||||
|
||||
// add form parameters if provided
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Get,
|
||||
headers: headers,
|
||||
search: queryParameters,
|
||||
responseType: ResponseContentType.Json
|
||||
});
|
||||
|
||||
return this.http.request(path, requestOptions)
|
||||
.map((response: Response) => {
|
||||
@ -104,21 +141,37 @@ export class StoreApi {
|
||||
* For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||
* @param orderId ID of pet that needs to be fetched
|
||||
*/
|
||||
public getOrderById (orderId: string, extraHttpRequestParams?: any ) : Observable<models.Order> {
|
||||
const path = this.basePath + '/store/order/{orderId}'
|
||||
.replace('{' + 'orderId' + '}', String(orderId));
|
||||
public getOrderById(orderId: string, extraHttpRequestParams?: any): Observable<models.Order> {
|
||||
const path = this.basePath + `/store/order/${orderId}`;
|
||||
|
||||
let queryParameters = new URLSearchParams();
|
||||
let headerParams = this.defaultHeaders;
|
||||
let headers = new Headers(this.defaultHeaders.values()); // https://github.com/angular/angular/issues/6845
|
||||
// verify required parameter 'orderId' is not null or undefined
|
||||
if (orderId === null || orderId === undefined) {
|
||||
throw new Error('Required parameter orderId was null or undefined when calling getOrderById.');
|
||||
}
|
||||
let requestOptions: RequestOptionsArgs = {
|
||||
method: 'GET',
|
||||
headers: headerParams,
|
||||
search: queryParameters
|
||||
};
|
||||
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
// to determine the Accept header
|
||||
let produces: string[] = [
|
||||
'application/json',
|
||||
'application/xml'
|
||||
];
|
||||
|
||||
|
||||
|
||||
// add form parameters if provided
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Get,
|
||||
headers: headers,
|
||||
search: queryParameters,
|
||||
responseType: ResponseContentType.Json
|
||||
});
|
||||
|
||||
return this.http.request(path, requestOptions)
|
||||
.map((response: Response) => {
|
||||
@ -135,17 +188,35 @@ export class StoreApi {
|
||||
*
|
||||
* @param body order placed for purchasing the pet
|
||||
*/
|
||||
public placeOrder (body?: models.Order, extraHttpRequestParams?: any ) : Observable<models.Order> {
|
||||
const path = this.basePath + '/store/order';
|
||||
public placeOrder(body?: models.Order, extraHttpRequestParams?: any): Observable<models.Order> {
|
||||
const path = this.basePath + `/store/order`;
|
||||
|
||||
let queryParameters = new URLSearchParams();
|
||||
let headerParams = this.defaultHeaders;
|
||||
let requestOptions: RequestOptionsArgs = {
|
||||
method: 'POST',
|
||||
headers: headerParams,
|
||||
search: queryParameters
|
||||
};
|
||||
requestOptions.body = JSON.stringify(body);
|
||||
let headers = new Headers(this.defaultHeaders.values()); // https://github.com/angular/angular/issues/6845
|
||||
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
// to determine the Accept header
|
||||
let produces: string[] = [
|
||||
'application/json',
|
||||
'application/xml'
|
||||
];
|
||||
|
||||
|
||||
headers.set('Content-Type', 'application/json');
|
||||
|
||||
// add form parameters if provided
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Post,
|
||||
headers: headers,
|
||||
body: body == null ? '' : JSON.stringify(body), // https://github.com/angular/angular/issues/10612
|
||||
search: queryParameters,
|
||||
responseType: ResponseContentType.Json
|
||||
});
|
||||
|
||||
return this.http.request(path, requestOptions)
|
||||
.map((response: Response) => {
|
||||
|
@ -22,22 +22,26 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {Http, Headers, RequestOptionsArgs, Response, URLSearchParams} from '@angular/http';
|
||||
import {Injectable, Optional} from '@angular/core';
|
||||
import {Observable} from 'rxjs/Observable';
|
||||
import * as models from '../model/models';
|
||||
import 'rxjs/Rx';
|
||||
import { Inject, Injectable, Optional } from '@angular/core';
|
||||
import { Http, Headers, URLSearchParams } from '@angular/http';
|
||||
import { RequestMethod, RequestOptions, RequestOptionsArgs } from '@angular/http';
|
||||
import { Response, ResponseContentType } from '@angular/http';
|
||||
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import 'rxjs/add/operator/map';
|
||||
|
||||
import * as models from '../model/models';
|
||||
import { BASE_PATH } from '../variables';
|
||||
|
||||
/* tslint:disable:no-unused-variable member-ordering */
|
||||
|
||||
'use strict';
|
||||
|
||||
@Injectable()
|
||||
export class UserApi {
|
||||
protected basePath = 'http://petstore.swagger.io/v2';
|
||||
public defaultHeaders : Headers = new Headers();
|
||||
public defaultHeaders: Headers = new Headers();
|
||||
|
||||
constructor(protected http: Http, @Optional() basePath: string) {
|
||||
constructor(protected http: Http, @Optional()@Inject(BASE_PATH) basePath: string) {
|
||||
if (basePath) {
|
||||
this.basePath = basePath;
|
||||
}
|
||||
@ -48,17 +52,35 @@ export class UserApi {
|
||||
* This can only be done by the logged in user.
|
||||
* @param body Created user object
|
||||
*/
|
||||
public createUser (body?: models.User, extraHttpRequestParams?: any ) : Observable<{}> {
|
||||
const path = this.basePath + '/user';
|
||||
public createUser(body?: models.User, extraHttpRequestParams?: any): Observable<{}> {
|
||||
const path = this.basePath + `/user`;
|
||||
|
||||
let queryParameters = new URLSearchParams();
|
||||
let headerParams = this.defaultHeaders;
|
||||
let requestOptions: RequestOptionsArgs = {
|
||||
method: 'POST',
|
||||
headers: headerParams,
|
||||
search: queryParameters
|
||||
};
|
||||
requestOptions.body = JSON.stringify(body);
|
||||
let headers = new Headers(this.defaultHeaders.values()); // https://github.com/angular/angular/issues/6845
|
||||
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
// to determine the Accept header
|
||||
let produces: string[] = [
|
||||
'application/json',
|
||||
'application/xml'
|
||||
];
|
||||
|
||||
|
||||
headers.set('Content-Type', 'application/json');
|
||||
|
||||
// add form parameters if provided
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Post,
|
||||
headers: headers,
|
||||
body: body == null ? '' : JSON.stringify(body), // https://github.com/angular/angular/issues/10612
|
||||
search: queryParameters,
|
||||
responseType: ResponseContentType.Json
|
||||
});
|
||||
|
||||
return this.http.request(path, requestOptions)
|
||||
.map((response: Response) => {
|
||||
@ -75,17 +97,35 @@ export class UserApi {
|
||||
*
|
||||
* @param body List of user object
|
||||
*/
|
||||
public createUsersWithArrayInput (body?: Array<models.User>, extraHttpRequestParams?: any ) : Observable<{}> {
|
||||
const path = this.basePath + '/user/createWithArray';
|
||||
public createUsersWithArrayInput(body?: Array<models.User>, extraHttpRequestParams?: any): Observable<{}> {
|
||||
const path = this.basePath + `/user/createWithArray`;
|
||||
|
||||
let queryParameters = new URLSearchParams();
|
||||
let headerParams = this.defaultHeaders;
|
||||
let requestOptions: RequestOptionsArgs = {
|
||||
method: 'POST',
|
||||
headers: headerParams,
|
||||
search: queryParameters
|
||||
};
|
||||
requestOptions.body = JSON.stringify(body);
|
||||
let headers = new Headers(this.defaultHeaders.values()); // https://github.com/angular/angular/issues/6845
|
||||
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
// to determine the Accept header
|
||||
let produces: string[] = [
|
||||
'application/json',
|
||||
'application/xml'
|
||||
];
|
||||
|
||||
|
||||
headers.set('Content-Type', 'application/json');
|
||||
|
||||
// add form parameters if provided
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Post,
|
||||
headers: headers,
|
||||
body: body == null ? '' : JSON.stringify(body), // https://github.com/angular/angular/issues/10612
|
||||
search: queryParameters,
|
||||
responseType: ResponseContentType.Json
|
||||
});
|
||||
|
||||
return this.http.request(path, requestOptions)
|
||||
.map((response: Response) => {
|
||||
@ -102,17 +142,35 @@ export class UserApi {
|
||||
*
|
||||
* @param body List of user object
|
||||
*/
|
||||
public createUsersWithListInput (body?: Array<models.User>, extraHttpRequestParams?: any ) : Observable<{}> {
|
||||
const path = this.basePath + '/user/createWithList';
|
||||
public createUsersWithListInput(body?: Array<models.User>, extraHttpRequestParams?: any): Observable<{}> {
|
||||
const path = this.basePath + `/user/createWithList`;
|
||||
|
||||
let queryParameters = new URLSearchParams();
|
||||
let headerParams = this.defaultHeaders;
|
||||
let requestOptions: RequestOptionsArgs = {
|
||||
method: 'POST',
|
||||
headers: headerParams,
|
||||
search: queryParameters
|
||||
};
|
||||
requestOptions.body = JSON.stringify(body);
|
||||
let headers = new Headers(this.defaultHeaders.values()); // https://github.com/angular/angular/issues/6845
|
||||
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
// to determine the Accept header
|
||||
let produces: string[] = [
|
||||
'application/json',
|
||||
'application/xml'
|
||||
];
|
||||
|
||||
|
||||
headers.set('Content-Type', 'application/json');
|
||||
|
||||
// add form parameters if provided
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Post,
|
||||
headers: headers,
|
||||
body: body == null ? '' : JSON.stringify(body), // https://github.com/angular/angular/issues/10612
|
||||
search: queryParameters,
|
||||
responseType: ResponseContentType.Json
|
||||
});
|
||||
|
||||
return this.http.request(path, requestOptions)
|
||||
.map((response: Response) => {
|
||||
@ -129,21 +187,37 @@ export class UserApi {
|
||||
* This can only be done by the logged in user.
|
||||
* @param username The name that needs to be deleted
|
||||
*/
|
||||
public deleteUser (username: string, extraHttpRequestParams?: any ) : Observable<{}> {
|
||||
const path = this.basePath + '/user/{username}'
|
||||
.replace('{' + 'username' + '}', String(username));
|
||||
public deleteUser(username: string, extraHttpRequestParams?: any): Observable<{}> {
|
||||
const path = this.basePath + `/user/${username}`;
|
||||
|
||||
let queryParameters = new URLSearchParams();
|
||||
let headerParams = this.defaultHeaders;
|
||||
let headers = new Headers(this.defaultHeaders.values()); // https://github.com/angular/angular/issues/6845
|
||||
// verify required parameter 'username' is not null or undefined
|
||||
if (username === null || username === undefined) {
|
||||
throw new Error('Required parameter username was null or undefined when calling deleteUser.');
|
||||
}
|
||||
let requestOptions: RequestOptionsArgs = {
|
||||
method: 'DELETE',
|
||||
headers: headerParams,
|
||||
search: queryParameters
|
||||
};
|
||||
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
// to determine the Accept header
|
||||
let produces: string[] = [
|
||||
'application/json',
|
||||
'application/xml'
|
||||
];
|
||||
|
||||
|
||||
|
||||
// add form parameters if provided
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Delete,
|
||||
headers: headers,
|
||||
search: queryParameters,
|
||||
responseType: ResponseContentType.Json
|
||||
});
|
||||
|
||||
return this.http.request(path, requestOptions)
|
||||
.map((response: Response) => {
|
||||
@ -160,21 +234,37 @@ export class UserApi {
|
||||
*
|
||||
* @param username The name that needs to be fetched. Use user1 for testing.
|
||||
*/
|
||||
public getUserByName (username: string, extraHttpRequestParams?: any ) : Observable<models.User> {
|
||||
const path = this.basePath + '/user/{username}'
|
||||
.replace('{' + 'username' + '}', String(username));
|
||||
public getUserByName(username: string, extraHttpRequestParams?: any): Observable<models.User> {
|
||||
const path = this.basePath + `/user/${username}`;
|
||||
|
||||
let queryParameters = new URLSearchParams();
|
||||
let headerParams = this.defaultHeaders;
|
||||
let headers = new Headers(this.defaultHeaders.values()); // https://github.com/angular/angular/issues/6845
|
||||
// verify required parameter 'username' is not null or undefined
|
||||
if (username === null || username === undefined) {
|
||||
throw new Error('Required parameter username was null or undefined when calling getUserByName.');
|
||||
}
|
||||
let requestOptions: RequestOptionsArgs = {
|
||||
method: 'GET',
|
||||
headers: headerParams,
|
||||
search: queryParameters
|
||||
};
|
||||
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
// to determine the Accept header
|
||||
let produces: string[] = [
|
||||
'application/json',
|
||||
'application/xml'
|
||||
];
|
||||
|
||||
|
||||
|
||||
// add form parameters if provided
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Get,
|
||||
headers: headers,
|
||||
search: queryParameters,
|
||||
responseType: ResponseContentType.Json
|
||||
});
|
||||
|
||||
return this.http.request(path, requestOptions)
|
||||
.map((response: Response) => {
|
||||
@ -192,24 +282,39 @@ export class UserApi {
|
||||
* @param username The user name for login
|
||||
* @param password The password for login in clear text
|
||||
*/
|
||||
public loginUser (username?: string, password?: string, extraHttpRequestParams?: any ) : Observable<string> {
|
||||
const path = this.basePath + '/user/login';
|
||||
public loginUser(username?: string, password?: string, extraHttpRequestParams?: any): Observable<string> {
|
||||
const path = this.basePath + `/user/login`;
|
||||
|
||||
let queryParameters = new URLSearchParams();
|
||||
let headerParams = this.defaultHeaders;
|
||||
let headers = new Headers(this.defaultHeaders.values()); // https://github.com/angular/angular/issues/6845
|
||||
if (username !== undefined) {
|
||||
queryParameters.set('username', String(username));
|
||||
queryParameters.set('username', <any>username);
|
||||
}
|
||||
|
||||
if (password !== undefined) {
|
||||
queryParameters.set('password', String(password));
|
||||
queryParameters.set('password', <any>password);
|
||||
}
|
||||
|
||||
let requestOptions: RequestOptionsArgs = {
|
||||
method: 'GET',
|
||||
headers: headerParams,
|
||||
search: queryParameters
|
||||
};
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
// to determine the Accept header
|
||||
let produces: string[] = [
|
||||
'application/json',
|
||||
'application/xml'
|
||||
];
|
||||
|
||||
|
||||
|
||||
// add form parameters if provided
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Get,
|
||||
headers: headers,
|
||||
search: queryParameters,
|
||||
responseType: ResponseContentType.Json
|
||||
});
|
||||
|
||||
return this.http.request(path, requestOptions)
|
||||
.map((response: Response) => {
|
||||
@ -225,16 +330,33 @@ export class UserApi {
|
||||
* Logs out current logged in user session
|
||||
*
|
||||
*/
|
||||
public logoutUser (extraHttpRequestParams?: any ) : Observable<{}> {
|
||||
const path = this.basePath + '/user/logout';
|
||||
public logoutUser(extraHttpRequestParams?: any): Observable<{}> {
|
||||
const path = this.basePath + `/user/logout`;
|
||||
|
||||
let queryParameters = new URLSearchParams();
|
||||
let headerParams = this.defaultHeaders;
|
||||
let requestOptions: RequestOptionsArgs = {
|
||||
method: 'GET',
|
||||
headers: headerParams,
|
||||
search: queryParameters
|
||||
};
|
||||
let headers = new Headers(this.defaultHeaders.values()); // https://github.com/angular/angular/issues/6845
|
||||
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
// to determine the Accept header
|
||||
let produces: string[] = [
|
||||
'application/json',
|
||||
'application/xml'
|
||||
];
|
||||
|
||||
|
||||
|
||||
// add form parameters if provided
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Get,
|
||||
headers: headers,
|
||||
search: queryParameters,
|
||||
responseType: ResponseContentType.Json
|
||||
});
|
||||
|
||||
return this.http.request(path, requestOptions)
|
||||
.map((response: Response) => {
|
||||
@ -252,22 +374,39 @@ export class UserApi {
|
||||
* @param username name that need to be deleted
|
||||
* @param body Updated user object
|
||||
*/
|
||||
public updateUser (username: string, body?: models.User, extraHttpRequestParams?: any ) : Observable<{}> {
|
||||
const path = this.basePath + '/user/{username}'
|
||||
.replace('{' + 'username' + '}', String(username));
|
||||
public updateUser(username: string, body?: models.User, extraHttpRequestParams?: any): Observable<{}> {
|
||||
const path = this.basePath + `/user/${username}`;
|
||||
|
||||
let queryParameters = new URLSearchParams();
|
||||
let headerParams = this.defaultHeaders;
|
||||
let headers = new Headers(this.defaultHeaders.values()); // https://github.com/angular/angular/issues/6845
|
||||
// verify required parameter 'username' is not null or undefined
|
||||
if (username === null || username === undefined) {
|
||||
throw new Error('Required parameter username was null or undefined when calling updateUser.');
|
||||
}
|
||||
let requestOptions: RequestOptionsArgs = {
|
||||
method: 'PUT',
|
||||
headers: headerParams,
|
||||
search: queryParameters
|
||||
};
|
||||
requestOptions.body = JSON.stringify(body);
|
||||
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
// to determine the Accept header
|
||||
let produces: string[] = [
|
||||
'application/json',
|
||||
'application/xml'
|
||||
];
|
||||
|
||||
|
||||
headers.set('Content-Type', 'application/json');
|
||||
|
||||
// add form parameters if provided
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Put,
|
||||
headers: headers,
|
||||
body: body == null ? '' : JSON.stringify(body), // https://github.com/angular/angular/issues/10612
|
||||
search: queryParameters,
|
||||
responseType: ResponseContentType.Json
|
||||
});
|
||||
|
||||
return this.http.request(path, requestOptions)
|
||||
.map((response: Response) => {
|
||||
|
@ -1,2 +1,3 @@
|
||||
export * from './api/api';
|
||||
export * from './model/models';
|
||||
export * from './model/models';
|
||||
export * from './variables';
|
@ -22,7 +22,6 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
import * as models from './models';
|
||||
|
||||
export interface Category {
|
||||
|
@ -22,7 +22,6 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
import * as models from './models';
|
||||
|
||||
export interface Order {
|
||||
|
@ -22,7 +22,6 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
import * as models from './models';
|
||||
|
||||
export interface Pet {
|
||||
|
@ -22,7 +22,6 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
import * as models from './models';
|
||||
|
||||
export interface Tag {
|
||||
|
@ -22,7 +22,6 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
import * as models from './models';
|
||||
|
||||
export interface User {
|
||||
|
@ -1,4 +1,4 @@
|
||||
## @swagger/angular2-typescript-petstore@0.0.1-SNAPSHOT.201608052320
|
||||
## @swagger/angular2-typescript-petstore@0.0.1-SNAPSHOT.201609051239
|
||||
|
||||
### 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.201608052320 --save
|
||||
npm install @swagger/angular2-typescript-petstore@0.0.1-SNAPSHOT.201609051239 --save
|
||||
```
|
||||
|
||||
_unPublished (not recommended):_
|
||||
@ -31,3 +31,14 @@ npm install PATH_TO_GENERATED_PACKAGE --save
|
||||
In your angular2 project:
|
||||
|
||||
TODO: paste example.
|
||||
|
||||
### Set service base path
|
||||
If different than the generated base path, during app bootstrap, you can provide the base path to your service.
|
||||
|
||||
```
|
||||
import { BASE_PATH } from './path-to-swagger-gen-service/index';
|
||||
|
||||
bootstrap(AppComponent, [
|
||||
{ provide: BASE_PATH, useValue: 'https://your-web-service.com' },
|
||||
]);
|
||||
```
|
@ -22,22 +22,26 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {Http, Headers, RequestOptionsArgs, Response, URLSearchParams} from '@angular/http';
|
||||
import {Injectable, Optional} from '@angular/core';
|
||||
import {Observable} from 'rxjs/Observable';
|
||||
import * as models from '../model/models';
|
||||
import 'rxjs/Rx';
|
||||
import { Inject, Injectable, Optional } from '@angular/core';
|
||||
import { Http, Headers, URLSearchParams } from '@angular/http';
|
||||
import { RequestMethod, RequestOptions, RequestOptionsArgs } from '@angular/http';
|
||||
import { Response, ResponseContentType } from '@angular/http';
|
||||
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import 'rxjs/add/operator/map';
|
||||
|
||||
import * as models from '../model/models';
|
||||
import { BASE_PATH } from '../variables';
|
||||
|
||||
/* tslint:disable:no-unused-variable member-ordering */
|
||||
|
||||
'use strict';
|
||||
|
||||
@Injectable()
|
||||
export class PetApi {
|
||||
protected basePath = 'http://petstore.swagger.io/v2';
|
||||
public defaultHeaders : Headers = new Headers();
|
||||
public defaultHeaders: Headers = new Headers();
|
||||
|
||||
constructor(protected http: Http, @Optional() basePath: string) {
|
||||
constructor(protected http: Http, @Optional()@Inject(BASE_PATH) basePath: string) {
|
||||
if (basePath) {
|
||||
this.basePath = basePath;
|
||||
}
|
||||
@ -48,17 +52,37 @@ export class PetApi {
|
||||
*
|
||||
* @param body Pet object that needs to be added to the store
|
||||
*/
|
||||
public addPet (body?: models.Pet, extraHttpRequestParams?: any ) : Observable<{}> {
|
||||
const path = this.basePath + '/pet';
|
||||
public addPet(body?: models.Pet, extraHttpRequestParams?: any): Observable<{}> {
|
||||
const path = this.basePath + `/pet`;
|
||||
|
||||
let queryParameters = new URLSearchParams();
|
||||
let headerParams = this.defaultHeaders;
|
||||
let requestOptions: RequestOptionsArgs = {
|
||||
method: 'POST',
|
||||
headers: headerParams,
|
||||
search: queryParameters
|
||||
};
|
||||
requestOptions.body = JSON.stringify(body);
|
||||
let headers = new Headers(this.defaultHeaders.values()); // https://github.com/angular/angular/issues/6845
|
||||
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
'application/json',
|
||||
'application/xml'
|
||||
];
|
||||
|
||||
// to determine the Accept header
|
||||
let produces: string[] = [
|
||||
'application/json',
|
||||
'application/xml'
|
||||
];
|
||||
|
||||
|
||||
headers.set('Content-Type', 'application/json');
|
||||
|
||||
// add form parameters if provided
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Post,
|
||||
headers: headers,
|
||||
body: body == null ? '' : JSON.stringify(body), // https://github.com/angular/angular/issues/10612
|
||||
search: queryParameters,
|
||||
responseType: ResponseContentType.Json
|
||||
});
|
||||
|
||||
return this.http.request(path, requestOptions)
|
||||
.map((response: Response) => {
|
||||
@ -76,23 +100,37 @@ export class PetApi {
|
||||
* @param petId Pet id to delete
|
||||
* @param apiKey
|
||||
*/
|
||||
public deletePet (petId: number, apiKey?: string, extraHttpRequestParams?: any ) : Observable<{}> {
|
||||
const path = this.basePath + '/pet/{petId}'
|
||||
.replace('{' + 'petId' + '}', String(petId));
|
||||
public deletePet(petId: number, apiKey?: string, extraHttpRequestParams?: any): Observable<{}> {
|
||||
const path = this.basePath + `/pet/${petId}`;
|
||||
|
||||
let queryParameters = new URLSearchParams();
|
||||
let headerParams = this.defaultHeaders;
|
||||
let headers = new Headers(this.defaultHeaders.values()); // https://github.com/angular/angular/issues/6845
|
||||
// verify required parameter 'petId' is not null or undefined
|
||||
if (petId === null || petId === undefined) {
|
||||
throw new Error('Required parameter petId was null or undefined when calling deletePet.');
|
||||
}
|
||||
headerParams.set('api_key', String(apiKey));
|
||||
|
||||
let requestOptions: RequestOptionsArgs = {
|
||||
method: 'DELETE',
|
||||
headers: headerParams,
|
||||
search: queryParameters
|
||||
};
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
// to determine the Accept header
|
||||
let produces: string[] = [
|
||||
'application/json',
|
||||
'application/xml'
|
||||
];
|
||||
|
||||
|
||||
|
||||
// add form parameters if provided
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Delete,
|
||||
headers: headers,
|
||||
search: queryParameters,
|
||||
responseType: ResponseContentType.Json
|
||||
});
|
||||
|
||||
return this.http.request(path, requestOptions)
|
||||
.map((response: Response) => {
|
||||
@ -109,20 +147,36 @@ export class PetApi {
|
||||
* Multiple status values can be provided with comma separated strings
|
||||
* @param status Status values that need to be considered for filter
|
||||
*/
|
||||
public findPetsByStatus (status?: Array<string>, extraHttpRequestParams?: any ) : Observable<Array<models.Pet>> {
|
||||
const path = this.basePath + '/pet/findByStatus';
|
||||
public findPetsByStatus(status?: Array<string>, extraHttpRequestParams?: any): Observable<Array<models.Pet>> {
|
||||
const path = this.basePath + `/pet/findByStatus`;
|
||||
|
||||
let queryParameters = new URLSearchParams();
|
||||
let headerParams = this.defaultHeaders;
|
||||
let headers = new Headers(this.defaultHeaders.values()); // https://github.com/angular/angular/issues/6845
|
||||
if (status !== undefined) {
|
||||
queryParameters.set('status', String(status));
|
||||
queryParameters.set('status', <any>status);
|
||||
}
|
||||
|
||||
let requestOptions: RequestOptionsArgs = {
|
||||
method: 'GET',
|
||||
headers: headerParams,
|
||||
search: queryParameters
|
||||
};
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
// to determine the Accept header
|
||||
let produces: string[] = [
|
||||
'application/json',
|
||||
'application/xml'
|
||||
];
|
||||
|
||||
|
||||
|
||||
// add form parameters if provided
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Get,
|
||||
headers: headers,
|
||||
search: queryParameters,
|
||||
responseType: ResponseContentType.Json
|
||||
});
|
||||
|
||||
return this.http.request(path, requestOptions)
|
||||
.map((response: Response) => {
|
||||
@ -139,20 +193,36 @@ export class PetApi {
|
||||
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
||||
* @param tags Tags to filter by
|
||||
*/
|
||||
public findPetsByTags (tags?: Array<string>, extraHttpRequestParams?: any ) : Observable<Array<models.Pet>> {
|
||||
const path = this.basePath + '/pet/findByTags';
|
||||
public findPetsByTags(tags?: Array<string>, extraHttpRequestParams?: any): Observable<Array<models.Pet>> {
|
||||
const path = this.basePath + `/pet/findByTags`;
|
||||
|
||||
let queryParameters = new URLSearchParams();
|
||||
let headerParams = this.defaultHeaders;
|
||||
let headers = new Headers(this.defaultHeaders.values()); // https://github.com/angular/angular/issues/6845
|
||||
if (tags !== undefined) {
|
||||
queryParameters.set('tags', String(tags));
|
||||
queryParameters.set('tags', <any>tags);
|
||||
}
|
||||
|
||||
let requestOptions: RequestOptionsArgs = {
|
||||
method: 'GET',
|
||||
headers: headerParams,
|
||||
search: queryParameters
|
||||
};
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
// to determine the Accept header
|
||||
let produces: string[] = [
|
||||
'application/json',
|
||||
'application/xml'
|
||||
];
|
||||
|
||||
|
||||
|
||||
// add form parameters if provided
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Get,
|
||||
headers: headers,
|
||||
search: queryParameters,
|
||||
responseType: ResponseContentType.Json
|
||||
});
|
||||
|
||||
return this.http.request(path, requestOptions)
|
||||
.map((response: Response) => {
|
||||
@ -169,21 +239,37 @@ export class PetApi {
|
||||
* Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions
|
||||
* @param petId ID of pet that needs to be fetched
|
||||
*/
|
||||
public getPetById (petId: number, extraHttpRequestParams?: any ) : Observable<models.Pet> {
|
||||
const path = this.basePath + '/pet/{petId}'
|
||||
.replace('{' + 'petId' + '}', String(petId));
|
||||
public getPetById(petId: number, extraHttpRequestParams?: any): Observable<models.Pet> {
|
||||
const path = this.basePath + `/pet/${petId}`;
|
||||
|
||||
let queryParameters = new URLSearchParams();
|
||||
let headerParams = this.defaultHeaders;
|
||||
let headers = new Headers(this.defaultHeaders.values()); // https://github.com/angular/angular/issues/6845
|
||||
// verify required parameter 'petId' is not null or undefined
|
||||
if (petId === null || petId === undefined) {
|
||||
throw new Error('Required parameter petId was null or undefined when calling getPetById.');
|
||||
}
|
||||
let requestOptions: RequestOptionsArgs = {
|
||||
method: 'GET',
|
||||
headers: headerParams,
|
||||
search: queryParameters
|
||||
};
|
||||
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
// to determine the Accept header
|
||||
let produces: string[] = [
|
||||
'application/json',
|
||||
'application/xml'
|
||||
];
|
||||
|
||||
|
||||
|
||||
// add form parameters if provided
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Get,
|
||||
headers: headers,
|
||||
search: queryParameters,
|
||||
responseType: ResponseContentType.Json
|
||||
});
|
||||
|
||||
return this.http.request(path, requestOptions)
|
||||
.map((response: Response) => {
|
||||
@ -200,17 +286,37 @@ export class PetApi {
|
||||
*
|
||||
* @param body Pet object that needs to be added to the store
|
||||
*/
|
||||
public updatePet (body?: models.Pet, extraHttpRequestParams?: any ) : Observable<{}> {
|
||||
const path = this.basePath + '/pet';
|
||||
public updatePet(body?: models.Pet, extraHttpRequestParams?: any): Observable<{}> {
|
||||
const path = this.basePath + `/pet`;
|
||||
|
||||
let queryParameters = new URLSearchParams();
|
||||
let headerParams = this.defaultHeaders;
|
||||
let requestOptions: RequestOptionsArgs = {
|
||||
method: 'PUT',
|
||||
headers: headerParams,
|
||||
search: queryParameters
|
||||
};
|
||||
requestOptions.body = JSON.stringify(body);
|
||||
let headers = new Headers(this.defaultHeaders.values()); // https://github.com/angular/angular/issues/6845
|
||||
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
'application/json',
|
||||
'application/xml'
|
||||
];
|
||||
|
||||
// to determine the Accept header
|
||||
let produces: string[] = [
|
||||
'application/json',
|
||||
'application/xml'
|
||||
];
|
||||
|
||||
|
||||
headers.set('Content-Type', 'application/json');
|
||||
|
||||
// add form parameters if provided
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Put,
|
||||
headers: headers,
|
||||
body: body == null ? '' : JSON.stringify(body), // https://github.com/angular/angular/issues/10612
|
||||
search: queryParameters,
|
||||
responseType: ResponseContentType.Json
|
||||
});
|
||||
|
||||
return this.http.request(path, requestOptions)
|
||||
.map((response: Response) => {
|
||||
@ -229,30 +335,48 @@ export class PetApi {
|
||||
* @param name Updated name of the pet
|
||||
* @param status Updated status of the pet
|
||||
*/
|
||||
public updatePetWithForm (petId: string, name?: string, status?: string, extraHttpRequestParams?: any ) : Observable<{}> {
|
||||
const path = this.basePath + '/pet/{petId}'
|
||||
.replace('{' + 'petId' + '}', String(petId));
|
||||
public updatePetWithForm(petId: string, name?: string, status?: string, extraHttpRequestParams?: any): Observable<{}> {
|
||||
const path = this.basePath + `/pet/${petId}`;
|
||||
|
||||
let queryParameters = new URLSearchParams();
|
||||
let headerParams = this.defaultHeaders;
|
||||
let headers = new Headers(this.defaultHeaders.values()); // https://github.com/angular/angular/issues/6845
|
||||
let formParams = new URLSearchParams();
|
||||
|
||||
// verify required parameter 'petId' is not null or undefined
|
||||
if (petId === null || petId === undefined) {
|
||||
throw new Error('Required parameter petId was null or undefined when calling updatePetWithForm.');
|
||||
}
|
||||
headerParams.set('Content-Type', 'application/x-www-form-urlencoded');
|
||||
|
||||
formParams['name'] = name;
|
||||
|
||||
formParams['status'] = status;
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
'application/x-www-form-urlencoded'
|
||||
];
|
||||
|
||||
let requestOptions: RequestOptionsArgs = {
|
||||
method: 'POST',
|
||||
headers: headerParams,
|
||||
search: queryParameters
|
||||
};
|
||||
requestOptions.body = formParams.toString();
|
||||
// to determine the Accept header
|
||||
let produces: string[] = [
|
||||
'application/json',
|
||||
'application/xml'
|
||||
];
|
||||
|
||||
headers.set('Content-Type', 'application/x-www-form-urlencoded');
|
||||
|
||||
|
||||
// add form parameters if provided
|
||||
if (name !== undefined) {
|
||||
formParams.set('name', <any>name);
|
||||
}
|
||||
if (status !== undefined) {
|
||||
formParams.set('status', <any>status);
|
||||
}
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Post,
|
||||
headers: headers,
|
||||
body: formParams.toString(),
|
||||
search: queryParameters,
|
||||
responseType: ResponseContentType.Json
|
||||
});
|
||||
|
||||
return this.http.request(path, requestOptions)
|
||||
.map((response: Response) => {
|
||||
@ -271,30 +395,48 @@ export class PetApi {
|
||||
* @param additionalMetadata Additional data to pass to server
|
||||
* @param file file to upload
|
||||
*/
|
||||
public uploadFile (petId: number, additionalMetadata?: string, file?: any, extraHttpRequestParams?: any ) : Observable<{}> {
|
||||
const path = this.basePath + '/pet/{petId}/uploadImage'
|
||||
.replace('{' + 'petId' + '}', String(petId));
|
||||
public uploadFile(petId: number, additionalMetadata?: string, file?: any, extraHttpRequestParams?: any): Observable<{}> {
|
||||
const path = this.basePath + `/pet/${petId}/uploadImage`;
|
||||
|
||||
let queryParameters = new URLSearchParams();
|
||||
let headerParams = this.defaultHeaders;
|
||||
let headers = new Headers(this.defaultHeaders.values()); // https://github.com/angular/angular/issues/6845
|
||||
let formParams = new URLSearchParams();
|
||||
|
||||
// verify required parameter 'petId' is not null or undefined
|
||||
if (petId === null || petId === undefined) {
|
||||
throw new Error('Required parameter petId was null or undefined when calling uploadFile.');
|
||||
}
|
||||
headerParams.set('Content-Type', 'application/x-www-form-urlencoded');
|
||||
|
||||
formParams['additionalMetadata'] = additionalMetadata;
|
||||
|
||||
formParams['file'] = file;
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
'multipart/form-data'
|
||||
];
|
||||
|
||||
let requestOptions: RequestOptionsArgs = {
|
||||
method: 'POST',
|
||||
headers: headerParams,
|
||||
search: queryParameters
|
||||
};
|
||||
requestOptions.body = formParams.toString();
|
||||
// to determine the Accept header
|
||||
let produces: string[] = [
|
||||
'application/json',
|
||||
'application/xml'
|
||||
];
|
||||
|
||||
headers.set('Content-Type', 'application/x-www-form-urlencoded');
|
||||
|
||||
|
||||
// add form parameters if provided
|
||||
if (additionalMetadata !== undefined) {
|
||||
formParams.set('additionalMetadata', <any>additionalMetadata);
|
||||
}
|
||||
if (file !== undefined) {
|
||||
formParams.set('file', <any>file);
|
||||
}
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Post,
|
||||
headers: headers,
|
||||
body: formParams.toString(),
|
||||
search: queryParameters,
|
||||
responseType: ResponseContentType.Json
|
||||
});
|
||||
|
||||
return this.http.request(path, requestOptions)
|
||||
.map((response: Response) => {
|
||||
|
@ -22,22 +22,26 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {Http, Headers, RequestOptionsArgs, Response, URLSearchParams} from '@angular/http';
|
||||
import {Injectable, Optional} from '@angular/core';
|
||||
import {Observable} from 'rxjs/Observable';
|
||||
import * as models from '../model/models';
|
||||
import 'rxjs/Rx';
|
||||
import { Inject, Injectable, Optional } from '@angular/core';
|
||||
import { Http, Headers, URLSearchParams } from '@angular/http';
|
||||
import { RequestMethod, RequestOptions, RequestOptionsArgs } from '@angular/http';
|
||||
import { Response, ResponseContentType } from '@angular/http';
|
||||
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import 'rxjs/add/operator/map';
|
||||
|
||||
import * as models from '../model/models';
|
||||
import { BASE_PATH } from '../variables';
|
||||
|
||||
/* tslint:disable:no-unused-variable member-ordering */
|
||||
|
||||
'use strict';
|
||||
|
||||
@Injectable()
|
||||
export class StoreApi {
|
||||
protected basePath = 'http://petstore.swagger.io/v2';
|
||||
public defaultHeaders : Headers = new Headers();
|
||||
public defaultHeaders: Headers = new Headers();
|
||||
|
||||
constructor(protected http: Http, @Optional() basePath: string) {
|
||||
constructor(protected http: Http, @Optional()@Inject(BASE_PATH) basePath: string) {
|
||||
if (basePath) {
|
||||
this.basePath = basePath;
|
||||
}
|
||||
@ -48,21 +52,37 @@ export class StoreApi {
|
||||
* For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||
* @param orderId ID of the order that needs to be deleted
|
||||
*/
|
||||
public deleteOrder (orderId: string, extraHttpRequestParams?: any ) : Observable<{}> {
|
||||
const path = this.basePath + '/store/order/{orderId}'
|
||||
.replace('{' + 'orderId' + '}', String(orderId));
|
||||
public deleteOrder(orderId: string, extraHttpRequestParams?: any): Observable<{}> {
|
||||
const path = this.basePath + `/store/order/${orderId}`;
|
||||
|
||||
let queryParameters = new URLSearchParams();
|
||||
let headerParams = this.defaultHeaders;
|
||||
let headers = new Headers(this.defaultHeaders.values()); // https://github.com/angular/angular/issues/6845
|
||||
// verify required parameter 'orderId' is not null or undefined
|
||||
if (orderId === null || orderId === undefined) {
|
||||
throw new Error('Required parameter orderId was null or undefined when calling deleteOrder.');
|
||||
}
|
||||
let requestOptions: RequestOptionsArgs = {
|
||||
method: 'DELETE',
|
||||
headers: headerParams,
|
||||
search: queryParameters
|
||||
};
|
||||
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
// to determine the Accept header
|
||||
let produces: string[] = [
|
||||
'application/json',
|
||||
'application/xml'
|
||||
];
|
||||
|
||||
|
||||
|
||||
// add form parameters if provided
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Delete,
|
||||
headers: headers,
|
||||
search: queryParameters,
|
||||
responseType: ResponseContentType.Json
|
||||
});
|
||||
|
||||
return this.http.request(path, requestOptions)
|
||||
.map((response: Response) => {
|
||||
@ -78,16 +98,33 @@ export class StoreApi {
|
||||
* Returns pet inventories by status
|
||||
* Returns a map of status codes to quantities
|
||||
*/
|
||||
public getInventory (extraHttpRequestParams?: any ) : Observable<{ [key: string]: number; }> {
|
||||
const path = this.basePath + '/store/inventory';
|
||||
public getInventory(extraHttpRequestParams?: any): Observable<{ [key: string]: number; }> {
|
||||
const path = this.basePath + `/store/inventory`;
|
||||
|
||||
let queryParameters = new URLSearchParams();
|
||||
let headerParams = this.defaultHeaders;
|
||||
let requestOptions: RequestOptionsArgs = {
|
||||
method: 'GET',
|
||||
headers: headerParams,
|
||||
search: queryParameters
|
||||
};
|
||||
let headers = new Headers(this.defaultHeaders.values()); // https://github.com/angular/angular/issues/6845
|
||||
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
// to determine the Accept header
|
||||
let produces: string[] = [
|
||||
'application/json',
|
||||
'application/xml'
|
||||
];
|
||||
|
||||
|
||||
|
||||
// add form parameters if provided
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Get,
|
||||
headers: headers,
|
||||
search: queryParameters,
|
||||
responseType: ResponseContentType.Json
|
||||
});
|
||||
|
||||
return this.http.request(path, requestOptions)
|
||||
.map((response: Response) => {
|
||||
@ -104,21 +141,37 @@ export class StoreApi {
|
||||
* For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||
* @param orderId ID of pet that needs to be fetched
|
||||
*/
|
||||
public getOrderById (orderId: string, extraHttpRequestParams?: any ) : Observable<models.Order> {
|
||||
const path = this.basePath + '/store/order/{orderId}'
|
||||
.replace('{' + 'orderId' + '}', String(orderId));
|
||||
public getOrderById(orderId: string, extraHttpRequestParams?: any): Observable<models.Order> {
|
||||
const path = this.basePath + `/store/order/${orderId}`;
|
||||
|
||||
let queryParameters = new URLSearchParams();
|
||||
let headerParams = this.defaultHeaders;
|
||||
let headers = new Headers(this.defaultHeaders.values()); // https://github.com/angular/angular/issues/6845
|
||||
// verify required parameter 'orderId' is not null or undefined
|
||||
if (orderId === null || orderId === undefined) {
|
||||
throw new Error('Required parameter orderId was null or undefined when calling getOrderById.');
|
||||
}
|
||||
let requestOptions: RequestOptionsArgs = {
|
||||
method: 'GET',
|
||||
headers: headerParams,
|
||||
search: queryParameters
|
||||
};
|
||||
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
// to determine the Accept header
|
||||
let produces: string[] = [
|
||||
'application/json',
|
||||
'application/xml'
|
||||
];
|
||||
|
||||
|
||||
|
||||
// add form parameters if provided
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Get,
|
||||
headers: headers,
|
||||
search: queryParameters,
|
||||
responseType: ResponseContentType.Json
|
||||
});
|
||||
|
||||
return this.http.request(path, requestOptions)
|
||||
.map((response: Response) => {
|
||||
@ -135,17 +188,35 @@ export class StoreApi {
|
||||
*
|
||||
* @param body order placed for purchasing the pet
|
||||
*/
|
||||
public placeOrder (body?: models.Order, extraHttpRequestParams?: any ) : Observable<models.Order> {
|
||||
const path = this.basePath + '/store/order';
|
||||
public placeOrder(body?: models.Order, extraHttpRequestParams?: any): Observable<models.Order> {
|
||||
const path = this.basePath + `/store/order`;
|
||||
|
||||
let queryParameters = new URLSearchParams();
|
||||
let headerParams = this.defaultHeaders;
|
||||
let requestOptions: RequestOptionsArgs = {
|
||||
method: 'POST',
|
||||
headers: headerParams,
|
||||
search: queryParameters
|
||||
};
|
||||
requestOptions.body = JSON.stringify(body);
|
||||
let headers = new Headers(this.defaultHeaders.values()); // https://github.com/angular/angular/issues/6845
|
||||
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
// to determine the Accept header
|
||||
let produces: string[] = [
|
||||
'application/json',
|
||||
'application/xml'
|
||||
];
|
||||
|
||||
|
||||
headers.set('Content-Type', 'application/json');
|
||||
|
||||
// add form parameters if provided
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Post,
|
||||
headers: headers,
|
||||
body: body == null ? '' : JSON.stringify(body), // https://github.com/angular/angular/issues/10612
|
||||
search: queryParameters,
|
||||
responseType: ResponseContentType.Json
|
||||
});
|
||||
|
||||
return this.http.request(path, requestOptions)
|
||||
.map((response: Response) => {
|
||||
|
@ -22,22 +22,26 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {Http, Headers, RequestOptionsArgs, Response, URLSearchParams} from '@angular/http';
|
||||
import {Injectable, Optional} from '@angular/core';
|
||||
import {Observable} from 'rxjs/Observable';
|
||||
import * as models from '../model/models';
|
||||
import 'rxjs/Rx';
|
||||
import { Inject, Injectable, Optional } from '@angular/core';
|
||||
import { Http, Headers, URLSearchParams } from '@angular/http';
|
||||
import { RequestMethod, RequestOptions, RequestOptionsArgs } from '@angular/http';
|
||||
import { Response, ResponseContentType } from '@angular/http';
|
||||
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import 'rxjs/add/operator/map';
|
||||
|
||||
import * as models from '../model/models';
|
||||
import { BASE_PATH } from '../variables';
|
||||
|
||||
/* tslint:disable:no-unused-variable member-ordering */
|
||||
|
||||
'use strict';
|
||||
|
||||
@Injectable()
|
||||
export class UserApi {
|
||||
protected basePath = 'http://petstore.swagger.io/v2';
|
||||
public defaultHeaders : Headers = new Headers();
|
||||
public defaultHeaders: Headers = new Headers();
|
||||
|
||||
constructor(protected http: Http, @Optional() basePath: string) {
|
||||
constructor(protected http: Http, @Optional()@Inject(BASE_PATH) basePath: string) {
|
||||
if (basePath) {
|
||||
this.basePath = basePath;
|
||||
}
|
||||
@ -48,17 +52,35 @@ export class UserApi {
|
||||
* This can only be done by the logged in user.
|
||||
* @param body Created user object
|
||||
*/
|
||||
public createUser (body?: models.User, extraHttpRequestParams?: any ) : Observable<{}> {
|
||||
const path = this.basePath + '/user';
|
||||
public createUser(body?: models.User, extraHttpRequestParams?: any): Observable<{}> {
|
||||
const path = this.basePath + `/user`;
|
||||
|
||||
let queryParameters = new URLSearchParams();
|
||||
let headerParams = this.defaultHeaders;
|
||||
let requestOptions: RequestOptionsArgs = {
|
||||
method: 'POST',
|
||||
headers: headerParams,
|
||||
search: queryParameters
|
||||
};
|
||||
requestOptions.body = JSON.stringify(body);
|
||||
let headers = new Headers(this.defaultHeaders.values()); // https://github.com/angular/angular/issues/6845
|
||||
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
// to determine the Accept header
|
||||
let produces: string[] = [
|
||||
'application/json',
|
||||
'application/xml'
|
||||
];
|
||||
|
||||
|
||||
headers.set('Content-Type', 'application/json');
|
||||
|
||||
// add form parameters if provided
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Post,
|
||||
headers: headers,
|
||||
body: body == null ? '' : JSON.stringify(body), // https://github.com/angular/angular/issues/10612
|
||||
search: queryParameters,
|
||||
responseType: ResponseContentType.Json
|
||||
});
|
||||
|
||||
return this.http.request(path, requestOptions)
|
||||
.map((response: Response) => {
|
||||
@ -75,17 +97,35 @@ export class UserApi {
|
||||
*
|
||||
* @param body List of user object
|
||||
*/
|
||||
public createUsersWithArrayInput (body?: Array<models.User>, extraHttpRequestParams?: any ) : Observable<{}> {
|
||||
const path = this.basePath + '/user/createWithArray';
|
||||
public createUsersWithArrayInput(body?: Array<models.User>, extraHttpRequestParams?: any): Observable<{}> {
|
||||
const path = this.basePath + `/user/createWithArray`;
|
||||
|
||||
let queryParameters = new URLSearchParams();
|
||||
let headerParams = this.defaultHeaders;
|
||||
let requestOptions: RequestOptionsArgs = {
|
||||
method: 'POST',
|
||||
headers: headerParams,
|
||||
search: queryParameters
|
||||
};
|
||||
requestOptions.body = JSON.stringify(body);
|
||||
let headers = new Headers(this.defaultHeaders.values()); // https://github.com/angular/angular/issues/6845
|
||||
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
// to determine the Accept header
|
||||
let produces: string[] = [
|
||||
'application/json',
|
||||
'application/xml'
|
||||
];
|
||||
|
||||
|
||||
headers.set('Content-Type', 'application/json');
|
||||
|
||||
// add form parameters if provided
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Post,
|
||||
headers: headers,
|
||||
body: body == null ? '' : JSON.stringify(body), // https://github.com/angular/angular/issues/10612
|
||||
search: queryParameters,
|
||||
responseType: ResponseContentType.Json
|
||||
});
|
||||
|
||||
return this.http.request(path, requestOptions)
|
||||
.map((response: Response) => {
|
||||
@ -102,17 +142,35 @@ export class UserApi {
|
||||
*
|
||||
* @param body List of user object
|
||||
*/
|
||||
public createUsersWithListInput (body?: Array<models.User>, extraHttpRequestParams?: any ) : Observable<{}> {
|
||||
const path = this.basePath + '/user/createWithList';
|
||||
public createUsersWithListInput(body?: Array<models.User>, extraHttpRequestParams?: any): Observable<{}> {
|
||||
const path = this.basePath + `/user/createWithList`;
|
||||
|
||||
let queryParameters = new URLSearchParams();
|
||||
let headerParams = this.defaultHeaders;
|
||||
let requestOptions: RequestOptionsArgs = {
|
||||
method: 'POST',
|
||||
headers: headerParams,
|
||||
search: queryParameters
|
||||
};
|
||||
requestOptions.body = JSON.stringify(body);
|
||||
let headers = new Headers(this.defaultHeaders.values()); // https://github.com/angular/angular/issues/6845
|
||||
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
// to determine the Accept header
|
||||
let produces: string[] = [
|
||||
'application/json',
|
||||
'application/xml'
|
||||
];
|
||||
|
||||
|
||||
headers.set('Content-Type', 'application/json');
|
||||
|
||||
// add form parameters if provided
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Post,
|
||||
headers: headers,
|
||||
body: body == null ? '' : JSON.stringify(body), // https://github.com/angular/angular/issues/10612
|
||||
search: queryParameters,
|
||||
responseType: ResponseContentType.Json
|
||||
});
|
||||
|
||||
return this.http.request(path, requestOptions)
|
||||
.map((response: Response) => {
|
||||
@ -129,21 +187,37 @@ export class UserApi {
|
||||
* This can only be done by the logged in user.
|
||||
* @param username The name that needs to be deleted
|
||||
*/
|
||||
public deleteUser (username: string, extraHttpRequestParams?: any ) : Observable<{}> {
|
||||
const path = this.basePath + '/user/{username}'
|
||||
.replace('{' + 'username' + '}', String(username));
|
||||
public deleteUser(username: string, extraHttpRequestParams?: any): Observable<{}> {
|
||||
const path = this.basePath + `/user/${username}`;
|
||||
|
||||
let queryParameters = new URLSearchParams();
|
||||
let headerParams = this.defaultHeaders;
|
||||
let headers = new Headers(this.defaultHeaders.values()); // https://github.com/angular/angular/issues/6845
|
||||
// verify required parameter 'username' is not null or undefined
|
||||
if (username === null || username === undefined) {
|
||||
throw new Error('Required parameter username was null or undefined when calling deleteUser.');
|
||||
}
|
||||
let requestOptions: RequestOptionsArgs = {
|
||||
method: 'DELETE',
|
||||
headers: headerParams,
|
||||
search: queryParameters
|
||||
};
|
||||
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
// to determine the Accept header
|
||||
let produces: string[] = [
|
||||
'application/json',
|
||||
'application/xml'
|
||||
];
|
||||
|
||||
|
||||
|
||||
// add form parameters if provided
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Delete,
|
||||
headers: headers,
|
||||
search: queryParameters,
|
||||
responseType: ResponseContentType.Json
|
||||
});
|
||||
|
||||
return this.http.request(path, requestOptions)
|
||||
.map((response: Response) => {
|
||||
@ -160,21 +234,37 @@ export class UserApi {
|
||||
*
|
||||
* @param username The name that needs to be fetched. Use user1 for testing.
|
||||
*/
|
||||
public getUserByName (username: string, extraHttpRequestParams?: any ) : Observable<models.User> {
|
||||
const path = this.basePath + '/user/{username}'
|
||||
.replace('{' + 'username' + '}', String(username));
|
||||
public getUserByName(username: string, extraHttpRequestParams?: any): Observable<models.User> {
|
||||
const path = this.basePath + `/user/${username}`;
|
||||
|
||||
let queryParameters = new URLSearchParams();
|
||||
let headerParams = this.defaultHeaders;
|
||||
let headers = new Headers(this.defaultHeaders.values()); // https://github.com/angular/angular/issues/6845
|
||||
// verify required parameter 'username' is not null or undefined
|
||||
if (username === null || username === undefined) {
|
||||
throw new Error('Required parameter username was null or undefined when calling getUserByName.');
|
||||
}
|
||||
let requestOptions: RequestOptionsArgs = {
|
||||
method: 'GET',
|
||||
headers: headerParams,
|
||||
search: queryParameters
|
||||
};
|
||||
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
// to determine the Accept header
|
||||
let produces: string[] = [
|
||||
'application/json',
|
||||
'application/xml'
|
||||
];
|
||||
|
||||
|
||||
|
||||
// add form parameters if provided
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Get,
|
||||
headers: headers,
|
||||
search: queryParameters,
|
||||
responseType: ResponseContentType.Json
|
||||
});
|
||||
|
||||
return this.http.request(path, requestOptions)
|
||||
.map((response: Response) => {
|
||||
@ -192,24 +282,39 @@ export class UserApi {
|
||||
* @param username The user name for login
|
||||
* @param password The password for login in clear text
|
||||
*/
|
||||
public loginUser (username?: string, password?: string, extraHttpRequestParams?: any ) : Observable<string> {
|
||||
const path = this.basePath + '/user/login';
|
||||
public loginUser(username?: string, password?: string, extraHttpRequestParams?: any): Observable<string> {
|
||||
const path = this.basePath + `/user/login`;
|
||||
|
||||
let queryParameters = new URLSearchParams();
|
||||
let headerParams = this.defaultHeaders;
|
||||
let headers = new Headers(this.defaultHeaders.values()); // https://github.com/angular/angular/issues/6845
|
||||
if (username !== undefined) {
|
||||
queryParameters.set('username', String(username));
|
||||
queryParameters.set('username', <any>username);
|
||||
}
|
||||
|
||||
if (password !== undefined) {
|
||||
queryParameters.set('password', String(password));
|
||||
queryParameters.set('password', <any>password);
|
||||
}
|
||||
|
||||
let requestOptions: RequestOptionsArgs = {
|
||||
method: 'GET',
|
||||
headers: headerParams,
|
||||
search: queryParameters
|
||||
};
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
// to determine the Accept header
|
||||
let produces: string[] = [
|
||||
'application/json',
|
||||
'application/xml'
|
||||
];
|
||||
|
||||
|
||||
|
||||
// add form parameters if provided
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Get,
|
||||
headers: headers,
|
||||
search: queryParameters,
|
||||
responseType: ResponseContentType.Json
|
||||
});
|
||||
|
||||
return this.http.request(path, requestOptions)
|
||||
.map((response: Response) => {
|
||||
@ -225,16 +330,33 @@ export class UserApi {
|
||||
* Logs out current logged in user session
|
||||
*
|
||||
*/
|
||||
public logoutUser (extraHttpRequestParams?: any ) : Observable<{}> {
|
||||
const path = this.basePath + '/user/logout';
|
||||
public logoutUser(extraHttpRequestParams?: any): Observable<{}> {
|
||||
const path = this.basePath + `/user/logout`;
|
||||
|
||||
let queryParameters = new URLSearchParams();
|
||||
let headerParams = this.defaultHeaders;
|
||||
let requestOptions: RequestOptionsArgs = {
|
||||
method: 'GET',
|
||||
headers: headerParams,
|
||||
search: queryParameters
|
||||
};
|
||||
let headers = new Headers(this.defaultHeaders.values()); // https://github.com/angular/angular/issues/6845
|
||||
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
// to determine the Accept header
|
||||
let produces: string[] = [
|
||||
'application/json',
|
||||
'application/xml'
|
||||
];
|
||||
|
||||
|
||||
|
||||
// add form parameters if provided
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Get,
|
||||
headers: headers,
|
||||
search: queryParameters,
|
||||
responseType: ResponseContentType.Json
|
||||
});
|
||||
|
||||
return this.http.request(path, requestOptions)
|
||||
.map((response: Response) => {
|
||||
@ -252,22 +374,39 @@ export class UserApi {
|
||||
* @param username name that need to be deleted
|
||||
* @param body Updated user object
|
||||
*/
|
||||
public updateUser (username: string, body?: models.User, extraHttpRequestParams?: any ) : Observable<{}> {
|
||||
const path = this.basePath + '/user/{username}'
|
||||
.replace('{' + 'username' + '}', String(username));
|
||||
public updateUser(username: string, body?: models.User, extraHttpRequestParams?: any): Observable<{}> {
|
||||
const path = this.basePath + `/user/${username}`;
|
||||
|
||||
let queryParameters = new URLSearchParams();
|
||||
let headerParams = this.defaultHeaders;
|
||||
let headers = new Headers(this.defaultHeaders.values()); // https://github.com/angular/angular/issues/6845
|
||||
// verify required parameter 'username' is not null or undefined
|
||||
if (username === null || username === undefined) {
|
||||
throw new Error('Required parameter username was null or undefined when calling updateUser.');
|
||||
}
|
||||
let requestOptions: RequestOptionsArgs = {
|
||||
method: 'PUT',
|
||||
headers: headerParams,
|
||||
search: queryParameters
|
||||
};
|
||||
requestOptions.body = JSON.stringify(body);
|
||||
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
// to determine the Accept header
|
||||
let produces: string[] = [
|
||||
'application/json',
|
||||
'application/xml'
|
||||
];
|
||||
|
||||
|
||||
headers.set('Content-Type', 'application/json');
|
||||
|
||||
// add form parameters if provided
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Put,
|
||||
headers: headers,
|
||||
body: body == null ? '' : JSON.stringify(body), // https://github.com/angular/angular/issues/10612
|
||||
search: queryParameters,
|
||||
responseType: ResponseContentType.Json
|
||||
});
|
||||
|
||||
return this.http.request(path, requestOptions)
|
||||
.map((response: Response) => {
|
||||
|
@ -1,2 +1,3 @@
|
||||
export * from './api/api';
|
||||
export * from './model/models';
|
||||
export * from './model/models';
|
||||
export * from './variables';
|
@ -22,7 +22,6 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
import * as models from './models';
|
||||
|
||||
export interface Category {
|
||||
|
@ -22,7 +22,6 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
import * as models from './models';
|
||||
|
||||
export interface Order {
|
||||
|
@ -22,7 +22,6 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
import * as models from './models';
|
||||
|
||||
export interface Pet {
|
||||
|
@ -22,7 +22,6 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
import * as models from './models';
|
||||
|
||||
export interface Tag {
|
||||
|
@ -22,7 +22,6 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
import * as models from './models';
|
||||
|
||||
export interface User {
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@swagger/angular2-typescript-petstore",
|
||||
"version": "0.0.1-SNAPSHOT.201608052320",
|
||||
"version": "0.0.1-SNAPSHOT.201609051239",
|
||||
"description": "swagger client for @swagger/angular2-typescript-petstore",
|
||||
"author": "Swagger Codegen Contributors",
|
||||
"keywords": [
|
||||
@ -13,26 +13,31 @@
|
||||
"main": "./lib/index.js",
|
||||
"typings": "./lib/index.d.ts",
|
||||
"scripts": {
|
||||
"build": "typings install && tsc"
|
||||
"build": "typings install && tsc",
|
||||
"postinstall": "npm run build"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@angular/core": "^2.0.0-rc.1",
|
||||
"@angular/http": "^2.0.0-rc.1"
|
||||
"@angular/core": "^2.0.0-rc.5",
|
||||
"@angular/http": "^2.0.0-rc.5",
|
||||
"@angular/common": "^2.0.0-rc.5",
|
||||
"@angular/compiler": "^2.0.0-rc.5",
|
||||
"core-js": "^2.4.0",
|
||||
"reflect-metadata": "^0.1.3",
|
||||
"rxjs": "5.0.0-beta.6",
|
||||
"zone.js": "^0.6.17"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@angular/common": "^2.0.0-rc.1",
|
||||
"@angular/compiler": "^2.0.0-rc.1",
|
||||
"@angular/core": "^2.0.0-rc.1",
|
||||
"@angular/http": "^2.0.0-rc.1",
|
||||
"@angular/platform-browser": "^2.0.0-rc.1",
|
||||
"@angular/platform-browser-dynamic": "^2.0.0-rc.1",
|
||||
"core-js": "^2.3.0",
|
||||
"rxjs": "^5.0.0-beta.6",
|
||||
"zone.js": "^0.6.12",
|
||||
"@angular/core": "^2.0.0-rc.5",
|
||||
"@angular/http": "^2.0.0-rc.5",
|
||||
"@angular/common": "^2.0.0-rc.5",
|
||||
"@angular/compiler": "^2.0.0-rc.5",
|
||||
"@angular/platform-browser": "^2.0.0-rc.5",
|
||||
"core-js": "^2.4.0",
|
||||
"reflect-metadata": "^0.1.3",
|
||||
"rxjs": "5.0.0-beta.6",
|
||||
"zone.js": "^0.6.17",
|
||||
"typescript": "^1.8.10",
|
||||
"typings": "^0.8.1",
|
||||
"es6-shim": "^0.35.0",
|
||||
"es7-reflect-metadata": "^1.6.0"
|
||||
"typings": "^1.3.2"
|
||||
},
|
||||
"publishConfig":{
|
||||
"registry":"https://skimdb.npmjs.com/registry"
|
||||
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"ambientDependencies": {
|
||||
"core-js": "registry:dt/core-js#0.0.0+20160317120654"
|
||||
"globalDependencies": {
|
||||
"core-js": "registry:dt/core-js#0.0.0+20160725163759"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user