swagger-api / swagger-api/swagger-codegen
Typescript-fetch client default headers for every request
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
I want to be able add default headers to every request. Right now this includes the accept heard. Like this:
accept: 'application/json'
For every request right now I have to add it in the options like this
let response: LensResponse[] = await LensApiFactory({}, fetch).getChildrenLensTreeUsingGET(id, undefined, undefined, { headers: { accept: 'application/json' } })
but as you can see this can get pretty tedious. Do we have an option to add header to every request? the configuration param that factory takes in doesn't have header as an option.
Swagger-codegen version
3.0.24
Related issues/PRs
https://github.com/swagger-api/swagger-codegen/issues/8444
Suggest a fix/enhancement
Add ability to add custom headers in the config
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the typescript-fetch generator and the LensApiFactory configuration entry point, then trace how request options and headers are assembled. Check the related issue for prior context. Done means configuration can provide headers applied to every request while per-request headers remain usable, with coverage for the generated client behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100