openapi-typescript-codegen
openapi-typescript-codegen copied to clipboard
optionally pass other setting to AxiosRequestConfig used in axios.request(requestConfig);
Describe the solution you'd like A clear and concise description of what you want to happen. Ideally with a small example of the proposed changes.
// In the generated client's constructor, it could be
constructor(config?: Partial<OpenAPIConfig>, HttpRequest: HttpRequestConstructor = AxiosHttpRequest, rawAxiosConfig: AxiosRequestConfig) {
// save rawAxiosConfig somethere
}
// in the generated request.ts
const requestConfig: AxiosRequestConfig = {
url,
headers,
data: body ?? formData,
method: options.method,
withCredentials: config.WITH_CREDENTIALS,
cancelToken: source.token,
...rawAxiosConfig
};
now:
// current
constructor(config?: Partial<OpenAPIConfig>, HttpRequest: HttpRequestConstructor = AxiosHttpRequest) {
this.request = new HttpRequest({
BASE: config?.BASE ?? '',
VERSION: config?.VERSION ?? '1.0',
WITH_CREDENTIALS: config?.WITH_CREDENTIALS ?? false,
CREDENTIALS: config?.CREDENTIALS ?? 'include',
TOKEN: config?.TOKEN,
USERNAME: config?.USERNAME,
PASSWORD: config?.PASSWORD,
HEADERS: config?.HEADERS,
ENCODE_PATH: config?.ENCODE_PATH,
});
// in the generated request.ts
const requestConfig: AxiosRequestConfig = {
url,
headers,
data: body ?? formData,
method: options.method,
withCredentials: config.WITH_CREDENTIALS,
cancelToken: source.token,
};
Hey @grimmer0125, please migrate to https://github.com/hey-api/openapi-ts if you'd like this addressed. I'm actually working on an Axios client right now which will follow the Fetch API client I released yesterday