hey-api / openapi-ts

🚀 The OpenAPI to TypeScript codegen. Generate clients, SDKs, validators, and more. Support: @mrlubos
https://heyapi.dev
Other
1.4k stars 106 forks source link

@hey-api/client-fetch Returns response as Blob for Accept: "application/ld+json" #1288

Closed zilvinas-abromavicius-surfshark closed 1 week ago

zilvinas-abromavicius-surfshark commented 1 week ago

Description

It seems that when passing header to Accept ld+json format, the response returned is a Blob instead of a json. E.g. I initialize the client as such:

  const client = createClient({
    baseUrl,
    headers: {
      Accept: "application/ld+json",
    },
  });

And when logging, I get such result for response.data: data: Blob { size: 162241, type: 'application/ld+json;charset=utf-8' },

Reproducible example or configuration

No response

OpenAPI specification (optional)

No response

System information (optional)

No response

scripness commented 1 week ago

To fix that I use: parseAs: 'json' in client.setConfig.

Also while we're here, is there a way to tell the client to prioritize ld+json? For example when we run some operation in response to the generated service we get as typescript response the json object while in reality (since we set the headers to ld+json) it comes with the extra fields.

zilvinas-abromavicius-surfshark commented 1 week ago

To fix that I use: parseAs: 'json' in client.setConfig.

Also while we're here, is there a way to tell the client to prioritize ld+json? For example when we run some operation in response to the generated service we get as typescript response the json object while in reality (since we set the headers to ld+json) it comes with the extra fields.

Thanks a lot, this seems to resolve the issue for now!

mrlubos commented 1 week ago

@zilvinas-abromavicius-surfshark can you add a reproducible example?