- changed status to resolved
SwaggerRequestResponseValidator fails with XML body
Issue #65
resolved
Using SwaggerRequestResponseValidator to validate requests against Swagger specs, validation fails when when request body is an XML.
For example using the pet store specification, and invoking the POST /pet
operation, which consumes both application/json
and application/xml
/pet: {
post: {
...
consumes: [
"application/json",
"application/xml"
],
...
parameters: [
{
in: "body",
name: "body",
description: "Pet object that needs to be added to the store",
required: true,
schema: {
$ref: "#/definitions/Pet"
}
...
}
I get the following error when request body is an XML:
Unable to parse JSON - Unexpected character ('<' (code 60)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')
at [Source: <Pet><name>doggie</name><photoUrls>http://localhost:8080/doggie.jpg</photoUrls></Pet>; line: 1, column: 2].: []
On the other side, if request body is a JSON, request is correctly validated, as you can see in attached test class.
Comments (2)
-
-
Version 1.4.2 fixes the validation error, but doesn't validate the XML body. I have raised
#111to track adding support for XML validation. - Log in to comment
Available in v1.4.2