Add support to OpenAPI 3.1 to use non-string params in multipart/form-data operations
Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.
Problem
OpenAPI 3.1 extends the support to customize request generation for non-string params in multipart/form-data requests by using JsonSchema data and supporting more properties from Encoding object. Almost none of these properties are being used by current the OpenAPI 3.1 reader. The OpenAPI 3.1 reader should take advantage of the specific serialization information during request generation.
This issue follows up on the work to add/extend the support to non-string parameters in multipart/form-data requests for OpenAPI 3.1 documents. There was a bug, which was resolved for OpenAPI spec 2.0 and also for OpenAPI 3.0. At this time, only the basic support is shared between OpenAPI 3.0 and OpenAPI 3.1 readers.
Related issues
Links
- OpenAPI 3.1: Special Considerations for
multipartContent - JsonSchema: Media: string-encoding non-JSON data
- RFC7578: Returning Values from Forms: multipart/form-data
Proposal
For OpenAPI 3.1.x
-
Basic rules to convert Json Schema to multipart/form-data-
Add unit test(s) to check default mapping -
Using primitives values -
Using complex values -
Parameter using type: stringandcontentEncoding
-
-
Allow OpenAPI 3.1 reader to map each property to a content part using the following defaults: -
If the property is a type: stringwith acontentEncoding, the defaultContent-Typeisapplication/octet-stream -
If the property is a primitive, or an array of primitive values, the default Content-Typeistext/plain -
If the property is complex, or an array of complex values, the default Content-Typeisapplication/json
-
-
-
Use JSON Schema specification properties contentMediaType, andcontentEncodingto provide more serialization details-
Add unit test(s) -
Supported contentMediaType -
Unsupported contentMediaType -
Supported contentEncoding -
Unsupported contentEncoding
-
-
Allow OpenAPI 3.1 reader to check contentMediaType, andcontentEncodingto produce request content. NOTE 2
-
-
Use Encoding property to provide more details about Content Part serialization -
Add unit test(t) checking the use of each Encoding Propertyused bymultipart/form-data. -
Modify OpenAPI reader to take into account properties from Encoding Object: -
contentTypeNSwag do not expose contentType (maybe a bug in NSwag) -
headersNOTE 1 -
styleNOTE 1 -
explodeNOTE 1 -
allowReservedNOTE 1
-
-
NOTES:
- See description in OpenAPI 3.1: Encoding Object
- As per OpenAPI 3.1 documentation:
Per the JSON Schema specification,
contentMediaTypewithoutcontentEncodingpresent is treated as ifcontentEncoding: identitywere present. While useful for embedding text documents such astext/htmlinto JSON strings, it is not useful for amultipart/form-datapart, as it just causes the document to be treated astext/plaininstead of its actual media type. Use the Encoding Object withoutcontentMediaTypeif no contentEncoding is required