Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{>licenseInfo}}
/* tslint:disable:no-unused-variable member-ordering */
/* tslint:disable:no-unused-variable member-ordering import-spacing*/

import { Inject, Injectable, Optional } from '@angular/core';
{{#useHttpClient}}
Expand Down Expand Up @@ -65,7 +65,7 @@ export class {{classname}} {
*/
private canConsumeForm(consumes: string[]): boolean {
const form = 'multipart/form-data';
for (let consume of consumes) {
for (const consume of consumes) {
if (form === consume) {
return true;
}
Expand Down Expand Up @@ -170,14 +170,14 @@ export class {{classname}} {
// authentication ({{name}}) required
{{#isApiKey}}
{{#isKeyInHeader}}
if (this.configuration.apiKeys["{{keyParamName}}"]) {
{{#useHttpClient}}headers = {{/useHttpClient}}headers.set('{{keyParamName}}', this.configuration.apiKeys["{{keyParamName}}"]);
if (this.configuration.apiKeys['{{keyParamName}}']) {
{{#useHttpClient}}headers = {{/useHttpClient}}headers.set('{{keyParamName}}', this.configuration.apiKeys['{{keyParamName}}']);
}

{{/isKeyInHeader}}
{{#isKeyInQuery}}
if (this.configuration.apiKeys["{{keyParamName}}"]) {
{{#useHttpClient}}queryParameters = {{/useHttpClient}}queryParameters.set('{{keyParamName}}', this.configuration.apiKeys["{{keyParamName}}"]);
if (this.configuration.apiKeys['{{keyParamName}}']) {
{{#useHttpClient}}queryParameters = {{/useHttpClient}}queryParameters.set('{{keyParamName}}', this.configuration.apiKeys['{{keyParamName}}']);
}

{{/isKeyInQuery}}
Expand All @@ -199,35 +199,35 @@ export class {{classname}} {
{{/isOAuth}}
{{/authMethods}}
// to determine the Accept header
let httpHeaderAccepts: string[] = [
const httpHeaderAccepts: string[] = [
{{#produces}}
'{{{mediaType}}}'{{#hasMore}},{{/hasMore}}
{{/produces}}
];
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
if (httpHeaderAcceptSelected != undefined) {
const httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
if (httpHeaderAcceptSelected !== undefined) {
{{^useHttpClient}}
headers.set("Accept", httpHeaderAcceptSelected);
headers.set('Accept', httpHeaderAcceptSelected);
{{/useHttpClient}}
{{#useHttpClient}}
headers = headers.set("Accept", httpHeaderAcceptSelected);
headers = headers.set('Accept', httpHeaderAcceptSelected);
{{/useHttpClient}}
}

// to determine the Content-Type header
let consumes: string[] = [
const consumes: string[] = [
{{#consumes}}
'{{{mediaType}}}'{{#hasMore}},{{/hasMore}}
{{/consumes}}
];
{{#bodyParam}}
let httpContentTypeSelected:string = this.configuration.selectHeaderContentType(consumes);
if (httpContentTypeSelected != undefined) {
const httpContentTypeSelected: string = this.configuration.selectHeaderContentType(consumes);
if (httpContentTypeSelected !== undefined) {
{{^useHttpClient}}
headers.set('Content-Type', httpContentTypeSelected);
{{/useHttpClient}}
{{#useHttpClient}}
headers = headers.set("Content-Type", httpContentTypeSelected);
headers = headers.set('Content-Type', httpContentTypeSelected);
{{/useHttpClient}}
}
{{/bodyParam}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ export class Configuration {
* 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
* @param {Array<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) {
selectHeaderContentType(contentTypes: Array<string>): string {
if (contentTypes.length === 0) {
return undefined;
}

let type = contentTypes.find(x => this.isJsonMime(x));
const type = contentTypes.find(x => this.isJsonMime(x));
if (type === undefined) {
return contentTypes[0];
}
Expand All @@ -47,15 +47,15 @@ export class Configuration {
* 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.
* @param {Array<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) {
selectHeaderAccept(accepts: Array<string>): string {
if (accepts.length === 0) {
return undefined;
}

let type = accepts.find(x => this.isJsonMime(x));
const type = accepts.find(x => this.isJsonMime(x));
if (type === undefined) {
return accepts[0];
}
Expand All @@ -72,7 +72,7 @@ export class Configuration {
* @param {string} mime - MIME (Multipurpose Internet Mail Extensions)
* @return {boolean} True if the given MIME is JSON, false otherwise.
*/
public isJsonMime(mime: string): boolean {
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');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
/* tslint:disable:no-unused-variable member-ordering */
/* tslint:disable:no-unused-variable member-ordering import-spacing*/

import { Inject, Injectable, Optional } from '@angular/core';
import { Http, Headers, URLSearchParams } from '@angular/http';
Expand Down Expand Up @@ -50,7 +50,7 @@ export class PetService {
*/
private canConsumeForm(consumes: string[]): boolean {
const form = 'multipart/form-data';
for (let consume of consumes) {
for (const consume of consumes) {
if (form === consume) {
return true;
}
Expand Down Expand Up @@ -213,22 +213,22 @@ export class PetService {
}

// to determine the Accept header
let httpHeaderAccepts: string[] = [
const httpHeaderAccepts: string[] = [
'application/xml',
'application/json'
];
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
if (httpHeaderAcceptSelected != undefined) {
headers.set("Accept", httpHeaderAcceptSelected);
const httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
if (httpHeaderAcceptSelected !== undefined) {
headers.set('Accept', httpHeaderAcceptSelected);
}

// to determine the Content-Type header
let consumes: string[] = [
const consumes: string[] = [
'application/json',
'application/xml'
];
let httpContentTypeSelected:string = this.configuration.selectHeaderContentType(consumes);
if (httpContentTypeSelected != undefined) {
const httpContentTypeSelected: string = this.configuration.selectHeaderContentType(consumes);
if (httpContentTypeSelected !== undefined) {
headers.set('Content-Type', httpContentTypeSelected);
}

Expand Down Expand Up @@ -271,17 +271,17 @@ export class PetService {
}

// to determine the Accept header
let httpHeaderAccepts: string[] = [
const httpHeaderAccepts: string[] = [
'application/xml',
'application/json'
];
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
if (httpHeaderAcceptSelected != undefined) {
headers.set("Accept", httpHeaderAcceptSelected);
const httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
if (httpHeaderAcceptSelected !== undefined) {
headers.set('Accept', httpHeaderAcceptSelected);
}

// to determine the Content-Type header
let consumes: string[] = [
const consumes: string[] = [
];

let requestOptions: RequestOptionsArgs = new RequestOptions({
Expand Down Expand Up @@ -323,17 +323,17 @@ export class PetService {
}

// to determine the Accept header
let httpHeaderAccepts: string[] = [
const httpHeaderAccepts: string[] = [
'application/xml',
'application/json'
];
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
if (httpHeaderAcceptSelected != undefined) {
headers.set("Accept", httpHeaderAcceptSelected);
const httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
if (httpHeaderAcceptSelected !== undefined) {
headers.set('Accept', httpHeaderAcceptSelected);
}

// to determine the Content-Type header
let consumes: string[] = [
const consumes: string[] = [
];

let requestOptions: RequestOptionsArgs = new RequestOptions({
Expand Down Expand Up @@ -376,17 +376,17 @@ export class PetService {
}

// to determine the Accept header
let httpHeaderAccepts: string[] = [
const httpHeaderAccepts: string[] = [
'application/xml',
'application/json'
];
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
if (httpHeaderAcceptSelected != undefined) {
headers.set("Accept", httpHeaderAcceptSelected);
const httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
if (httpHeaderAcceptSelected !== undefined) {
headers.set('Accept', httpHeaderAcceptSelected);
}

// to determine the Content-Type header
let consumes: string[] = [
const consumes: string[] = [
];

let requestOptions: RequestOptionsArgs = new RequestOptions({
Expand Down Expand Up @@ -416,22 +416,22 @@ export class PetService {
let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845

// authentication (api_key) required
if (this.configuration.apiKeys["api_key"]) {
headers.set('api_key', this.configuration.apiKeys["api_key"]);
if (this.configuration.apiKeys['api_key']) {
headers.set('api_key', this.configuration.apiKeys['api_key']);
}

// to determine the Accept header
let httpHeaderAccepts: string[] = [
const httpHeaderAccepts: string[] = [
'application/xml',
'application/json'
];
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
if (httpHeaderAcceptSelected != undefined) {
headers.set("Accept", httpHeaderAcceptSelected);
const httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
if (httpHeaderAcceptSelected !== undefined) {
headers.set('Accept', httpHeaderAcceptSelected);
}

// to determine the Content-Type header
let consumes: string[] = [
const consumes: string[] = [
];

let requestOptions: RequestOptionsArgs = new RequestOptions({
Expand Down Expand Up @@ -468,22 +468,22 @@ export class PetService {
}

// to determine the Accept header
let httpHeaderAccepts: string[] = [
const httpHeaderAccepts: string[] = [
'application/xml',
'application/json'
];
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
if (httpHeaderAcceptSelected != undefined) {
headers.set("Accept", httpHeaderAcceptSelected);
const httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
if (httpHeaderAcceptSelected !== undefined) {
headers.set('Accept', httpHeaderAcceptSelected);
}

// to determine the Content-Type header
let consumes: string[] = [
const consumes: string[] = [
'application/json',
'application/xml'
];
let httpContentTypeSelected:string = this.configuration.selectHeaderContentType(consumes);
if (httpContentTypeSelected != undefined) {
const httpContentTypeSelected: string = this.configuration.selectHeaderContentType(consumes);
if (httpContentTypeSelected !== undefined) {
headers.set('Content-Type', httpContentTypeSelected);
}

Expand Down Expand Up @@ -524,17 +524,17 @@ export class PetService {
}

// to determine the Accept header
let httpHeaderAccepts: string[] = [
const httpHeaderAccepts: string[] = [
'application/xml',
'application/json'
];
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
if (httpHeaderAcceptSelected != undefined) {
headers.set("Accept", httpHeaderAcceptSelected);
const httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
if (httpHeaderAcceptSelected !== undefined) {
headers.set('Accept', httpHeaderAcceptSelected);
}

// to determine the Content-Type header
let consumes: string[] = [
const consumes: string[] = [
'application/x-www-form-urlencoded'
];

Expand Down Expand Up @@ -597,16 +597,16 @@ export class PetService {
}

// to determine the Accept header
let httpHeaderAccepts: string[] = [
const httpHeaderAccepts: string[] = [
'application/json'
];
let httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
if (httpHeaderAcceptSelected != undefined) {
headers.set("Accept", httpHeaderAcceptSelected);
const httpHeaderAcceptSelected: string = this.configuration.selectHeaderAccept(httpHeaderAccepts);
if (httpHeaderAcceptSelected !== undefined) {
headers.set('Accept', httpHeaderAcceptSelected);
}

// to determine the Content-Type header
let consumes: string[] = [
const consumes: string[] = [
'multipart/form-data'
];

Expand Down
Loading