-
Notifications
You must be signed in to change notification settings - Fork 527
Description
Is there an existing issue that is already proposing this?
- I have searched the existing issues
Is your feature request related to a problem? Please describe it
Hello, I need to generate a form-data input where there are some properties which are arrays.
I found out that the ApiBody decorator does not allow to specify the encoding property defined by OAS 3.0 (search for "encoding:" since this page does not have anchors).
Sadly the Swagger UI client, when the encoding attribute is missing, encodes the array properties as csv strings.
i.e., instead of
formData.add('arrayProp', elem0)
formData.add('arrayProp', elem1)
...
formData.add('arrayProp', elemN)it does
formData.add('arrayProp', 'elem0,elem1,...,elemN')Some people added some wonderful nasty workaround like this for NestJS. But it would be great if this was supported by the library.
Describe the solution you'd like
Support the encoding attribute in ApiBody as optional parameter
@ApiBody({
encoding: {
arrayProp1: { explode: true, style: 'form' },
arrayProp2: { explode: true, style: 'form' }
...
},
schema: {
...
properties: {
arrayProp1: { type: 'array', items: {type: 'string'} },
arrayProp2: { type: 'array', items: {type: 'object', properties: {...}} }
}
},The encoding parameter should be optional.
Teachability, documentation, adoption, migration strategy
Should not be a breaking change, but just a new feature
What is the motivation / use case for changing the behavior?
Make the Swagger UI behave correctly when using it to test form data endpoints
Allow generated OpenAPI client to handle this parameter.