mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-06 18:45:23 +00:00
typescript-fetch: allow configuration of headers and credentials (#3586)
* Fix #3402 by giving the possibility to set additional headers and the credentials parameters to the fetch query. * Fix #3402 : Changes from code review
This commit is contained in:
parent
7f36f26422
commit
b28ef78145
@ -52,10 +52,13 @@ export class BaseAPI {
|
||||
const body = (context.body instanceof FormData || isBlob(context.body))
|
||||
? context.body
|
||||
: JSON.stringify(context.body);
|
||||
|
||||
const headers = Object.assign({}, this.configuration.headers, context.headers);
|
||||
const init = {
|
||||
method: context.method,
|
||||
headers: context.headers,
|
||||
headers: headers,
|
||||
body,
|
||||
credentials: this.configuration.credentials
|
||||
};
|
||||
return { url, init };
|
||||
}
|
||||
@ -121,6 +124,8 @@ export interface ConfigurationParameters {
|
||||
password?: string; // parameter for basic security
|
||||
apiKey?: string | ((name: string) => string); // parameter for apiKey security
|
||||
accessToken?: string | ((name?: string, scopes?: string[]) => string); // parameter for oauth2 security
|
||||
headers?: HTTPHeaders; //header params we want to use on every request
|
||||
credentials?: RequestCredentials; //value for the credentials param we want to use on each request
|
||||
}
|
||||
|
||||
export class Configuration {
|
||||
@ -165,6 +170,14 @@ export class Configuration {
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
get headers(): HTTPHeaders {
|
||||
return this.configuration.headers;
|
||||
}
|
||||
|
||||
get credentials(): RequestCredentials {
|
||||
return this.configuration.credentials;
|
||||
}
|
||||
}
|
||||
|
||||
export type Json = any;
|
||||
|
@ -63,10 +63,13 @@ export class BaseAPI {
|
||||
const body = (context.body instanceof FormData || isBlob(context.body))
|
||||
? context.body
|
||||
: JSON.stringify(context.body);
|
||||
|
||||
const headers = Object.assign({}, this.configuration.headers, context.headers);
|
||||
const init = {
|
||||
method: context.method,
|
||||
headers: context.headers,
|
||||
headers: headers,
|
||||
body,
|
||||
credentials: this.configuration.credentials
|
||||
};
|
||||
return { url, init };
|
||||
}
|
||||
@ -132,6 +135,8 @@ export interface ConfigurationParameters {
|
||||
password?: string; // parameter for basic security
|
||||
apiKey?: string | ((name: string) => string); // parameter for apiKey security
|
||||
accessToken?: string | ((name?: string, scopes?: string[]) => string); // parameter for oauth2 security
|
||||
headers?: HTTPHeaders; //header params we want to use on every request
|
||||
credentials?: RequestCredentials; //value for the credentials param we want to use on each request
|
||||
}
|
||||
|
||||
export class Configuration {
|
||||
@ -176,6 +181,14 @@ export class Configuration {
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
get headers(): HTTPHeaders {
|
||||
return this.configuration.headers;
|
||||
}
|
||||
|
||||
get credentials(): RequestCredentials {
|
||||
return this.configuration.credentials;
|
||||
}
|
||||
}
|
||||
|
||||
export type Json = any;
|
||||
|
@ -63,10 +63,13 @@ export class BaseAPI {
|
||||
const body = (context.body instanceof FormData || isBlob(context.body))
|
||||
? context.body
|
||||
: JSON.stringify(context.body);
|
||||
|
||||
const headers = Object.assign({}, this.configuration.headers, context.headers);
|
||||
const init = {
|
||||
method: context.method,
|
||||
headers: context.headers,
|
||||
headers: headers,
|
||||
body,
|
||||
credentials: this.configuration.credentials
|
||||
};
|
||||
return { url, init };
|
||||
}
|
||||
@ -132,6 +135,8 @@ export interface ConfigurationParameters {
|
||||
password?: string; // parameter for basic security
|
||||
apiKey?: string | ((name: string) => string); // parameter for apiKey security
|
||||
accessToken?: string | ((name?: string, scopes?: string[]) => string); // parameter for oauth2 security
|
||||
headers?: HTTPHeaders; //header params we want to use on every request
|
||||
credentials?: RequestCredentials; //value for the credentials param we want to use on each request
|
||||
}
|
||||
|
||||
export class Configuration {
|
||||
@ -176,6 +181,14 @@ export class Configuration {
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
get headers(): HTTPHeaders {
|
||||
return this.configuration.headers;
|
||||
}
|
||||
|
||||
get credentials(): RequestCredentials {
|
||||
return this.configuration.credentials;
|
||||
}
|
||||
}
|
||||
|
||||
export type Json = any;
|
||||
|
@ -63,10 +63,13 @@ export class BaseAPI {
|
||||
const body = (context.body instanceof FormData || isBlob(context.body))
|
||||
? context.body
|
||||
: JSON.stringify(context.body);
|
||||
|
||||
const headers = Object.assign({}, this.configuration.headers, context.headers);
|
||||
const init = {
|
||||
method: context.method,
|
||||
headers: context.headers,
|
||||
headers: headers,
|
||||
body,
|
||||
credentials: this.configuration.credentials
|
||||
};
|
||||
return { url, init };
|
||||
}
|
||||
@ -132,6 +135,8 @@ export interface ConfigurationParameters {
|
||||
password?: string; // parameter for basic security
|
||||
apiKey?: string | ((name: string) => string); // parameter for apiKey security
|
||||
accessToken?: string | ((name?: string, scopes?: string[]) => string); // parameter for oauth2 security
|
||||
headers?: HTTPHeaders; //header params we want to use on every request
|
||||
credentials?: RequestCredentials; //value for the credentials param we want to use on each request
|
||||
}
|
||||
|
||||
export class Configuration {
|
||||
@ -176,6 +181,14 @@ export class Configuration {
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
get headers(): HTTPHeaders {
|
||||
return this.configuration.headers;
|
||||
}
|
||||
|
||||
get credentials(): RequestCredentials {
|
||||
return this.configuration.credentials;
|
||||
}
|
||||
}
|
||||
|
||||
export type Json = any;
|
||||
|
@ -63,10 +63,13 @@ export class BaseAPI {
|
||||
const body = (context.body instanceof FormData || isBlob(context.body))
|
||||
? context.body
|
||||
: JSON.stringify(context.body);
|
||||
|
||||
const headers = Object.assign({}, this.configuration.headers, context.headers);
|
||||
const init = {
|
||||
method: context.method,
|
||||
headers: context.headers,
|
||||
headers: headers,
|
||||
body,
|
||||
credentials: this.configuration.credentials
|
||||
};
|
||||
return { url, init };
|
||||
}
|
||||
@ -132,6 +135,8 @@ export interface ConfigurationParameters {
|
||||
password?: string; // parameter for basic security
|
||||
apiKey?: string | ((name: string) => string); // parameter for apiKey security
|
||||
accessToken?: string | ((name?: string, scopes?: string[]) => string); // parameter for oauth2 security
|
||||
headers?: HTTPHeaders; //header params we want to use on every request
|
||||
credentials?: RequestCredentials; //value for the credentials param we want to use on each request
|
||||
}
|
||||
|
||||
export class Configuration {
|
||||
@ -176,6 +181,14 @@ export class Configuration {
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
get headers(): HTTPHeaders {
|
||||
return this.configuration.headers;
|
||||
}
|
||||
|
||||
get credentials(): RequestCredentials {
|
||||
return this.configuration.credentials;
|
||||
}
|
||||
}
|
||||
|
||||
export type Json = any;
|
||||
|
@ -63,10 +63,13 @@ export class BaseAPI {
|
||||
const body = (context.body instanceof FormData || isBlob(context.body))
|
||||
? context.body
|
||||
: JSON.stringify(context.body);
|
||||
|
||||
const headers = Object.assign({}, this.configuration.headers, context.headers);
|
||||
const init = {
|
||||
method: context.method,
|
||||
headers: context.headers,
|
||||
headers: headers,
|
||||
body,
|
||||
credentials: this.configuration.credentials
|
||||
};
|
||||
return { url, init };
|
||||
}
|
||||
@ -132,6 +135,8 @@ export interface ConfigurationParameters {
|
||||
password?: string; // parameter for basic security
|
||||
apiKey?: string | ((name: string) => string); // parameter for apiKey security
|
||||
accessToken?: string | ((name?: string, scopes?: string[]) => string); // parameter for oauth2 security
|
||||
headers?: HTTPHeaders; //header params we want to use on every request
|
||||
credentials?: RequestCredentials; //value for the credentials param we want to use on each request
|
||||
}
|
||||
|
||||
export class Configuration {
|
||||
@ -176,6 +181,14 @@ export class Configuration {
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
get headers(): HTTPHeaders {
|
||||
return this.configuration.headers;
|
||||
}
|
||||
|
||||
get credentials(): RequestCredentials {
|
||||
return this.configuration.credentials;
|
||||
}
|
||||
}
|
||||
|
||||
export type Json = any;
|
||||
|
Loading…
Reference in New Issue
Block a user