Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Question: extending context initial request headers

Aperta
#114 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
30/100
Tipo di issue
Funzionalità
Chiarezza
Da chiarire
Stato di attività
Ferma
Stack tecnologico
typescript
Ambito
api, tooling

Direzione di ricerca

Start by tracing the generated use* functions, useApiContext(), fetcherOptions, and the myFetchFn call described in the issue. Clarify the intended property-specific header merge behavior and how per-request variables should interact with shared context options. Done means the chosen behavior is documented and verified for both shared and request-specific headers.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

waiting response

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

Lingua principale
TypeScript
Stelle
634
Fork
83
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di fabien0102/openapi-codegen

Tutte le issue di fabien0102/openapi-codegen

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.