Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #1867
Closed
Open
Issue created Jan 09, 2019 by Administrator@rootContributor

[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

Additional context

https://github.com/swagger-api/swagger-codegen/issues/9035

Assignee
Assign to
Time tracking