JsonParseException while using multi line base64 encoded value with type string
Hello there,
While using a base64 encoded value which can have multiple lines, Swagger is throwing a JsonParseException as it is not escaping characters correctly and putting into a JSON to validate against the schema.
Comments (5)
-
-
reporter @Sven Doring
I understand that a json cannot have multi line values. But I am talking about a string value which is Base64 encoded which can be a multi line.
My requirement is simple, I want to have query parameter which is Base64 encoded value (Base64 encoded value can have newline characters). This is something swagger is not allowing.
Is there an alternative to this??
-
How is it defined in your OpenAPI definition? As type string with format base64?
-
reporter I was using the format as byte which takes care of base64 values as per the below link
byte
– base64-encoded characters, for example, U3dhZ2dlciByb2Nrcw==
-
There is an issue on GitHub for Jackson addressing multiline Base64 strings. https://github.com/FasterXML/jackson-core/issues/414
Some sort of fix was released with version 2.9.4.
Which version is used by the OpenAPI validator? I vaguely remember something about version 2.8.x.
Can you try it with a newer 2.9.x version?
Edit:
Since version 1.4.0 of the Swagger Request Validator it uses Jackson 2.9.5.
So, right now, the used JSON decoder does not support multiline Base64 strings.
- Log in to comment
JSON can't have multiline strings. Not even as Base64 encoded byte array. Therefore the JsonParseException is right - your JSON is invalid.
See http://json.org/ for more information on the String definition. A new line has to be escaped with
\n
.