Open monscamus opened 4 years ago
👍 Thanks for opening this issue! 🏷 I have applied any labels matching special text in your issue.
The team will review the labels and make any necessary changes.
Any progress on this or a timeline on when it might be added?
I run into the same issue that a custom response header was not inside the header array. Investigating the server response with browser developer tools showed that the header exists. After some research i think it is not a bug of the typescript-fetch generator. It is more likely that custom response headers are not accessible due to the cors nature of the request https://developers.google.com/web/updates/2015/03/introduction-to-fetch#response_types
The relevant part:
If a request is made for a resource on another origin which returns the CORs headers, then the type is cors. cors and basic responses are almost identical except that a cors response restricts the headers you can view to
Cache-Control
,Content-Language
,Content-Type
,Expires
,Last-Modified
, andPragma
.
If you don't provide a fetchApi per configuration the browser fetchApi implementation is used and this one takes care of copying headers to the array of the response object (and only the ones you are allowed to view):
get fetchApi(): FetchAPI { return this.configuration.fetchApi || window.fetch.bind(window); }
Solution (worked for me): The server must provide the "Access-Control-Expose-Headers" Header field. As value define all the custom header names that are not part of the default cors header list: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Expose-Headers
Bug Report Checklist
Description
When calling this method I know from the documents that the response provides details of a document created in the header.location but I can't examine this with the typescript-fetch API? The following snippet from a React test app is where I see the response headers are empty. If I use the standard dap
openapi-generator version
4.3.1
OpenAPI declaration file content or url
https://raw.githubusercontent.com/legalesign/Legalesign-V1-OpenAPI3/master/legalesign-api-v1.yaml
Command line used for generation
openapi-generator generate -i https://raw.githubusercontent.com/legalesign/Legalesign-V1-OpenAPI3/master/legalesign-api-v1.yaml -g typescript-fetch --additional-properties supportsES6=true
Steps to reproduce
Execute generation, make any Raw Api call - check response.headers.
Related issues/PRs
https://github.com/swagger-api/swagger-codegen/issues/7828
Suggest a fix
Should the baseApi.fetchApi.response be mapping onto this?