-
Notifications
You must be signed in to change notification settings - Fork 9.1k
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
Support for multipart/mixed
(and possibly better multipart/*
support in general)
#3721
Comments
It's also worth noting that when uploading multiple files for a form field with |
EDIT: guess I should have read your link. Another multipart option missing is the ability to send multiple files in a single form field. It should be a form-data payload with a nested multipart body with individual parts for each file. There is no way to define a nested multipart payload. This is as far as I can get with it. But no way to define the nested body parts if I were to send multiple file types requestBody:
content:
'multipart/form-data':
schema:
name:
type: string
file:
type: string
format: binary
encoding:
name:
headers:
content-disposition:
schema:
type: string
contentType: 'application/json'
file:
headers:
content-disposition:
schema:
type: string
contentType: 'multipart/mixed' |
@jeremyfiel I know that I noticed that the most recent |
A big missing piece from the Because the RFC is so old, and was originally for email messaging, apparently they didn't have a need to identify the body parts and the form-data RFC didn't address the if we could depend on this same header, I think it would help quite a lot to define mixed bodies with OAS, with the same syntax as |
I'm not entirely sure we have a nested implementation, but we do heavily use |
So it turns out that, in theory, support for
The question remains, how is it supposed to work? Somewhere during the extensive GitHub archaeology involved in digging this up, I thought I found an example of someone using a Unfortunately, But I'm guessing that even if you can use I still need to take another pass at reading how array instances work with the Encoding Object as their might be something there, at least if all of the parts are of the same type (which kind of goes against the whole 🤔 |
related #3827 (reply in thread) |
There is another thing that the RFC specifies that is not currently supported by the "deserialize into a JSON object" mechanism: the ordering of the parts must be preserved. I think that, combined with duplicate names being allowed, means that we need to pivot to deserializing message parts (of any multipart/* type) as array items, rather than as object values. This is of course a breaking change. |
@karenetheridge the multiple files with the same name is handled with a property that is itself an array (see example at the end of the linked section). It's on my TODO list to figure out if an array property using For My current thought is that it would define relative numeric order (so people don't have to worry about keeping a perfect sequential set of numbers), ordering This would also be important for supporting #1502 as query strings can also have duplicate names and are considered to be ordered (although whether the order of Parameter Objects with |
It looks like Also, there is a I really have no idea how the changes for 3.0 were supposed to support |
@jeremyfiel @karenetheridge OK I've been thinking on this more, and I realized that my statement that So... I don't see anything that says you can't use We can also look at the definition of Now, how many tools out there will support such a thing? No clue. But it is the only way I can think of that PR #878 could have resulted in issue #303 being closed: the whole Encoding Object depends on a We might as well document that in 3.0.4 (because 3.0.3 actually has a (But we should still also be able to support ordered |
We occasionally see folks trying to use OAS with
multipart/mixed
, which does not support it. But it would not be hard to define a mapping along the lines ofmultipart/form-data
but with more of an array model. See also discussion #2599. I think @jeremyfiel also has experience with this.[EDIT: See also
multipart/x-mixed-replace
which AFAICT does not have a usable specification as WHATWG explicitly states in that section that there spec "describes processing rules for web browsers" and relegates everything else tomultipart/mixed
... I guess non-web-browsers aren't supposed to process it? 😒 ]The text was updated successfully, but these errors were encountered: