forked from loafle/openapi-generator-original
* Implemented fix for #6006. Mime-type support for accepts and content-type. * Review comments of @macjohnny incorporated * merge with latest and retest * merge with latest and retest. Now correctly generated with new Maven build
This commit is contained in:
@@ -73,7 +73,6 @@ export class {{classname}} {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
{{^useHttpClient}}
|
||||
{{! not sure why we used to generate a second method here rather than inlining those few lines of code,
|
||||
but let's keep it for now for the sake of backwards compatiblity. }}
|
||||
@@ -199,19 +198,41 @@ export class {{classname}} {
|
||||
|
||||
{{/isOAuth}}
|
||||
{{/authMethods}}
|
||||
{{#bodyParam}}
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
{{#produces}}
|
||||
'{{{mediaType}}}'{{#hasMore}},{{/hasMore}}
|
||||
{{/produces}}
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
{{^useHttpClient}}
|
||||
headers.set('Content-Type', 'application/json');
|
||||
|
||||
headers.set("Accept", httpHeaderAcceptSelected);
|
||||
{{/useHttpClient}}
|
||||
{{/bodyParam}}
|
||||
{{#hasFormParams}}
|
||||
{{#useHttpClient}}
|
||||
headers = headers.set("Accept", httpHeaderAcceptSelected);
|
||||
{{/useHttpClient}}
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
{{#consumes}}
|
||||
'{{{mediaType}}}'{{#hasMore}},{{/hasMore}}
|
||||
{{/consumes}}
|
||||
];
|
||||
{{#bodyParam}}
|
||||
let httpContentTypeSelected:string = this.configuration.selectHeaderContentType(consumes);
|
||||
if (httpContentTypeSelected != undefined) {
|
||||
{{^useHttpClient}}
|
||||
headers.set('Content-Type', httpContentTypeSelected);
|
||||
{{/useHttpClient}}
|
||||
{{#useHttpClient}}
|
||||
headers = headers.set("Content-Type", httpContentTypeSelected);
|
||||
{{/useHttpClient}}
|
||||
}
|
||||
{{/bodyParam}}
|
||||
|
||||
{{#hasFormParams}}
|
||||
const canConsumeForm = this.canConsumeForm(consumes);
|
||||
|
||||
let formParams: { append(param: string, value: any): void; };
|
||||
@@ -239,8 +260,6 @@ export class {{classname}} {
|
||||
{{/useHttpClient}}
|
||||
}
|
||||
|
||||
|
||||
|
||||
{{#formParams}}
|
||||
{{#isListContainer}}
|
||||
if ({{paramName}}) {
|
||||
|
||||
@@ -23,4 +23,57 @@ export class Configuration {
|
||||
this.basePath = configurationParameters.basePath;
|
||||
this.withCredentials = configurationParameters.withCredentials;
|
||||
}
|
||||
|
||||
/**
|
||||
* Select the correct content-type to use for a request.
|
||||
* Uses {@link Configuration#isJsonMime} to determine the correct content-type.
|
||||
* If no content type is found return the first found type if the contentTypes is not empty
|
||||
* @param {string[]} contentTypes - the array of content types that are available for selection
|
||||
* @returns {string} the selected content-type or <code>undefined</code> if no selection could be made.
|
||||
*/
|
||||
public selectHeaderContentType (contentTypes: string[]): string {
|
||||
if (contentTypes.length == 0) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
let type = contentTypes.find(x => this.isJsonMime(x));
|
||||
if (type === undefined) {
|
||||
return contentTypes[0];
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Select the correct accept content-type to use for a request.
|
||||
* Uses {@link Configuration#isJsonMime} to determine the correct accept content-type.
|
||||
* If no content type is found return the first found type if the contentTypes is not empty
|
||||
* @param {string[]} accepts - the array of content types that are available for selection.
|
||||
* @returns {string} the selected content-type or <code>undefined</code> if no selection could be made.
|
||||
*/
|
||||
public selectHeaderAccept(accepts: string[]): string {
|
||||
if (accepts.length == 0) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
let type = accepts.find(x => this.isJsonMime(x));
|
||||
if (type === undefined) {
|
||||
return accepts[0];
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the given MIME is a JSON MIME.
|
||||
* JSON MIME examples:
|
||||
* application/json
|
||||
* application/json; charset=UTF8
|
||||
* APPLICATION/JSON
|
||||
* application/vnd.company+json
|
||||
* @param {string} mime - MIME (Multipurpose Internet Mail Extensions)
|
||||
* @return {boolean} True if the given MIME is JSON, false otherwise.
|
||||
*/
|
||||
public isJsonMime(mime: string): boolean {
|
||||
const jsonMime: RegExp = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i');
|
||||
return mime != null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,7 +58,6 @@ export class PetService {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @summary Add a new pet to the store
|
||||
@@ -213,7 +212,25 @@ export class PetService {
|
||||
headers.set('Authorization', 'Bearer ' + accessToken);
|
||||
}
|
||||
|
||||
headers.set('Content-Type', 'application/json');
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
'application/json',
|
||||
'application/xml'
|
||||
];
|
||||
let httpContentTypeSelected:string = this.configuration.selectHeaderContentType(consumes);
|
||||
if (httpContentTypeSelected != undefined) {
|
||||
headers.set('Content-Type', httpContentTypeSelected);
|
||||
}
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Post,
|
||||
@@ -253,6 +270,20 @@ export class PetService {
|
||||
headers.set('Authorization', 'Bearer ' + accessToken);
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Delete,
|
||||
headers: headers,
|
||||
@@ -291,6 +322,20 @@ export class PetService {
|
||||
headers.set('Authorization', 'Bearer ' + accessToken);
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Get,
|
||||
headers: headers,
|
||||
@@ -330,6 +375,20 @@ export class PetService {
|
||||
headers.set('Authorization', 'Bearer ' + accessToken);
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Get,
|
||||
headers: headers,
|
||||
@@ -361,6 +420,20 @@ export class PetService {
|
||||
headers.set('api_key', this.configuration.apiKeys["api_key"]);
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Get,
|
||||
headers: headers,
|
||||
@@ -394,7 +467,25 @@ export class PetService {
|
||||
headers.set('Authorization', 'Bearer ' + accessToken);
|
||||
}
|
||||
|
||||
headers.set('Content-Type', 'application/json');
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
'application/json',
|
||||
'application/xml'
|
||||
];
|
||||
let httpContentTypeSelected:string = this.configuration.selectHeaderContentType(consumes);
|
||||
if (httpContentTypeSelected != undefined) {
|
||||
headers.set('Content-Type', httpContentTypeSelected);
|
||||
}
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Put,
|
||||
@@ -432,10 +523,21 @@ export class PetService {
|
||||
headers.set('Authorization', 'Bearer ' + accessToken);
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
'application/x-www-form-urlencoded'
|
||||
];
|
||||
|
||||
const canConsumeForm = this.canConsumeForm(consumes);
|
||||
|
||||
let formParams: { append(param: string, value: any): void; };
|
||||
@@ -451,8 +553,6 @@ export class PetService {
|
||||
headers.set('Content-Type', 'application/x-www-form-urlencoded;charset=UTF-8');
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (name !== undefined) {
|
||||
formParams.append('name', <any>name);
|
||||
}
|
||||
@@ -496,10 +596,20 @@ export class PetService {
|
||||
headers.set('Authorization', 'Bearer ' + accessToken);
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
'multipart/form-data'
|
||||
];
|
||||
|
||||
const canConsumeForm = this.canConsumeForm(consumes);
|
||||
|
||||
let formParams: { append(param: string, value: any): void; };
|
||||
@@ -518,8 +628,6 @@ export class PetService {
|
||||
headers.set('Content-Type', 'application/x-www-form-urlencoded;charset=UTF-8');
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (additionalMetadata !== undefined) {
|
||||
formParams.append('additionalMetadata', <any>additionalMetadata);
|
||||
}
|
||||
|
||||
@@ -57,7 +57,6 @@ export class StoreService {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||
* @summary Delete purchase order by ID
|
||||
@@ -134,6 +133,20 @@ export class StoreService {
|
||||
|
||||
let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845
|
||||
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Delete,
|
||||
headers: headers,
|
||||
@@ -160,6 +173,19 @@ export class StoreService {
|
||||
headers.set('api_key', this.configuration.apiKeys["api_key"]);
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Get,
|
||||
headers: headers,
|
||||
@@ -185,6 +211,20 @@ export class StoreService {
|
||||
|
||||
let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845
|
||||
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Get,
|
||||
headers: headers,
|
||||
@@ -210,7 +250,23 @@ export class StoreService {
|
||||
|
||||
let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845
|
||||
|
||||
headers.set('Content-Type', 'application/json');
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
let httpContentTypeSelected:string = this.configuration.selectHeaderContentType(consumes);
|
||||
if (httpContentTypeSelected != undefined) {
|
||||
headers.set('Content-Type', httpContentTypeSelected);
|
||||
}
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Post,
|
||||
|
||||
@@ -57,7 +57,6 @@ export class UserService {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This can only be done by the logged in user.
|
||||
* @summary Create user
|
||||
@@ -200,7 +199,23 @@ export class UserService {
|
||||
|
||||
let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845
|
||||
|
||||
headers.set('Content-Type', 'application/json');
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
let httpContentTypeSelected:string = this.configuration.selectHeaderContentType(consumes);
|
||||
if (httpContentTypeSelected != undefined) {
|
||||
headers.set('Content-Type', httpContentTypeSelected);
|
||||
}
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Post,
|
||||
@@ -228,7 +243,23 @@ export class UserService {
|
||||
|
||||
let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845
|
||||
|
||||
headers.set('Content-Type', 'application/json');
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
let httpContentTypeSelected:string = this.configuration.selectHeaderContentType(consumes);
|
||||
if (httpContentTypeSelected != undefined) {
|
||||
headers.set('Content-Type', httpContentTypeSelected);
|
||||
}
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Post,
|
||||
@@ -256,7 +287,23 @@ export class UserService {
|
||||
|
||||
let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845
|
||||
|
||||
headers.set('Content-Type', 'application/json');
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
let httpContentTypeSelected:string = this.configuration.selectHeaderContentType(consumes);
|
||||
if (httpContentTypeSelected != undefined) {
|
||||
headers.set('Content-Type', httpContentTypeSelected);
|
||||
}
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Post,
|
||||
@@ -284,6 +331,20 @@ export class UserService {
|
||||
|
||||
let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845
|
||||
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Delete,
|
||||
headers: headers,
|
||||
@@ -309,6 +370,20 @@ export class UserService {
|
||||
|
||||
let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845
|
||||
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Get,
|
||||
headers: headers,
|
||||
@@ -346,6 +421,20 @@ export class UserService {
|
||||
|
||||
let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845
|
||||
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Get,
|
||||
headers: headers,
|
||||
@@ -368,6 +457,20 @@ export class UserService {
|
||||
|
||||
let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845
|
||||
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Get,
|
||||
headers: headers,
|
||||
@@ -397,7 +500,23 @@ export class UserService {
|
||||
|
||||
let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845
|
||||
|
||||
headers.set('Content-Type', 'application/json');
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
let httpContentTypeSelected:string = this.configuration.selectHeaderContentType(consumes);
|
||||
if (httpContentTypeSelected != undefined) {
|
||||
headers.set('Content-Type', httpContentTypeSelected);
|
||||
}
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Put,
|
||||
|
||||
@@ -23,4 +23,57 @@ export class Configuration {
|
||||
this.basePath = configurationParameters.basePath;
|
||||
this.withCredentials = configurationParameters.withCredentials;
|
||||
}
|
||||
|
||||
/**
|
||||
* Select the correct content-type to use for a request.
|
||||
* Uses {@link Configuration#isJsonMime} to determine the correct content-type.
|
||||
* If no content type is found return the first found type if the contentTypes is not empty
|
||||
* @param {string[]} contentTypes - the array of content types that are available for selection
|
||||
* @returns {string} the selected content-type or <code>undefined</code> if no selection could be made.
|
||||
*/
|
||||
public selectHeaderContentType (contentTypes: string[]): string {
|
||||
if (contentTypes.length == 0) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
let type = contentTypes.find(x => this.isJsonMime(x));
|
||||
if (type === undefined) {
|
||||
return contentTypes[0];
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Select the correct accept content-type to use for a request.
|
||||
* Uses {@link Configuration#isJsonMime} to determine the correct accept content-type.
|
||||
* If no content type is found return the first found type if the contentTypes is not empty
|
||||
* @param {string[]} accepts - the array of content types that are available for selection.
|
||||
* @returns {string} the selected content-type or <code>undefined</code> if no selection could be made.
|
||||
*/
|
||||
public selectHeaderAccept(accepts: string[]): string {
|
||||
if (accepts.length == 0) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
let type = accepts.find(x => this.isJsonMime(x));
|
||||
if (type === undefined) {
|
||||
return accepts[0];
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the given MIME is a JSON MIME.
|
||||
* JSON MIME examples:
|
||||
* application/json
|
||||
* application/json; charset=UTF8
|
||||
* APPLICATION/JSON
|
||||
* application/vnd.company+json
|
||||
* @param {string} mime - MIME (Multipurpose Internet Mail Extensions)
|
||||
* @return {boolean} True if the given MIME is JSON, false otherwise.
|
||||
*/
|
||||
public isJsonMime(mime: string): boolean {
|
||||
const jsonMime: RegExp = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i');
|
||||
return mime != null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,7 +58,6 @@ export class PetService {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @summary Add a new pet to the store
|
||||
@@ -213,7 +212,25 @@ export class PetService {
|
||||
headers.set('Authorization', 'Bearer ' + accessToken);
|
||||
}
|
||||
|
||||
headers.set('Content-Type', 'application/json');
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
'application/json',
|
||||
'application/xml'
|
||||
];
|
||||
let httpContentTypeSelected:string = this.configuration.selectHeaderContentType(consumes);
|
||||
if (httpContentTypeSelected != undefined) {
|
||||
headers.set('Content-Type', httpContentTypeSelected);
|
||||
}
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Post,
|
||||
@@ -253,6 +270,20 @@ export class PetService {
|
||||
headers.set('Authorization', 'Bearer ' + accessToken);
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Delete,
|
||||
headers: headers,
|
||||
@@ -291,6 +322,20 @@ export class PetService {
|
||||
headers.set('Authorization', 'Bearer ' + accessToken);
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Get,
|
||||
headers: headers,
|
||||
@@ -330,6 +375,20 @@ export class PetService {
|
||||
headers.set('Authorization', 'Bearer ' + accessToken);
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Get,
|
||||
headers: headers,
|
||||
@@ -361,6 +420,20 @@ export class PetService {
|
||||
headers.set('api_key', this.configuration.apiKeys["api_key"]);
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Get,
|
||||
headers: headers,
|
||||
@@ -394,7 +467,25 @@ export class PetService {
|
||||
headers.set('Authorization', 'Bearer ' + accessToken);
|
||||
}
|
||||
|
||||
headers.set('Content-Type', 'application/json');
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
'application/json',
|
||||
'application/xml'
|
||||
];
|
||||
let httpContentTypeSelected:string = this.configuration.selectHeaderContentType(consumes);
|
||||
if (httpContentTypeSelected != undefined) {
|
||||
headers.set('Content-Type', httpContentTypeSelected);
|
||||
}
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Put,
|
||||
@@ -432,10 +523,21 @@ export class PetService {
|
||||
headers.set('Authorization', 'Bearer ' + accessToken);
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
'application/x-www-form-urlencoded'
|
||||
];
|
||||
|
||||
const canConsumeForm = this.canConsumeForm(consumes);
|
||||
|
||||
let formParams: { append(param: string, value: any): void; };
|
||||
@@ -451,8 +553,6 @@ export class PetService {
|
||||
headers.set('Content-Type', 'application/x-www-form-urlencoded;charset=UTF-8');
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (name !== undefined) {
|
||||
formParams.append('name', <any>name);
|
||||
}
|
||||
@@ -496,10 +596,20 @@ export class PetService {
|
||||
headers.set('Authorization', 'Bearer ' + accessToken);
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
'multipart/form-data'
|
||||
];
|
||||
|
||||
const canConsumeForm = this.canConsumeForm(consumes);
|
||||
|
||||
let formParams: { append(param: string, value: any): void; };
|
||||
@@ -518,8 +628,6 @@ export class PetService {
|
||||
headers.set('Content-Type', 'application/x-www-form-urlencoded;charset=UTF-8');
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (additionalMetadata !== undefined) {
|
||||
formParams.append('additionalMetadata', <any>additionalMetadata);
|
||||
}
|
||||
|
||||
@@ -57,7 +57,6 @@ export class StoreService {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||
* @summary Delete purchase order by ID
|
||||
@@ -134,6 +133,20 @@ export class StoreService {
|
||||
|
||||
let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845
|
||||
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Delete,
|
||||
headers: headers,
|
||||
@@ -160,6 +173,19 @@ export class StoreService {
|
||||
headers.set('api_key', this.configuration.apiKeys["api_key"]);
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Get,
|
||||
headers: headers,
|
||||
@@ -185,6 +211,20 @@ export class StoreService {
|
||||
|
||||
let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845
|
||||
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Get,
|
||||
headers: headers,
|
||||
@@ -210,7 +250,23 @@ export class StoreService {
|
||||
|
||||
let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845
|
||||
|
||||
headers.set('Content-Type', 'application/json');
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
let httpContentTypeSelected:string = this.configuration.selectHeaderContentType(consumes);
|
||||
if (httpContentTypeSelected != undefined) {
|
||||
headers.set('Content-Type', httpContentTypeSelected);
|
||||
}
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Post,
|
||||
|
||||
@@ -57,7 +57,6 @@ export class UserService {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This can only be done by the logged in user.
|
||||
* @summary Create user
|
||||
@@ -200,7 +199,23 @@ export class UserService {
|
||||
|
||||
let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845
|
||||
|
||||
headers.set('Content-Type', 'application/json');
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
let httpContentTypeSelected:string = this.configuration.selectHeaderContentType(consumes);
|
||||
if (httpContentTypeSelected != undefined) {
|
||||
headers.set('Content-Type', httpContentTypeSelected);
|
||||
}
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Post,
|
||||
@@ -228,7 +243,23 @@ export class UserService {
|
||||
|
||||
let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845
|
||||
|
||||
headers.set('Content-Type', 'application/json');
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
let httpContentTypeSelected:string = this.configuration.selectHeaderContentType(consumes);
|
||||
if (httpContentTypeSelected != undefined) {
|
||||
headers.set('Content-Type', httpContentTypeSelected);
|
||||
}
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Post,
|
||||
@@ -256,7 +287,23 @@ export class UserService {
|
||||
|
||||
let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845
|
||||
|
||||
headers.set('Content-Type', 'application/json');
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
let httpContentTypeSelected:string = this.configuration.selectHeaderContentType(consumes);
|
||||
if (httpContentTypeSelected != undefined) {
|
||||
headers.set('Content-Type', httpContentTypeSelected);
|
||||
}
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Post,
|
||||
@@ -284,6 +331,20 @@ export class UserService {
|
||||
|
||||
let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845
|
||||
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Delete,
|
||||
headers: headers,
|
||||
@@ -309,6 +370,20 @@ export class UserService {
|
||||
|
||||
let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845
|
||||
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Get,
|
||||
headers: headers,
|
||||
@@ -346,6 +421,20 @@ export class UserService {
|
||||
|
||||
let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845
|
||||
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Get,
|
||||
headers: headers,
|
||||
@@ -368,6 +457,20 @@ export class UserService {
|
||||
|
||||
let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845
|
||||
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Get,
|
||||
headers: headers,
|
||||
@@ -397,7 +500,23 @@ export class UserService {
|
||||
|
||||
let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845
|
||||
|
||||
headers.set('Content-Type', 'application/json');
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
let httpContentTypeSelected:string = this.configuration.selectHeaderContentType(consumes);
|
||||
if (httpContentTypeSelected != undefined) {
|
||||
headers.set('Content-Type', httpContentTypeSelected);
|
||||
}
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Put,
|
||||
|
||||
@@ -23,4 +23,57 @@ export class Configuration {
|
||||
this.basePath = configurationParameters.basePath;
|
||||
this.withCredentials = configurationParameters.withCredentials;
|
||||
}
|
||||
|
||||
/**
|
||||
* Select the correct content-type to use for a request.
|
||||
* Uses {@link Configuration#isJsonMime} to determine the correct content-type.
|
||||
* If no content type is found return the first found type if the contentTypes is not empty
|
||||
* @param {string[]} contentTypes - the array of content types that are available for selection
|
||||
* @returns {string} the selected content-type or <code>undefined</code> if no selection could be made.
|
||||
*/
|
||||
public selectHeaderContentType (contentTypes: string[]): string {
|
||||
if (contentTypes.length == 0) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
let type = contentTypes.find(x => this.isJsonMime(x));
|
||||
if (type === undefined) {
|
||||
return contentTypes[0];
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Select the correct accept content-type to use for a request.
|
||||
* Uses {@link Configuration#isJsonMime} to determine the correct accept content-type.
|
||||
* If no content type is found return the first found type if the contentTypes is not empty
|
||||
* @param {string[]} accepts - the array of content types that are available for selection.
|
||||
* @returns {string} the selected content-type or <code>undefined</code> if no selection could be made.
|
||||
*/
|
||||
public selectHeaderAccept(accepts: string[]): string {
|
||||
if (accepts.length == 0) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
let type = accepts.find(x => this.isJsonMime(x));
|
||||
if (type === undefined) {
|
||||
return accepts[0];
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the given MIME is a JSON MIME.
|
||||
* JSON MIME examples:
|
||||
* application/json
|
||||
* application/json; charset=UTF8
|
||||
* APPLICATION/JSON
|
||||
* application/vnd.company+json
|
||||
* @param {string} mime - MIME (Multipurpose Internet Mail Extensions)
|
||||
* @return {boolean} True if the given MIME is JSON, false otherwise.
|
||||
*/
|
||||
public isJsonMime(mime: string): boolean {
|
||||
const jsonMime: RegExp = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i');
|
||||
return mime != null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,7 +59,6 @@ export class PetService implements PetServiceInterface {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @summary Add a new pet to the store
|
||||
@@ -214,7 +213,25 @@ export class PetService implements PetServiceInterface {
|
||||
headers.set('Authorization', 'Bearer ' + accessToken);
|
||||
}
|
||||
|
||||
headers.set('Content-Type', 'application/json');
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
'application/json',
|
||||
'application/xml'
|
||||
];
|
||||
let httpContentTypeSelected:string = this.configuration.selectHeaderContentType(consumes);
|
||||
if (httpContentTypeSelected != undefined) {
|
||||
headers.set('Content-Type', httpContentTypeSelected);
|
||||
}
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Post,
|
||||
@@ -254,6 +271,20 @@ export class PetService implements PetServiceInterface {
|
||||
headers.set('Authorization', 'Bearer ' + accessToken);
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Delete,
|
||||
headers: headers,
|
||||
@@ -292,6 +323,20 @@ export class PetService implements PetServiceInterface {
|
||||
headers.set('Authorization', 'Bearer ' + accessToken);
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Get,
|
||||
headers: headers,
|
||||
@@ -331,6 +376,20 @@ export class PetService implements PetServiceInterface {
|
||||
headers.set('Authorization', 'Bearer ' + accessToken);
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Get,
|
||||
headers: headers,
|
||||
@@ -362,6 +421,20 @@ export class PetService implements PetServiceInterface {
|
||||
headers.set('api_key', this.configuration.apiKeys["api_key"]);
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Get,
|
||||
headers: headers,
|
||||
@@ -395,7 +468,25 @@ export class PetService implements PetServiceInterface {
|
||||
headers.set('Authorization', 'Bearer ' + accessToken);
|
||||
}
|
||||
|
||||
headers.set('Content-Type', 'application/json');
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
'application/json',
|
||||
'application/xml'
|
||||
];
|
||||
let httpContentTypeSelected:string = this.configuration.selectHeaderContentType(consumes);
|
||||
if (httpContentTypeSelected != undefined) {
|
||||
headers.set('Content-Type', httpContentTypeSelected);
|
||||
}
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Put,
|
||||
@@ -433,10 +524,21 @@ export class PetService implements PetServiceInterface {
|
||||
headers.set('Authorization', 'Bearer ' + accessToken);
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
'application/x-www-form-urlencoded'
|
||||
];
|
||||
|
||||
const canConsumeForm = this.canConsumeForm(consumes);
|
||||
|
||||
let formParams: { append(param: string, value: any): void; };
|
||||
@@ -452,8 +554,6 @@ export class PetService implements PetServiceInterface {
|
||||
headers.set('Content-Type', 'application/x-www-form-urlencoded;charset=UTF-8');
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (name !== undefined) {
|
||||
formParams.append('name', <any>name);
|
||||
}
|
||||
@@ -497,10 +597,20 @@ export class PetService implements PetServiceInterface {
|
||||
headers.set('Authorization', 'Bearer ' + accessToken);
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
'multipart/form-data'
|
||||
];
|
||||
|
||||
const canConsumeForm = this.canConsumeForm(consumes);
|
||||
|
||||
let formParams: { append(param: string, value: any): void; };
|
||||
@@ -519,8 +629,6 @@ export class PetService implements PetServiceInterface {
|
||||
headers.set('Content-Type', 'application/x-www-form-urlencoded;charset=UTF-8');
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (additionalMetadata !== undefined) {
|
||||
formParams.append('additionalMetadata', <any>additionalMetadata);
|
||||
}
|
||||
|
||||
@@ -58,7 +58,6 @@ export class StoreService implements StoreServiceInterface {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||
* @summary Delete purchase order by ID
|
||||
@@ -135,6 +134,20 @@ export class StoreService implements StoreServiceInterface {
|
||||
|
||||
let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845
|
||||
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Delete,
|
||||
headers: headers,
|
||||
@@ -161,6 +174,19 @@ export class StoreService implements StoreServiceInterface {
|
||||
headers.set('api_key', this.configuration.apiKeys["api_key"]);
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Get,
|
||||
headers: headers,
|
||||
@@ -186,6 +212,20 @@ export class StoreService implements StoreServiceInterface {
|
||||
|
||||
let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845
|
||||
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Get,
|
||||
headers: headers,
|
||||
@@ -211,7 +251,23 @@ export class StoreService implements StoreServiceInterface {
|
||||
|
||||
let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845
|
||||
|
||||
headers.set('Content-Type', 'application/json');
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
let httpContentTypeSelected:string = this.configuration.selectHeaderContentType(consumes);
|
||||
if (httpContentTypeSelected != undefined) {
|
||||
headers.set('Content-Type', httpContentTypeSelected);
|
||||
}
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Post,
|
||||
|
||||
@@ -58,7 +58,6 @@ export class UserService implements UserServiceInterface {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This can only be done by the logged in user.
|
||||
* @summary Create user
|
||||
@@ -201,7 +200,23 @@ export class UserService implements UserServiceInterface {
|
||||
|
||||
let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845
|
||||
|
||||
headers.set('Content-Type', 'application/json');
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
let httpContentTypeSelected:string = this.configuration.selectHeaderContentType(consumes);
|
||||
if (httpContentTypeSelected != undefined) {
|
||||
headers.set('Content-Type', httpContentTypeSelected);
|
||||
}
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Post,
|
||||
@@ -229,7 +244,23 @@ export class UserService implements UserServiceInterface {
|
||||
|
||||
let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845
|
||||
|
||||
headers.set('Content-Type', 'application/json');
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
let httpContentTypeSelected:string = this.configuration.selectHeaderContentType(consumes);
|
||||
if (httpContentTypeSelected != undefined) {
|
||||
headers.set('Content-Type', httpContentTypeSelected);
|
||||
}
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Post,
|
||||
@@ -257,7 +288,23 @@ export class UserService implements UserServiceInterface {
|
||||
|
||||
let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845
|
||||
|
||||
headers.set('Content-Type', 'application/json');
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
let httpContentTypeSelected:string = this.configuration.selectHeaderContentType(consumes);
|
||||
if (httpContentTypeSelected != undefined) {
|
||||
headers.set('Content-Type', httpContentTypeSelected);
|
||||
}
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Post,
|
||||
@@ -285,6 +332,20 @@ export class UserService implements UserServiceInterface {
|
||||
|
||||
let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845
|
||||
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Delete,
|
||||
headers: headers,
|
||||
@@ -310,6 +371,20 @@ export class UserService implements UserServiceInterface {
|
||||
|
||||
let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845
|
||||
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Get,
|
||||
headers: headers,
|
||||
@@ -347,6 +422,20 @@ export class UserService implements UserServiceInterface {
|
||||
|
||||
let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845
|
||||
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Get,
|
||||
headers: headers,
|
||||
@@ -369,6 +458,20 @@ export class UserService implements UserServiceInterface {
|
||||
|
||||
let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845
|
||||
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Get,
|
||||
headers: headers,
|
||||
@@ -398,7 +501,23 @@ export class UserService implements UserServiceInterface {
|
||||
|
||||
let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845
|
||||
|
||||
headers.set('Content-Type', 'application/json');
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
let httpContentTypeSelected:string = this.configuration.selectHeaderContentType(consumes);
|
||||
if (httpContentTypeSelected != undefined) {
|
||||
headers.set('Content-Type', httpContentTypeSelected);
|
||||
}
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Put,
|
||||
|
||||
@@ -23,4 +23,57 @@ export class Configuration {
|
||||
this.basePath = configurationParameters.basePath;
|
||||
this.withCredentials = configurationParameters.withCredentials;
|
||||
}
|
||||
|
||||
/**
|
||||
* Select the correct content-type to use for a request.
|
||||
* Uses {@link Configuration#isJsonMime} to determine the correct content-type.
|
||||
* If no content type is found return the first found type if the contentTypes is not empty
|
||||
* @param {string[]} contentTypes - the array of content types that are available for selection
|
||||
* @returns {string} the selected content-type or <code>undefined</code> if no selection could be made.
|
||||
*/
|
||||
public selectHeaderContentType (contentTypes: string[]): string {
|
||||
if (contentTypes.length == 0) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
let type = contentTypes.find(x => this.isJsonMime(x));
|
||||
if (type === undefined) {
|
||||
return contentTypes[0];
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Select the correct accept content-type to use for a request.
|
||||
* Uses {@link Configuration#isJsonMime} to determine the correct accept content-type.
|
||||
* If no content type is found return the first found type if the contentTypes is not empty
|
||||
* @param {string[]} accepts - the array of content types that are available for selection.
|
||||
* @returns {string} the selected content-type or <code>undefined</code> if no selection could be made.
|
||||
*/
|
||||
public selectHeaderAccept(accepts: string[]): string {
|
||||
if (accepts.length == 0) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
let type = accepts.find(x => this.isJsonMime(x));
|
||||
if (type === undefined) {
|
||||
return accepts[0];
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the given MIME is a JSON MIME.
|
||||
* JSON MIME examples:
|
||||
* application/json
|
||||
* application/json; charset=UTF8
|
||||
* APPLICATION/JSON
|
||||
* application/vnd.company+json
|
||||
* @param {string} mime - MIME (Multipurpose Internet Mail Extensions)
|
||||
* @return {boolean} True if the given MIME is JSON, false otherwise.
|
||||
*/
|
||||
public isJsonMime(mime: string): boolean {
|
||||
const jsonMime: RegExp = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i');
|
||||
return mime != null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +57,6 @@ export class PetService {
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Add a new pet to the store
|
||||
*
|
||||
@@ -78,13 +77,31 @@ export class PetService {
|
||||
headers = headers.set('Authorization', 'Bearer ' + accessToken);
|
||||
}
|
||||
|
||||
return this.httpClient.post<any>(`${this.basePath}/pet`,
|
||||
body,
|
||||
{
|
||||
headers: headers,
|
||||
withCredentials: this.configuration.withCredentials,
|
||||
}
|
||||
);
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers = headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
'application/json',
|
||||
'application/xml'
|
||||
];
|
||||
let httpContentTypeSelected:string = this.configuration.selectHeaderContentType(consumes);
|
||||
if (httpContentTypeSelected != undefined) {
|
||||
headers = headers.set("Content-Type", httpContentTypeSelected);
|
||||
}
|
||||
|
||||
return this.httpClient.post<any>(`${this.basePath}/pet`, body,
|
||||
{
|
||||
headers: headers,
|
||||
withCredentials: this.configuration.withCredentials,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -111,12 +128,25 @@ export class PetService {
|
||||
headers = headers.set('Authorization', 'Bearer ' + accessToken);
|
||||
}
|
||||
|
||||
return this.httpClient.delete<any>(`${this.basePath}/pet/${encodeURIComponent(String(petId))}`,
|
||||
{
|
||||
headers: headers,
|
||||
withCredentials: this.configuration.withCredentials,
|
||||
}
|
||||
);
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers = headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
return this.httpClient.delete<any>(`${this.basePath}/pet/${encodeURIComponent(String(petId))}`,
|
||||
{
|
||||
headers: headers,
|
||||
withCredentials: this.configuration.withCredentials,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -144,13 +174,26 @@ export class PetService {
|
||||
headers = headers.set('Authorization', 'Bearer ' + accessToken);
|
||||
}
|
||||
|
||||
return this.httpClient.get<any>(`${this.basePath}/pet/findByStatus`,
|
||||
{
|
||||
params: queryParameters,
|
||||
headers: headers,
|
||||
withCredentials: this.configuration.withCredentials,
|
||||
}
|
||||
);
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers = headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
return this.httpClient.get<any>(`${this.basePath}/pet/findByStatus`,
|
||||
{
|
||||
params: queryParameters,
|
||||
headers: headers,
|
||||
withCredentials: this.configuration.withCredentials,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -178,13 +221,26 @@ export class PetService {
|
||||
headers = headers.set('Authorization', 'Bearer ' + accessToken);
|
||||
}
|
||||
|
||||
return this.httpClient.get<any>(`${this.basePath}/pet/findByTags`,
|
||||
{
|
||||
params: queryParameters,
|
||||
headers: headers,
|
||||
withCredentials: this.configuration.withCredentials,
|
||||
}
|
||||
);
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers = headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
return this.httpClient.get<any>(`${this.basePath}/pet/findByTags`,
|
||||
{
|
||||
params: queryParameters,
|
||||
headers: headers,
|
||||
withCredentials: this.configuration.withCredentials,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -204,12 +260,25 @@ export class PetService {
|
||||
headers = headers.set('api_key', this.configuration.apiKeys["api_key"]);
|
||||
}
|
||||
|
||||
return this.httpClient.get<any>(`${this.basePath}/pet/${encodeURIComponent(String(petId))}`,
|
||||
{
|
||||
headers: headers,
|
||||
withCredentials: this.configuration.withCredentials,
|
||||
}
|
||||
);
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers = headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
return this.httpClient.get<any>(`${this.basePath}/pet/${encodeURIComponent(String(petId))}`,
|
||||
{
|
||||
headers: headers,
|
||||
withCredentials: this.configuration.withCredentials,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -232,13 +301,31 @@ export class PetService {
|
||||
headers = headers.set('Authorization', 'Bearer ' + accessToken);
|
||||
}
|
||||
|
||||
return this.httpClient.put<any>(`${this.basePath}/pet`,
|
||||
body,
|
||||
{
|
||||
headers: headers,
|
||||
withCredentials: this.configuration.withCredentials,
|
||||
}
|
||||
);
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers = headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
'application/json',
|
||||
'application/xml'
|
||||
];
|
||||
let httpContentTypeSelected:string = this.configuration.selectHeaderContentType(consumes);
|
||||
if (httpContentTypeSelected != undefined) {
|
||||
headers = headers.set("Content-Type", httpContentTypeSelected);
|
||||
}
|
||||
|
||||
return this.httpClient.put<any>(`${this.basePath}/pet`, body,
|
||||
{
|
||||
headers: headers,
|
||||
withCredentials: this.configuration.withCredentials,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -263,10 +350,21 @@ export class PetService {
|
||||
headers = headers.set('Authorization', 'Bearer ' + accessToken);
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers = headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
'application/x-www-form-urlencoded'
|
||||
];
|
||||
|
||||
const canConsumeForm = this.canConsumeForm(consumes);
|
||||
|
||||
let formParams: { append(param: string, value: any): void; };
|
||||
@@ -278,8 +376,6 @@ export class PetService {
|
||||
formParams = new HttpParams({encoder: new CustomHttpUrlEncodingCodec()});
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (name !== undefined) {
|
||||
formParams = formParams.append('name', <any>name) || formParams;
|
||||
}
|
||||
@@ -318,10 +414,20 @@ export class PetService {
|
||||
headers = headers.set('Authorization', 'Bearer ' + accessToken);
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers = headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
'multipart/form-data'
|
||||
];
|
||||
|
||||
const canConsumeForm = this.canConsumeForm(consumes);
|
||||
|
||||
let formParams: { append(param: string, value: any): void; };
|
||||
@@ -336,8 +442,6 @@ export class PetService {
|
||||
formParams = new HttpParams({encoder: new CustomHttpUrlEncodingCodec()});
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (additionalMetadata !== undefined) {
|
||||
formParams = formParams.append('additionalMetadata', <any>additionalMetadata) || formParams;
|
||||
}
|
||||
|
||||
@@ -56,7 +56,6 @@ export class StoreService {
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Delete purchase order by ID
|
||||
* For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||
@@ -69,12 +68,25 @@ export class StoreService {
|
||||
|
||||
let headers = this.defaultHeaders;
|
||||
|
||||
return this.httpClient.delete<any>(`${this.basePath}/store/order/${encodeURIComponent(String(orderId))}`,
|
||||
{
|
||||
headers: headers,
|
||||
withCredentials: this.configuration.withCredentials,
|
||||
}
|
||||
);
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers = headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
return this.httpClient.delete<any>(`${this.basePath}/store/order/${encodeURIComponent(String(orderId))}`,
|
||||
{
|
||||
headers: headers,
|
||||
withCredentials: this.configuration.withCredentials,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -90,12 +102,24 @@ export class StoreService {
|
||||
headers = headers.set('api_key', this.configuration.apiKeys["api_key"]);
|
||||
}
|
||||
|
||||
return this.httpClient.get<any>(`${this.basePath}/store/inventory`,
|
||||
{
|
||||
headers: headers,
|
||||
withCredentials: this.configuration.withCredentials,
|
||||
}
|
||||
);
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers = headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
return this.httpClient.get<any>(`${this.basePath}/store/inventory`,
|
||||
{
|
||||
headers: headers,
|
||||
withCredentials: this.configuration.withCredentials,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -110,12 +134,25 @@ export class StoreService {
|
||||
|
||||
let headers = this.defaultHeaders;
|
||||
|
||||
return this.httpClient.get<any>(`${this.basePath}/store/order/${encodeURIComponent(String(orderId))}`,
|
||||
{
|
||||
headers: headers,
|
||||
withCredentials: this.configuration.withCredentials,
|
||||
}
|
||||
);
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers = headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
return this.httpClient.get<any>(`${this.basePath}/store/order/${encodeURIComponent(String(orderId))}`,
|
||||
{
|
||||
headers: headers,
|
||||
withCredentials: this.configuration.withCredentials,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -130,13 +167,29 @@ export class StoreService {
|
||||
|
||||
let headers = this.defaultHeaders;
|
||||
|
||||
return this.httpClient.post<any>(`${this.basePath}/store/order`,
|
||||
body,
|
||||
{
|
||||
headers: headers,
|
||||
withCredentials: this.configuration.withCredentials,
|
||||
}
|
||||
);
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers = headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
let httpContentTypeSelected:string = this.configuration.selectHeaderContentType(consumes);
|
||||
if (httpContentTypeSelected != undefined) {
|
||||
headers = headers.set("Content-Type", httpContentTypeSelected);
|
||||
}
|
||||
|
||||
return this.httpClient.post<any>(`${this.basePath}/store/order`, body,
|
||||
{
|
||||
headers: headers,
|
||||
withCredentials: this.configuration.withCredentials,
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -56,7 +56,6 @@ export class UserService {
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Create user
|
||||
* This can only be done by the logged in user.
|
||||
@@ -69,13 +68,29 @@ export class UserService {
|
||||
|
||||
let headers = this.defaultHeaders;
|
||||
|
||||
return this.httpClient.post<any>(`${this.basePath}/user`,
|
||||
body,
|
||||
{
|
||||
headers: headers,
|
||||
withCredentials: this.configuration.withCredentials,
|
||||
}
|
||||
);
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers = headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
let httpContentTypeSelected:string = this.configuration.selectHeaderContentType(consumes);
|
||||
if (httpContentTypeSelected != undefined) {
|
||||
headers = headers.set("Content-Type", httpContentTypeSelected);
|
||||
}
|
||||
|
||||
return this.httpClient.post<any>(`${this.basePath}/user`, body,
|
||||
{
|
||||
headers: headers,
|
||||
withCredentials: this.configuration.withCredentials,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -90,13 +105,29 @@ export class UserService {
|
||||
|
||||
let headers = this.defaultHeaders;
|
||||
|
||||
return this.httpClient.post<any>(`${this.basePath}/user/createWithArray`,
|
||||
body,
|
||||
{
|
||||
headers: headers,
|
||||
withCredentials: this.configuration.withCredentials,
|
||||
}
|
||||
);
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers = headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
let httpContentTypeSelected:string = this.configuration.selectHeaderContentType(consumes);
|
||||
if (httpContentTypeSelected != undefined) {
|
||||
headers = headers.set("Content-Type", httpContentTypeSelected);
|
||||
}
|
||||
|
||||
return this.httpClient.post<any>(`${this.basePath}/user/createWithArray`, body,
|
||||
{
|
||||
headers: headers,
|
||||
withCredentials: this.configuration.withCredentials,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -111,13 +142,29 @@ export class UserService {
|
||||
|
||||
let headers = this.defaultHeaders;
|
||||
|
||||
return this.httpClient.post<any>(`${this.basePath}/user/createWithList`,
|
||||
body,
|
||||
{
|
||||
headers: headers,
|
||||
withCredentials: this.configuration.withCredentials,
|
||||
}
|
||||
);
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers = headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
let httpContentTypeSelected:string = this.configuration.selectHeaderContentType(consumes);
|
||||
if (httpContentTypeSelected != undefined) {
|
||||
headers = headers.set("Content-Type", httpContentTypeSelected);
|
||||
}
|
||||
|
||||
return this.httpClient.post<any>(`${this.basePath}/user/createWithList`, body,
|
||||
{
|
||||
headers: headers,
|
||||
withCredentials: this.configuration.withCredentials,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -132,12 +179,25 @@ export class UserService {
|
||||
|
||||
let headers = this.defaultHeaders;
|
||||
|
||||
return this.httpClient.delete<any>(`${this.basePath}/user/${encodeURIComponent(String(username))}`,
|
||||
{
|
||||
headers: headers,
|
||||
withCredentials: this.configuration.withCredentials,
|
||||
}
|
||||
);
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers = headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
return this.httpClient.delete<any>(`${this.basePath}/user/${encodeURIComponent(String(username))}`,
|
||||
{
|
||||
headers: headers,
|
||||
withCredentials: this.configuration.withCredentials,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -152,12 +212,25 @@ export class UserService {
|
||||
|
||||
let headers = this.defaultHeaders;
|
||||
|
||||
return this.httpClient.get<any>(`${this.basePath}/user/${encodeURIComponent(String(username))}`,
|
||||
{
|
||||
headers: headers,
|
||||
withCredentials: this.configuration.withCredentials,
|
||||
}
|
||||
);
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers = headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
return this.httpClient.get<any>(`${this.basePath}/user/${encodeURIComponent(String(username))}`,
|
||||
{
|
||||
headers: headers,
|
||||
withCredentials: this.configuration.withCredentials,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -184,13 +257,26 @@ export class UserService {
|
||||
|
||||
let headers = this.defaultHeaders;
|
||||
|
||||
return this.httpClient.get<any>(`${this.basePath}/user/login`,
|
||||
{
|
||||
params: queryParameters,
|
||||
headers: headers,
|
||||
withCredentials: this.configuration.withCredentials,
|
||||
}
|
||||
);
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers = headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
return this.httpClient.get<any>(`${this.basePath}/user/login`,
|
||||
{
|
||||
params: queryParameters,
|
||||
headers: headers,
|
||||
withCredentials: this.configuration.withCredentials,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -201,12 +287,25 @@ export class UserService {
|
||||
|
||||
let headers = this.defaultHeaders;
|
||||
|
||||
return this.httpClient.get<any>(`${this.basePath}/user/logout`,
|
||||
{
|
||||
headers: headers,
|
||||
withCredentials: this.configuration.withCredentials,
|
||||
}
|
||||
);
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers = headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
return this.httpClient.get<any>(`${this.basePath}/user/logout`,
|
||||
{
|
||||
headers: headers,
|
||||
withCredentials: this.configuration.withCredentials,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -225,13 +324,29 @@ export class UserService {
|
||||
|
||||
let headers = this.defaultHeaders;
|
||||
|
||||
return this.httpClient.put<any>(`${this.basePath}/user/${encodeURIComponent(String(username))}`,
|
||||
body,
|
||||
{
|
||||
headers: headers,
|
||||
withCredentials: this.configuration.withCredentials,
|
||||
}
|
||||
);
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers = headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
let httpContentTypeSelected:string = this.configuration.selectHeaderContentType(consumes);
|
||||
if (httpContentTypeSelected != undefined) {
|
||||
headers = headers.set("Content-Type", httpContentTypeSelected);
|
||||
}
|
||||
|
||||
return this.httpClient.put<any>(`${this.basePath}/user/${encodeURIComponent(String(username))}`, body,
|
||||
{
|
||||
headers: headers,
|
||||
withCredentials: this.configuration.withCredentials,
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -23,4 +23,57 @@ export class Configuration {
|
||||
this.basePath = configurationParameters.basePath;
|
||||
this.withCredentials = configurationParameters.withCredentials;
|
||||
}
|
||||
|
||||
/**
|
||||
* Select the correct content-type to use for a request.
|
||||
* Uses {@link Configuration#isJsonMime} to determine the correct content-type.
|
||||
* If no content type is found return the first found type if the contentTypes is not empty
|
||||
* @param {string[]} contentTypes - the array of content types that are available for selection
|
||||
* @returns {string} the selected content-type or <code>undefined</code> if no selection could be made.
|
||||
*/
|
||||
public selectHeaderContentType (contentTypes: string[]): string {
|
||||
if (contentTypes.length == 0) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
let type = contentTypes.find(x => this.isJsonMime(x));
|
||||
if (type === undefined) {
|
||||
return contentTypes[0];
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Select the correct accept content-type to use for a request.
|
||||
* Uses {@link Configuration#isJsonMime} to determine the correct accept content-type.
|
||||
* If no content type is found return the first found type if the contentTypes is not empty
|
||||
* @param {string[]} accepts - the array of content types that are available for selection.
|
||||
* @returns {string} the selected content-type or <code>undefined</code> if no selection could be made.
|
||||
*/
|
||||
public selectHeaderAccept(accepts: string[]): string {
|
||||
if (accepts.length == 0) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
let type = accepts.find(x => this.isJsonMime(x));
|
||||
if (type === undefined) {
|
||||
return accepts[0];
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the given MIME is a JSON MIME.
|
||||
* JSON MIME examples:
|
||||
* application/json
|
||||
* application/json; charset=UTF8
|
||||
* APPLICATION/JSON
|
||||
* application/vnd.company+json
|
||||
* @param {string} mime - MIME (Multipurpose Internet Mail Extensions)
|
||||
* @return {boolean} True if the given MIME is JSON, false otherwise.
|
||||
*/
|
||||
public isJsonMime(mime: string): boolean {
|
||||
const jsonMime: RegExp = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i');
|
||||
return mime != null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,7 +58,6 @@ export class PetService {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @summary Add a new pet to the store
|
||||
@@ -213,7 +212,25 @@ export class PetService {
|
||||
headers.set('Authorization', 'Bearer ' + accessToken);
|
||||
}
|
||||
|
||||
headers.set('Content-Type', 'application/json');
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
'application/json',
|
||||
'application/xml'
|
||||
];
|
||||
let httpContentTypeSelected:string = this.configuration.selectHeaderContentType(consumes);
|
||||
if (httpContentTypeSelected != undefined) {
|
||||
headers.set('Content-Type', httpContentTypeSelected);
|
||||
}
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Post,
|
||||
@@ -253,6 +270,20 @@ export class PetService {
|
||||
headers.set('Authorization', 'Bearer ' + accessToken);
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Delete,
|
||||
headers: headers,
|
||||
@@ -291,6 +322,20 @@ export class PetService {
|
||||
headers.set('Authorization', 'Bearer ' + accessToken);
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Get,
|
||||
headers: headers,
|
||||
@@ -330,6 +375,20 @@ export class PetService {
|
||||
headers.set('Authorization', 'Bearer ' + accessToken);
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Get,
|
||||
headers: headers,
|
||||
@@ -361,6 +420,20 @@ export class PetService {
|
||||
headers.set('api_key', this.configuration.apiKeys["api_key"]);
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Get,
|
||||
headers: headers,
|
||||
@@ -394,7 +467,25 @@ export class PetService {
|
||||
headers.set('Authorization', 'Bearer ' + accessToken);
|
||||
}
|
||||
|
||||
headers.set('Content-Type', 'application/json');
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
'application/json',
|
||||
'application/xml'
|
||||
];
|
||||
let httpContentTypeSelected:string = this.configuration.selectHeaderContentType(consumes);
|
||||
if (httpContentTypeSelected != undefined) {
|
||||
headers.set('Content-Type', httpContentTypeSelected);
|
||||
}
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Put,
|
||||
@@ -432,10 +523,21 @@ export class PetService {
|
||||
headers.set('Authorization', 'Bearer ' + accessToken);
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
'application/x-www-form-urlencoded'
|
||||
];
|
||||
|
||||
const canConsumeForm = this.canConsumeForm(consumes);
|
||||
|
||||
let formParams: { append(param: string, value: any): void; };
|
||||
@@ -451,8 +553,6 @@ export class PetService {
|
||||
headers.set('Content-Type', 'application/x-www-form-urlencoded;charset=UTF-8');
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (name !== undefined) {
|
||||
formParams.append('name', <any>name);
|
||||
}
|
||||
@@ -496,10 +596,20 @@ export class PetService {
|
||||
headers.set('Authorization', 'Bearer ' + accessToken);
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
'multipart/form-data'
|
||||
];
|
||||
|
||||
const canConsumeForm = this.canConsumeForm(consumes);
|
||||
|
||||
let formParams: { append(param: string, value: any): void; };
|
||||
@@ -518,8 +628,6 @@ export class PetService {
|
||||
headers.set('Content-Type', 'application/x-www-form-urlencoded;charset=UTF-8');
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (additionalMetadata !== undefined) {
|
||||
formParams.append('additionalMetadata', <any>additionalMetadata);
|
||||
}
|
||||
|
||||
@@ -57,7 +57,6 @@ export class StoreService {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||
* @summary Delete purchase order by ID
|
||||
@@ -134,6 +133,20 @@ export class StoreService {
|
||||
|
||||
let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845
|
||||
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Delete,
|
||||
headers: headers,
|
||||
@@ -160,6 +173,19 @@ export class StoreService {
|
||||
headers.set('api_key', this.configuration.apiKeys["api_key"]);
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Get,
|
||||
headers: headers,
|
||||
@@ -185,6 +211,20 @@ export class StoreService {
|
||||
|
||||
let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845
|
||||
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Get,
|
||||
headers: headers,
|
||||
@@ -210,7 +250,23 @@ export class StoreService {
|
||||
|
||||
let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845
|
||||
|
||||
headers.set('Content-Type', 'application/json');
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
let httpContentTypeSelected:string = this.configuration.selectHeaderContentType(consumes);
|
||||
if (httpContentTypeSelected != undefined) {
|
||||
headers.set('Content-Type', httpContentTypeSelected);
|
||||
}
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Post,
|
||||
|
||||
@@ -57,7 +57,6 @@ export class UserService {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This can only be done by the logged in user.
|
||||
* @summary Create user
|
||||
@@ -200,7 +199,23 @@ export class UserService {
|
||||
|
||||
let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845
|
||||
|
||||
headers.set('Content-Type', 'application/json');
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
let httpContentTypeSelected:string = this.configuration.selectHeaderContentType(consumes);
|
||||
if (httpContentTypeSelected != undefined) {
|
||||
headers.set('Content-Type', httpContentTypeSelected);
|
||||
}
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Post,
|
||||
@@ -228,7 +243,23 @@ export class UserService {
|
||||
|
||||
let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845
|
||||
|
||||
headers.set('Content-Type', 'application/json');
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
let httpContentTypeSelected:string = this.configuration.selectHeaderContentType(consumes);
|
||||
if (httpContentTypeSelected != undefined) {
|
||||
headers.set('Content-Type', httpContentTypeSelected);
|
||||
}
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Post,
|
||||
@@ -256,7 +287,23 @@ export class UserService {
|
||||
|
||||
let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845
|
||||
|
||||
headers.set('Content-Type', 'application/json');
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
let httpContentTypeSelected:string = this.configuration.selectHeaderContentType(consumes);
|
||||
if (httpContentTypeSelected != undefined) {
|
||||
headers.set('Content-Type', httpContentTypeSelected);
|
||||
}
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Post,
|
||||
@@ -284,6 +331,20 @@ export class UserService {
|
||||
|
||||
let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845
|
||||
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Delete,
|
||||
headers: headers,
|
||||
@@ -309,6 +370,20 @@ export class UserService {
|
||||
|
||||
let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845
|
||||
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Get,
|
||||
headers: headers,
|
||||
@@ -346,6 +421,20 @@ export class UserService {
|
||||
|
||||
let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845
|
||||
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Get,
|
||||
headers: headers,
|
||||
@@ -368,6 +457,20 @@ export class UserService {
|
||||
|
||||
let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845
|
||||
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Get,
|
||||
headers: headers,
|
||||
@@ -397,7 +500,23 @@ export class UserService {
|
||||
|
||||
let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845
|
||||
|
||||
headers.set('Content-Type', 'application/json');
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
'application/json'
|
||||
];
|
||||
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers.set("Accept", httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
];
|
||||
let httpContentTypeSelected:string = this.configuration.selectHeaderContentType(consumes);
|
||||
if (httpContentTypeSelected != undefined) {
|
||||
headers.set('Content-Type', httpContentTypeSelected);
|
||||
}
|
||||
|
||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||
method: RequestMethod.Put,
|
||||
|
||||
@@ -23,4 +23,57 @@ export class Configuration {
|
||||
this.basePath = configurationParameters.basePath;
|
||||
this.withCredentials = configurationParameters.withCredentials;
|
||||
}
|
||||
|
||||
/**
|
||||
* Select the correct content-type to use for a request.
|
||||
* Uses {@link Configuration#isJsonMime} to determine the correct content-type.
|
||||
* If no content type is found return the first found type if the contentTypes is not empty
|
||||
* @param {string[]} contentTypes - the array of content types that are available for selection
|
||||
* @returns {string} the selected content-type or <code>undefined</code> if no selection could be made.
|
||||
*/
|
||||
public selectHeaderContentType (contentTypes: string[]): string {
|
||||
if (contentTypes.length == 0) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
let type = contentTypes.find(x => this.isJsonMime(x));
|
||||
if (type === undefined) {
|
||||
return contentTypes[0];
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Select the correct accept content-type to use for a request.
|
||||
* Uses {@link Configuration#isJsonMime} to determine the correct accept content-type.
|
||||
* If no content type is found return the first found type if the contentTypes is not empty
|
||||
* @param {string[]} accepts - the array of content types that are available for selection.
|
||||
* @returns {string} the selected content-type or <code>undefined</code> if no selection could be made.
|
||||
*/
|
||||
public selectHeaderAccept(accepts: string[]): string {
|
||||
if (accepts.length == 0) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
let type = accepts.find(x => this.isJsonMime(x));
|
||||
if (type === undefined) {
|
||||
return accepts[0];
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the given MIME is a JSON MIME.
|
||||
* JSON MIME examples:
|
||||
* application/json
|
||||
* application/json; charset=UTF8
|
||||
* APPLICATION/JSON
|
||||
* application/vnd.company+json
|
||||
* @param {string} mime - MIME (Multipurpose Internet Mail Extensions)
|
||||
* @return {boolean} True if the given MIME is JSON, false otherwise.
|
||||
*/
|
||||
public isJsonMime(mime: string): boolean {
|
||||
const jsonMime: RegExp = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i');
|
||||
return mime != null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user