multipart/form-data request validation not supported
Swagger specification mentions two form parameter types: application/x-www-form-urlencoded
and multipart/form-data
, but Swagger Request Validator only accepts a request with body when the consumes
field is application/x-www-form-urlencoded
.
An example of a request that doesn't pass the validation can be found in the pet store specification from Swagger for the POST /pet/{petId}/uploadImage
:
"/pet/{petId}/uploadImage": {
"post": {
"tags": [
"pet"
],
"summary": "uploads an image",
"description": "",
"operationId": "uploadFile",
"consumes": [
"multipart/form-data"
],
"produces": [
"application/json"
],
"parameters": [{
"name": "petId",
"in": "path",
"description": "ID of pet to update",
"required": true,
"type": "integer",
"format": "int64"
},
{
"name": "additionalMetadata",
"in": "formData",
"description": "Additional data to pass to server",
"required": false,
"type": "string"
},
{
"name": "file",
"in": "formData",
"description": "file to upload",
"required": false,
"type": "file"
}
],
"responses": {
"200": {
"description": "successful operation",
"schema": {
"$ref": "#/definitions/ApiResponse"
}
}
},
"security": [{
"petstore_auth": [
"write:pets",
"read:pets"
]
}]
}
}
Comments (6)
-
-
Account Deactivated We currently have the same issue but our multipart/formdata includes key/value pairs. Can someone pls look into it & provide the support for multipart/formdata as well.
-
Account Deactivated It's a shame that this library does not conform to the standard specification. Please add this feature ASAP.
-
Hi @jfnavin ,
Just today @alui and I were trying to validate PUT /rest/api/content/{contentId}/child/attachment in Confluence Cloud and discovered that it required validation on multipart/form-data.
What is required in this library to support multipart/form-data?
Is it just a matter of updating com.atlassian.oai.validator.interaction.RequestValidator#isFormData so that it supports an extra media type ('multipart/form-data')? Maybe we have to write a new alternative to com.atlassian.oai.validator.interaction.RequestValidator#validateForm as well?
Cheers, Robert
-
@robertmassaioli - @bgvozdev has an open PR with this work mostly done. Im just looking for time to perform a review.
-
- changed status to resolved
Available in v1.3.8
- Log in to comment
Hi Team,
I think this issue should be taken as critical as this fails to support validation on attachment related requests.
Regards Nakul Vashishth