Closed vaIgarashi closed 6 years ago
Also with current aproach it's not possible to obtain original file name.
To fix it should be at least like that:
File background = new File(message.body().getString("background"));
instead of:
File background = Json.mapper.readValue(message.body().getJsonObject("background").encode(), File.class);
Small patch to fix this:
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- modules/vertx-swagger-codegen/src/main/resources/javaVertXServer/apiVerticle.mustache (revision 354448ba45b13c7c1ffc3d8bd8c99e5edd00982e)
+++ modules/vertx-swagger-codegen/src/main/resources/javaVertXServer/apiVerticle.mustache (date 1513845883000)
@@ -73,7 +73,12 @@
{{/isString}}
{{/isPrimitiveType}}
{{^isPrimitiveType}}
+ {{#isFile}}
+ {{{dataType}}} {{paramName}} = new {{{dataType}}}(message.body().getString("{{baseName}}"));
+ {{/isFile}}
+ {{^isFile}}
{{{dataType}}} {{paramName}} = Json.mapper.readValue(message.body().getJsonObject("{{baseName}}").encode(), {{{dataType}}}.class);
+ {{/isFile}}
{{/isPrimitiveType}}
{{/isListContainer}}
{{/allParams}}```
Hi. I have been very busy these past two months. But now, I have time again for the project :) I will take a look soon.
I downloaded the current v1.6 from maven central and although it seems to contain this fix, code generation still spits out the wrong line for the petstore.json:
File file = Json.mapper.readValue(message.body().getJsonObject("file").encode(), File.class);
My sample code is in a github repo: https://github.com/cburnicki/vertx-file-upload-test I have no idea why this is still happening.
It's not possible to read image from
multipart/form-data
.Swagger:
Request:
Exception:
java.lang.ClassCastException: java.lang.String cannot be cast to io.vertx.core.json.JsonObject
It's try parse
file-uploads/c54807b6-ffa2-44da-be50-6424ab179cad
string as File.