mulesoft-labs / raml-for-jax-rs

This project is all about two way transformation of JAX-RS-annotated Java code to RAML API description and back.
Other
296 stars 181 forks source link

Always use InputStream and StreamingOuput for type "any" #421

Open Kaiser1989 opened 4 years ago

Kaiser1989 commented 4 years ago

When using type any, the generator creates an "Object" on java side. This makes no sense, as an object cannot be treated correctly. Is it a byte stream? Is it a string? Most converters will fail even before the function is being called. It's clearer if the parameter is an InputStream. Even if the object is a valid json, the stream can be read to a string and converted correctly.

The same yields for the response, where a StreamingOutput object should be used, so any byte data can be streamed to the client. If Object is returned, most convertes will fail and nothing will be send to the client.

Currently the InputStream variant is only implemented if used with "application/octet-stream". But in my opinion it should be used whenever type "any" occurs.

I added a pull request with a small fix.