forked from loafle/openapi-generator-original
[typescript-fetch] support custom stringify for query string (#3327)
* [typescript-fetch] support custom query stringify * [typescript-fetch] support custom query stringify
This commit is contained in:
parent
d117506b8a
commit
3eac8391f5
@ -47,7 +47,7 @@ export class BaseAPI {
|
|||||||
// only add the querystring to the URL if there are query parameters.
|
// only add the querystring to the URL if there are query parameters.
|
||||||
// this is done to avoid urls ending with a "?" character which buggy webservers
|
// this is done to avoid urls ending with a "?" character which buggy webservers
|
||||||
// do not handle correctly sometimes.
|
// do not handle correctly sometimes.
|
||||||
url += '?' + querystring(context.query);
|
url += '?' + this.configuration.queryParamsStringify(context.query);
|
||||||
}
|
}
|
||||||
const body = (context.body instanceof FormData || isBlob(context.body))
|
const body = (context.body instanceof FormData || isBlob(context.body))
|
||||||
? context.body
|
? context.body
|
||||||
@ -116,6 +116,7 @@ export interface ConfigurationParameters {
|
|||||||
basePath?: string; // override base path
|
basePath?: string; // override base path
|
||||||
fetchApi?: FetchAPI; // override for fetch implementation
|
fetchApi?: FetchAPI; // override for fetch implementation
|
||||||
middleware?: Middleware[]; // middleware to apply before/after fetch requests
|
middleware?: Middleware[]; // middleware to apply before/after fetch requests
|
||||||
|
queryParamsStringify?: (params: HTTPQuery) => string; // stringify function for query strings
|
||||||
username?: string; // parameter for basic security
|
username?: string; // parameter for basic security
|
||||||
password?: string; // parameter for basic security
|
password?: string; // parameter for basic security
|
||||||
apiKey?: string | ((name: string) => string); // parameter for apiKey security
|
apiKey?: string | ((name: string) => string); // parameter for apiKey security
|
||||||
@ -137,6 +138,10 @@ export class Configuration {
|
|||||||
return this.configuration.middleware || [];
|
return this.configuration.middleware || [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get queryParamsStringify(): (params: HTTPQuery) => string {
|
||||||
|
return this.configuration.queryParamsStringify || querystring;
|
||||||
|
}
|
||||||
|
|
||||||
get username(): string | undefined {
|
get username(): string | undefined {
|
||||||
return this.configuration.username;
|
return this.configuration.username;
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,7 @@ export class BaseAPI {
|
|||||||
// only add the querystring to the URL if there are query parameters.
|
// only add the querystring to the URL if there are query parameters.
|
||||||
// this is done to avoid urls ending with a "?" character which buggy webservers
|
// this is done to avoid urls ending with a "?" character which buggy webservers
|
||||||
// do not handle correctly sometimes.
|
// do not handle correctly sometimes.
|
||||||
url += '?' + querystring(context.query);
|
url += '?' + this.configuration.queryParamsStringify(context.query);
|
||||||
}
|
}
|
||||||
const body = (context.body instanceof FormData || isBlob(context.body))
|
const body = (context.body instanceof FormData || isBlob(context.body))
|
||||||
? context.body
|
? context.body
|
||||||
@ -127,6 +127,7 @@ export interface ConfigurationParameters {
|
|||||||
basePath?: string; // override base path
|
basePath?: string; // override base path
|
||||||
fetchApi?: FetchAPI; // override for fetch implementation
|
fetchApi?: FetchAPI; // override for fetch implementation
|
||||||
middleware?: Middleware[]; // middleware to apply before/after fetch requests
|
middleware?: Middleware[]; // middleware to apply before/after fetch requests
|
||||||
|
queryParamsStringify?: (params: HTTPQuery) => string; // stringify function for query strings
|
||||||
username?: string; // parameter for basic security
|
username?: string; // parameter for basic security
|
||||||
password?: string; // parameter for basic security
|
password?: string; // parameter for basic security
|
||||||
apiKey?: string | ((name: string) => string); // parameter for apiKey security
|
apiKey?: string | ((name: string) => string); // parameter for apiKey security
|
||||||
@ -148,6 +149,10 @@ export class Configuration {
|
|||||||
return this.configuration.middleware || [];
|
return this.configuration.middleware || [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get queryParamsStringify(): (params: HTTPQuery) => string {
|
||||||
|
return this.configuration.queryParamsStringify || querystring;
|
||||||
|
}
|
||||||
|
|
||||||
get username(): string | undefined {
|
get username(): string | undefined {
|
||||||
return this.configuration.username;
|
return this.configuration.username;
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,7 @@ export class BaseAPI {
|
|||||||
// only add the querystring to the URL if there are query parameters.
|
// only add the querystring to the URL if there are query parameters.
|
||||||
// this is done to avoid urls ending with a "?" character which buggy webservers
|
// this is done to avoid urls ending with a "?" character which buggy webservers
|
||||||
// do not handle correctly sometimes.
|
// do not handle correctly sometimes.
|
||||||
url += '?' + querystring(context.query);
|
url += '?' + this.configuration.queryParamsStringify(context.query);
|
||||||
}
|
}
|
||||||
const body = (context.body instanceof FormData || isBlob(context.body))
|
const body = (context.body instanceof FormData || isBlob(context.body))
|
||||||
? context.body
|
? context.body
|
||||||
@ -127,6 +127,7 @@ export interface ConfigurationParameters {
|
|||||||
basePath?: string; // override base path
|
basePath?: string; // override base path
|
||||||
fetchApi?: FetchAPI; // override for fetch implementation
|
fetchApi?: FetchAPI; // override for fetch implementation
|
||||||
middleware?: Middleware[]; // middleware to apply before/after fetch requests
|
middleware?: Middleware[]; // middleware to apply before/after fetch requests
|
||||||
|
queryParamsStringify?: (params: HTTPQuery) => string; // stringify function for query strings
|
||||||
username?: string; // parameter for basic security
|
username?: string; // parameter for basic security
|
||||||
password?: string; // parameter for basic security
|
password?: string; // parameter for basic security
|
||||||
apiKey?: string | ((name: string) => string); // parameter for apiKey security
|
apiKey?: string | ((name: string) => string); // parameter for apiKey security
|
||||||
@ -148,6 +149,10 @@ export class Configuration {
|
|||||||
return this.configuration.middleware || [];
|
return this.configuration.middleware || [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get queryParamsStringify(): (params: HTTPQuery) => string {
|
||||||
|
return this.configuration.queryParamsStringify || querystring;
|
||||||
|
}
|
||||||
|
|
||||||
get username(): string | undefined {
|
get username(): string | undefined {
|
||||||
return this.configuration.username;
|
return this.configuration.username;
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,7 @@ export class BaseAPI {
|
|||||||
// only add the querystring to the URL if there are query parameters.
|
// only add the querystring to the URL if there are query parameters.
|
||||||
// this is done to avoid urls ending with a "?" character which buggy webservers
|
// this is done to avoid urls ending with a "?" character which buggy webservers
|
||||||
// do not handle correctly sometimes.
|
// do not handle correctly sometimes.
|
||||||
url += '?' + querystring(context.query);
|
url += '?' + this.configuration.queryParamsStringify(context.query);
|
||||||
}
|
}
|
||||||
const body = (context.body instanceof FormData || isBlob(context.body))
|
const body = (context.body instanceof FormData || isBlob(context.body))
|
||||||
? context.body
|
? context.body
|
||||||
@ -127,6 +127,7 @@ export interface ConfigurationParameters {
|
|||||||
basePath?: string; // override base path
|
basePath?: string; // override base path
|
||||||
fetchApi?: FetchAPI; // override for fetch implementation
|
fetchApi?: FetchAPI; // override for fetch implementation
|
||||||
middleware?: Middleware[]; // middleware to apply before/after fetch requests
|
middleware?: Middleware[]; // middleware to apply before/after fetch requests
|
||||||
|
queryParamsStringify?: (params: HTTPQuery) => string; // stringify function for query strings
|
||||||
username?: string; // parameter for basic security
|
username?: string; // parameter for basic security
|
||||||
password?: string; // parameter for basic security
|
password?: string; // parameter for basic security
|
||||||
apiKey?: string | ((name: string) => string); // parameter for apiKey security
|
apiKey?: string | ((name: string) => string); // parameter for apiKey security
|
||||||
@ -148,6 +149,10 @@ export class Configuration {
|
|||||||
return this.configuration.middleware || [];
|
return this.configuration.middleware || [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get queryParamsStringify(): (params: HTTPQuery) => string {
|
||||||
|
return this.configuration.queryParamsStringify || querystring;
|
||||||
|
}
|
||||||
|
|
||||||
get username(): string | undefined {
|
get username(): string | undefined {
|
||||||
return this.configuration.username;
|
return this.configuration.username;
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,7 @@ export class BaseAPI {
|
|||||||
// only add the querystring to the URL if there are query parameters.
|
// only add the querystring to the URL if there are query parameters.
|
||||||
// this is done to avoid urls ending with a "?" character which buggy webservers
|
// this is done to avoid urls ending with a "?" character which buggy webservers
|
||||||
// do not handle correctly sometimes.
|
// do not handle correctly sometimes.
|
||||||
url += '?' + querystring(context.query);
|
url += '?' + this.configuration.queryParamsStringify(context.query);
|
||||||
}
|
}
|
||||||
const body = (context.body instanceof FormData || isBlob(context.body))
|
const body = (context.body instanceof FormData || isBlob(context.body))
|
||||||
? context.body
|
? context.body
|
||||||
@ -127,6 +127,7 @@ export interface ConfigurationParameters {
|
|||||||
basePath?: string; // override base path
|
basePath?: string; // override base path
|
||||||
fetchApi?: FetchAPI; // override for fetch implementation
|
fetchApi?: FetchAPI; // override for fetch implementation
|
||||||
middleware?: Middleware[]; // middleware to apply before/after fetch requests
|
middleware?: Middleware[]; // middleware to apply before/after fetch requests
|
||||||
|
queryParamsStringify?: (params: HTTPQuery) => string; // stringify function for query strings
|
||||||
username?: string; // parameter for basic security
|
username?: string; // parameter for basic security
|
||||||
password?: string; // parameter for basic security
|
password?: string; // parameter for basic security
|
||||||
apiKey?: string | ((name: string) => string); // parameter for apiKey security
|
apiKey?: string | ((name: string) => string); // parameter for apiKey security
|
||||||
@ -148,6 +149,10 @@ export class Configuration {
|
|||||||
return this.configuration.middleware || [];
|
return this.configuration.middleware || [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get queryParamsStringify(): (params: HTTPQuery) => string {
|
||||||
|
return this.configuration.queryParamsStringify || querystring;
|
||||||
|
}
|
||||||
|
|
||||||
get username(): string | undefined {
|
get username(): string | undefined {
|
||||||
return this.configuration.username;
|
return this.configuration.username;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user