Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add default headers for every request in generated api (typescript-fetch) #8444

Open
emreavsar opened this issue Jul 18, 2018 · 0 comments
Open

Comments

@emreavsar
Copy link

emreavsar commented Jul 18, 2018

Code-gen language: typescript-fetch

In Configuration I can only set the following attributes:

export interface ConfigurationParameters {
    apiKey?: string | ((name: string) => string);
    username?: string;
    password?: string;
    accessToken?: string | ((name: string, scopes?: string[]) => string);
    basePath?: string;
}

But adding a set of default headers would be nice, currently I have to add this always when calling the api operation:

let requestHeaders: any = { 
      'Accept': 'application/json',
      'Content-Type': 'application/json'
};

myApi.myOperation(myParam1, myParam2, requestHeaders)
    .then(...);

I saw that there were some investigations in Go language but not in typescript-fetch.

With the current situation I have to wrap each operation in a separate service api class, which is not so nice (especially to maintain these operations etc.)

Is there a way?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant