title: Is it possible to auto-generate custom HTTP Headers using nswag (TypeScript)
body: <p>I use <code>nswag</code> <a href="https://www.npmjs.com/package/nswag" rel="nofollow noreferrer">npm package</a> to generate http services, interfaces, etc.</p>
  
  <p>The typescript code for a typical service proxy looks as follows:</p>
  
  <pre><code>@Injectable()
  export class TenantsServiceProxy {
  ...
      constructor(@Inject(HttpClient) http: HttpClient, @Optional() @Inject(API_BASE_URL) baseUrl?: string) {
      ...
  
      getTenantId(subdomain: string | null): Observable&lt;number | null&gt; {
      ...
          let options_ : any = {
              observe: "response",
              responseType: "blob",
              headers: new HttpHeaders({
                  "Content-Type": "application/json", 
                  "Accept": "application/json"
                  })
              };
  
          return this.http.request("get", url_, options_).flatMap((response_ : any) =&gt; {
              return this.processGetTenantId(response_);
          }).catch((response_: any) =&gt; {
          ...
  </code></pre>
  
  <p>Regarding the bit where <code>HTTP Headers</code> are detailed:</p>
  
  <p>I wonder if there's a way to tell the <code>nswag</code> tool to add an extra header (<code>Authorization</code> for JWT Bearer in my case) automatically?</p>
  
  <p>Of course there's sort of a hacky workaround to replace the headers bit using text editor with the following code:</p>
  
  <pre><code>headers: new HttpHeaders({
              "Content-Type": "application/json", 
              "Accept": "application/json",
              'Authorization': 'Bearer ' + localStorage.getItem('token')
          })
  </code></pre>
  
  <p>But I suspect there might be a way to include additional headers.</p>
  
  <p>Maybe someone has already solved this issue?</p>