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

[BUG] [axios-typescript] header values configured via Configuration#baseOptions are dropped #4121

Closed
5 tasks done
johannes-darms opened this issue Oct 10, 2019 · 5 comments
Closed
5 tasks done

Comments

@johannes-darms
Copy link

johannes-darms commented Oct 10, 2019

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator
  • What's the version of OpenAPI Generator used?
  • Have you search for related issues/PRs?
  • What's the actual output vs expected output?
Description

Custom headers set via baseOptions of a Configuration object are not present in the axios request. Expected behaviour: they are present ;).

openapi-generator version

4.1.2

OpenAPI declaration file content or url

any, can be used

Command line used for generation

any, can be used

Steps to reproduce

Pass this Configuration to a *AxiosParamCreator, the axios request should contain the custom header but is doesn't.

new Configuration({
        baseOptions: {
          headers: {
            'x-CUSTOM-VALUE': `xxx`,
          },
        },
      })
Related issues/PRs
Suggest a fix

johannes-darms@cd12d42

@johannes-darms johannes-darms changed the title [BUG] axios-typescript header values configured via baseoption are dropped [BUG] [axios-typescript] header values configured via Configuration#baseOptions are dropped Oct 10, 2019
@macjohnny
Copy link
Member

I think the problem is that

localVarRequestOptions.headers = {...localVarHeaderParameter, ...options.headers};

should be changed to something like

localVarRequestOptions.headers = {
  ...localVarHeaderParameter, 
  ...options.headers,
  ...(baseOptions ? baseOptions.headers : {})
};

@johannes-darms would you like to implement and test this fix in

localVarRequestOptions.headers = {...localVarHeaderParameter, ...options.headers};

?

@macjohnny
Copy link
Member

the suggested fix johannes-darms@cd12d42 looks good
would you like to file a PR?

@johannes-darms
Copy link
Author

the suggested fix johannes-darms@cd12d42 looks good
would you like to file a PR?

sure.

@jonathan-avento
Copy link

What is the status of this, was a PR ever created?

@joshlang232
Copy link

It looks like this commit fixes the issue: a4fc319

It seems safe to close this issue as a duplicate of #5420

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

No branches or pull requests

4 participants