openapistack / openapi-client-axios

JavaScript client library for consuming OpenAPI-enabled APIs with axios
https://openapistack.co
MIT License
558 stars 67 forks source link

Setting headers manually does not override initial headers #76

Closed tominkki closed 2 years ago

tominkki commented 3 years ago

I'm not completely sure if this is bug or desired feature, but behaviour when setting headers manually for one request is (atleast in this case) weird.

Expected behaviour

Manually set headers overrides initial headers: authorization: 'Bearer token'

Actual behaviour

Manually set headers are joined to initial headers: authorization: 'initial header, Bearer token'

Steps to reproduce

const config = {
    definition: definition,
    axiosConfigDefaults: {
      headers: {
        authorization: 'initial header',
      },
    },
  };

const api  = new OpenAPIClientAxios(config);
api.withServer({ url });
await api.init();
const client = await api.getClient();

client.postSomething(null, data, { 
    headers: { 
      authorization: 'Bearer token' 
    } 
  }
);
anttiviljami commented 3 years ago

Morjes! Sorry but I'm unable to reproduce this.

This is definitely not the expected behaviour.

Could you take a look at this to see if you can spot anything wrong @tominkki ?

https://github.com/anttiviljami/openapi-client-axios/blob/master/src/client.ts#L388

npdev453 commented 2 years ago

I can't found reproduction too.

@tominkki, could you please provide more details? axios and openapi-cleint-axios version, webpack babel configuration

anttiviljami commented 2 years ago

Closing issue due to inactivity