openapi-codegen
openapi-codegen copied to clipboard
Question: extending context initial request headers
Hi everyone,
I have a question, I believe it's currently not possible but if it is, it would be nice to know.
With the fetcherOptions in the apiContext (auto-generated and manually modified) I am able to set some specific headers all of the requests. Let's say, for example, the authentication header which will be common to all requests (ie. Bearer Auth).
There are certain APIs, however, that require their own headers. In those cases, with the parameters of the use* generated function I'm able to send those as well without problem.
However, the problem that happens is that because of the way the fetch fn is called, all these initial fetcherOptions headers seem to get overwritten:
myFetchFn({ ...fetcherOptions, ...variables }, signal),
Is there any way to allow it overwrite in a property-specific way? For example something like this:
{headers: {...fetcherOptions.headers, ...variables.headers}} (I know we should check for possible null objects, I'm omitting it for simplicity's sake).
Other way I've been thinking of that could be possible to implement something like this would be passing the variables to the useApiContext() call at the start of each use* function and letting each person to extend the resulting variables in their own fashion or requirements per as the project.
What do you think? Thank you for your help
Hi, sorry but, I didn't understand the issue here. Can you give more context with examples, please?
@needim explained more in #226
I will get to work on fixing this as its blocking me