openapi-typescript icon indicating copy to clipboard operation
openapi-typescript copied to clipboard

Guess the used content type when multiple content is defined

Open armandabric opened this issue 1 year ago • 1 comments

Changes

This is a follow up of the workaround merged in this PR https://github.com/drwpow/openapi-typescript/pull/1597

Here the point is to infer the content type from the Accept header on each request.

For now I'm stuck, in the ClientMethod type, I did not succeed to infer the type. The I extends MaybeOptionalInit<Paths[P], M, AcceptHeader>, seems to prevent the inference. Did someone have an idea?

When this works, I still need to add a branch on the ParseAsResponse to manage the content type only on parseAs: json

Checklist

  • [ ] Unit tests updated
  • [ ] docs/ updated (if necessary)
  • [ ] pnpm run update:examples run (only applicable for openapi-typescript)

armandabric avatar Mar 28 '24 09:03 armandabric

⚠️ No Changeset found

Latest commit: 1c50300ecdba1d89f2f5f9a9bddbe6eff10dca60

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

changeset-bot[bot] avatar Mar 28 '24 09:03 changeset-bot[bot]