orval-labs / orval

orval is able to generate client with appropriate type-signatures (TypeScript) from any valid OpenAPI v3 or Swagger v2 specification, either in yaml or json formats. 🍺
https://orval.dev
MIT License
3.18k stars 336 forks source link

Fetch: add headers to response #1694

Closed nimo23 closed 1 week ago

nimo23 commented 2 weeks ago

What are the steps to reproduce this issue?

  1. Generate queries by using fetch api
  2. Look into the response object
  3. No headers are in the response object

What happens?

No headers will be in the response object. The code looks like:

  const res = await fetch(getTaskResourceListAllUrl(params),
  {      
    ...options,
    method: 'GET'
  }

  )
  const data = await res.json()
  // Issue: please add the "res.headers" into the return statement
  return { status: res.status, data }
}

What were you expecting to happen?

Add headers in the response object, at least when openapi.json describes custom headers for an API endpoint.

What versions are you using?

"orval": "^7.2.0",

melloware commented 2 weeks ago

@nimo23 can you review my PR i think that is what you are asking for?