You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
The swift5 generator is broken for API endpoint that should upload binary data (request body with a "application/octet-stream" content).
Currently, the generated code ask for a swift Url.
I would expect this to read the request body's data from the file at Url, but instead, it send the Url as is in the request body.
(Note: I find surprising to ask for a file Url instead of a Data, since we could want to generate the binary blob on the fly without using any file.)
I saw that there is an option named mapFileBinaryToData which replace the Url type with a Data one (but it is marked as deprecated).
With this option I am able to give the binary blob directly to the function, but instead of being send as is, it get base64 encoded.
Looking into the code I can see that this is a bug, as there is no piece of code to read a file, and as we never add the "application/octet-stream" content-type (which explain the base64 encoding since we default to json)
Bug Report Checklist
Description
The swift5 generator is broken for API endpoint that should upload binary data (request body with a "application/octet-stream" content).
Currently, the generated code ask for a swift
Url
.I would expect this to read the request body's data from the file at
Url
, but instead, it send the Url as is in the request body.(Note: I find surprising to ask for a file Url instead of a Data, since we could want to generate the binary blob on the fly without using any file.)
I saw that there is an option named
mapFileBinaryToData
which replace theUrl
type with aData
one (but it is marked as deprecated).With this option I am able to give the binary blob directly to the function, but instead of being send as is, it get base64 encoded.
Looking into the code I can see that this is a bug, as there is no piece of code to read a file, and as we never add the "application/octet-stream" content-type (which explain the base64 encoding since we default to json)
openapi-generator version
master
OpenAPI declaration file content or url
Here is a minimalist file for reproduction
Generation Details
No special option, just generate the API with
-g swift5
Steps to reproduce
Generate the swift code from the above json and try to use the endpoint with a Url.
See that it is not sending the binary data
Related issues/PRs
Very similar problem
#14268
PR that introduced file upload
#16299
With its issue
#16300
Suggest a fix
PR incoming
The text was updated successfully, but these errors were encountered: