multipart/form-data ambiguity #5321
Replies: 1 comment 1 reply
-
Since
I don't think this is necessary because the problem you're trying to solve is one of a header advertising a value instead of needing a schema constraint, and that's one of the core problems we're trying to solve with SAFs (#5310). So I think whatever solution we come up with there is what should be used here. However, I don't really think this needs much of a solution anyway. There's nothing meaningful you can do with |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
https://spec.openapis.org/oas/latest#additional-encoding-approaches says that if we want to serialize an object as multipart/form-data but use a fixed part order (e.g. we sort alphabetically by "name"), the way to specify that in the OAD is with:
Now, when I deserialize this message content, and I get data that looks like:
{ alpha => "something-encoded", beta => "something-else-encoded" },..now I need to find the encoding object (
prefixEncodingentry) that corresponds with each property value so it can be appropriately further decoded. The spec suggests that I do this by looking at theheaderskeyword under eachprefixEncodingencoding object and parsing its schema -- this seems far too fragile to be useful as it cannot be expected to be implemented consistently across implementations.I would suggest one of these two alternatives:
when
prefixEncoding(as opposed toencoding) is present in the media-type object (oritemSchemais present instead ofschema), that the form data be decoded directly to an array instead of an object, and thenprefixEncodingobjects can be applied to each array item as normal for array content (after all, why would it be important to keep parts in a specific order in the message body if we're just going to deserialize back to an object anyway, where the ordering is lost? so surely the user wants the data in array form anyway);introduce a "name" property in the encoding object, which is to be used when
prefixEncodingoritemEncodingobjects are used (and ignored inencoding, as it is redundant with the property name for this encoding object). This provides a direct and unambiguous mechanism to find whichprefixEncodingentry corresponds to each value in the deserialized object.As an aside, this would also be a useful application of the parameters-in-headers idea (#2342), as then "name" could be indicated as a parameter under the header:
Beta Was this translation helpful? Give feedback.
All reactions