Thanks for your help with this.
I have tried to implement it the way you suggested (handling the multipart within the method itself)- it looks like this:
@PUT
@Path("/{messageId}/icons")
@ApiOperation(value="Update display icon")
@RolesAllowed({"messageEditor", "messageAdmin"})
@Consumes("multipart/form-data")
@Produces("application/json")
public RestMessage updateIcons(@ApiParam(value="Icon file upload", required=true) MultipartFormDataInput formInput, @PathParam("messageId") int messageId) throws Exception {
log.debug("in updateIcon(Multipart) for messageId " + messageId);
Map<String, List<InputPart>> uploadForm = formInput.getFormDataMap();
List<InputPart> inputParts = uploadForm.get("uploadFile");
String fileName = "";
byte[] bytes = new byte[0];
for (InputPart inputPart: inputParts) {
MultivaluedMap<String, String> header = inputPart.getHeaders();
fileName = getFileName(header);
InputStream inputStream = inputPart.getBody(InputStream.class, null);
bytes = IOUtils.toByteArray(inputStream);
}
return helper.updateIcons(messageId, bytes, fileName, user);
}
Unfortunately, this still doesn't produce the desired file upload input (it works for retrieving the data, but doesn't work for swagger). It would be really helpful for the @APIParam annotation to have something like a paramType option in order to override the default (body):
- {
- name: "body"
- description: "Icon file upload"
- required: true
- allowMultiple: false
- type: "FileUploadForm"
- paramType: "body"
}
As a work-around, I can get an additional file selector to show up if I use the following annotation:
@ApiImplicitParams(@ApiImplicitParam(name = "uploadFile", value="", dataType = "file", paramType = "file"))
From that, I can retrieve the uploadFile that is submitted through the Swagger UI just as I would like to, but the default body input field still shows up. At this point, we're just setting the description in the body field to "*** DO NOT USE THIS ***" so that the user isn't quite as confused, but we'd love to be able to hide that field- we've tried the access="internal" as referenced on
https://github.com/wordnik/swagger-core/issues/127, but it looks like the location of the source has changed, and that it hasn't been working for other users either.
Because we're using RESTEasy, swagger has been a little more difficult to implement fully- this is the last hurdle before we are able to say we've got it working the way we want it to, but we haven't been able to find a good solution to it.
-Max