Forum Discussion

tomasz__1's avatar
tomasz__1
Occasional Visitor
4 years ago

[java / feign / jackson] swagger codegen and application/octet-stream issue

I'm using 3.0 spec and swagger-codegen-cli-3.0.26.jar for generating the client API.

The schema has operation with response application/octet-stream and format binary - part of schema below.

The generated API (java, feign, jackson) has File as return type.

  @RequestLine("GET /nodes/{nodeId}/content")
  @Headers({
      "Accept: application/octet-stream,application/octet-stream"
  })
  File getNodeContent(@Param("nodeId") String nodeId);

I wonder why it is File, not byte[], or InputStream?

What is astonishing, the http response content is stored in the File.path member (and broken), basically it doesn't work.

Is File type for octet-stream according to spec (I cannot find this information)? And how it should be done correctly?

(changing File by hand to byte[] doens't help as feign/jackson is expecting in this case base64 coded response, but the service returns raw content and the call fails with jackson parsing error.

 

  /nodes/{nodeId}/content:
    get:
      operationId: getNodeContent
      parameters:
...
      responses:
        "200":
          content:
            application/octet-stream:
              schema:
                format: binary
                type: string

 

No RepliesBe the first to reply