[REQ] [TypeScript-Node] support setting the content-type header per-call
Created by: silasbw
Is your feature request related to a problem? Please describe.
Some API endpoints accept multiple content-types with the same data format. For example, many of the Kubernetes API PATCH endpoints accept JSON data format, but with several different possible content-types (e.g., application/strategic-merge-patch+json, application/merge-patch+json, or application/json-patch+json).
The typescript-node implementation makes it cumbersome to call the same endpoint with different content-types, although you can accomplish it by setting content-type in .defaultHeaders
before the call, and restoring the previous value of content-type after the call.
Describe the solution you'd like
I'd like to specify this on a per-call basis. For example, by adding a final options
parameter to each call:
const result = await client.patchNamespace('foo', body, { headers: { 'content-type': 'application/strategic-merge-patch+json' } })
Describe alternatives you've considered
The workaround mentioned above:
const contentType = client.defaultHeaders['content-type']
client.defaultHeaders['content-type'] = 'application/strategic-merge-patch+json'
const resultPromise = client.patchNamespace('foo', body)
client.defaultHeaders['content-type'] = contentType
const result = await resultPromise