Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

optionally pass other setting to AxiosRequestConfig used in axios.request(requestConfig); #2157

Open
grimmer0125 opened this issue May 22, 2024 · 1 comment

Comments

@grimmer0125
Copy link

grimmer0125 commented May 22, 2024

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,
    };        
@mrlubos
Copy link
Collaborator

mrlubos commented May 22, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants