Open gustavoapaz opened 6 years ago
Your swagger response is of type
type: "string"
format: "binary"
which doesn't indicate a file but a binary string response.
For a file response, you must use type: "file"
@cbornet thank you very much.
I am using Restlet Studio to define my APIs.
When I use the File type in Restlet
I get the YAML definition that I posted.
So I guess it is an issue in Restlet.
So I guess it is an issue in Restlet.
Indeed :smile:
Issue reported to Restlet.
@cbornet when I use the swagger response of type file
type: "file"
the cxf server stub is generated like this:
public File v1FilesGet(String file) {
But, this way I can not use a file that does not exist on disk.
I guess javax.ws.rs.core.Response
return type would be more flexible here.
I checked and all other JAX-RS generators return Response
in their stub for any type of response. I think this should also be the case for CXF as it gives more control over the response (can add headers, etc...).
Description
This is a feature request. I have the necessity to include the file name in the response as well as to change the content type of the response to match the one of the file. Currently, I am not able to generate a file download API that can stand on its own without the need of additional coding on the client side.
Swagger-codegen version
2.3.0
Swagger declaration file content or url
For example, to define a REST API that downloads a file you need to define something like the following in the YAML:
This definition generates the following CXF Java server stub interface:
And the following CXF Java server stub implementation:
But, the return type byte[] does not allow to include the file name in the response and to change the content type of the response to match the one of the file.
Command line used for generation
..
Steps to reproduce
..
Related issues/PRs
..
Suggest a fix/enhancement
I propose that the CXF Java server stub implementation outputs a code similar to the following: