Openapi-generator: [BUG] [axios-typescript] header values configured via Configuration#baseOptions are dropped

Created on 10 Oct 2019  路  5Comments  路  Source: OpenAPITools/openapi-generator

Bug Report Checklist

  • [x] Have you provided a full/minimal spec to reproduce the issue?
  • [x] Have you validated the input using an OpenAPI validator
  • [x] What's the version of OpenAPI Generator used?
  • [x] Have you search for related issues/PRs?
  • [x] 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

https://github.com/johannes-darms/openapi-generator/commit/cd12d42df1cb139c1b16d80b4a8b9bc8425357f1

TypeScript Bug

All 5 comments

I think the problem is that
https://github.com/OpenAPITools/openapi-generator/blob/b69b8cdd31aef20bf41022d84df08bc62aca747e/samples/client/petstore/typescript-axios/builds/default/api.ts#L294

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
https://github.com/OpenAPITools/openapi-generator/blob/b69b8cdd31aef20bf41022d84df08bc62aca747e/modules/openapi-generator/src/main/resources/typescript-axios/apiInner.mustache#L191
?

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

sure.

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pellyadolfo picture pellyadolfo  路  21Comments

seunlanlege picture seunlanlege  路  23Comments

samarthgupta437 picture samarthgupta437  路  21Comments

jonrimmer picture jonrimmer  路  80Comments

MartinDelille picture MartinDelille  路  35Comments