我不知道如何将Java对象作为FormDataParam传递给Jersey restfull服务。该服务与curl完美配合,但Swagger响应错误。问题很可能是注释@FormDataParam。 Swagger不会抛出415错误不支持的媒体文件,但它
以下是泽西服务代码:
@POST
@ApiOperation(value = "Upload", notes = "", response = ImageAPIResponse.class)
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, "application/x-javascript" })
@Consumes(MediaType.MULTIPART_FORM_DATA)
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Successful or application error (see notes)", response = ImageAPIResponse.class) })
public ImageAPIUploadUpdateResponse upload(
@ApiParam(required = true, value = "user name part of credentials") @FormDataParam("user_name") String userName, //
@ApiParam(required = true, value = "") @FormDataParam("file") File file, //
@ApiParam(required = true, value = "") @FormDataParam("file") FormDataContentDisposition contentDispositionHeader,
@ApiParam(required = false, value = "") @FormDataParam("file_name") String fileName,
@ApiParam(required = false, value = "") @FormDataParam("meta_data") ImageMetaData metaData) {
ImageAPIResponse imageAPIResponse = new ImageAPIResponse();
//metaData object keeps being null...
return imageAPIResponse;
}
public class ImageMetaData{
public String fileName;
public String fileType;
}
有没有人遇到过与FormDataParam类似的问题?如果我可以在我的参数中使用这个泽西注释,那就太好了。