New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Array of files in multipart/form-data is not handled correctly #692
Comments
BTW, I'd be happy to contribute a fix for this if this is indeed a bug. But wanted to first verify to see if there was a reason that the list of files was being serialized as json. |
I'm facing the same issue. Any plans to merge the fix? |
This will work today if you have a schema like this: "schema": {
"type": "array",
"items": {
"type": "string",
"format": "binary"
}
} You're right though, that the object format does need to be supported so that explicit file names can be set via the object keys. This probably needs to be a different object (not Also, for completeness, the encoding object will give better control over how this works. For an initial fix, though, using all of the defaults it defines (e.g., arrays inherit, I'm totally open to a PR implementing a solution here! |
Describe the bug
For multipart/form-data with an array of files, generated code tries to serialize the array of files as JSON.
To Reproduce
Steps to reproduce the behavior:
openapi-python-client --path spec.json
The following error occurs:
Expected behavior
The generated code for handling an array of files seems to be trying to serialize the files as json:
Based on https://www.python-httpx.org/advanced/#multipart-file-encoding, we should probably be doing something more like the following, treating the multipart data as a list of tuples, with field keys that can repeat. Each file is added to the list under the same "files" key:
OpenAPI Spec File
Desktop (please complete the following information):
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: