Use of byte[] with spring-rest and springfox
<p>I am new to REST API design and I have two questions about the API I am trying to write.</p>

<p>I want to create a service that, giving a PDF file encoding, creates an object in the database.</p>

<p>My current service looks like this:</p>

<pre><code>@RequestMapping(value = "/create", method = RequestMethod.POST,
    produces = MediaType.APPLICATION_JSON_VALUE,
    consumes = MediaType.APPLICATION_OCTET_STREAM_VALUE)
public String create(@RequestBody byte[] pdf)
</code></pre>

<p>My questions are:</p>

<ol>
<li>Is it "recommended" to use the byte[] with REST APIs ?
PS: the service will be consumed by web clients as well as toolkits.</li>
<li>I tried to use springfox to document my API. the UI tool does not allow me to submit binary data.</li>
</ol>

<p>I used the following annotation</p>

<pre><code>    @ApiImplicitParams({
    @ApiImplicitParam(name = "pdf", value = "PDF encoding", required = true,
     allowMultiple = true,
     paramType = "body", dataType = "byte")
  })
</code></pre>

<p>The generated JSON is:</p>

<pre><code>{"type":"array","items":{"type":"string","format":"byte"}}
</code></pre>

<p>However the UI interface displays a textarea for the PDF encoding and submits any content as a string. (For example, if I submit the value "5", the server receives [53]).</p>

<p>Do you have any idea what I am missing at this level ?</p>

<p>-- EDIT --</p>

<p>The PDF is generated in the client side from an HTML form. So it is not a simple form submit.</p>