Replies: 1 comment
-
|
Yes you should declare octet-stream as the response type. That makes your API more semantically correct an obviously helps Orval as Orval assumes * is plain text |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I have a file download endpoint defined like this in my OpenAPI JSON:
{ "/project/participant/generate-excel-template/{projectId}": { "get": { "tags": ["project-participant-controller"], "operationId": "generateExcelTemplate", "parameters": [ { "name": "projectId", "in": "path", "required": true, "schema": { "type": "integer", "format": "int64" } } ], "responses": { "200": { "description": "OK", "content": { "*/*": { "schema": { "type": "string", "format": "binary" } } } } } } } }Orval generates the response type as
Blob, which looks correct:However, the generated Axios config does not include
responseType: "blob". Because of that, the downloaded Excel file is corrupted / cannot be opened.If I manually add
responseType: "blob", the file downloads correctly:My current workaround is to use an Orval transformer and normalize this binary response to
application/octet-streambefore generation.What would be the recommended approach here?
*/*and useapplication/octet-streaminstead?responseType: "blob"whenever the response schema istype: string+format: binary, even if the content type is*/*?Thanks.
Beta Was this translation helpful? Give feedback.
All reactions