phoenixnap / springmvc-raml-plugin

Spring MVC - RAML Spec Synchroniser Plugin. A Maven plugin designed to Generate Server & Client code in Spring from a RAML API descriptor and conversely, a RAML API document from the SpringMVC Server implementation.
Apache License 2.0
136 stars 84 forks source link

Download/upload file through RAML endpoint #252

Open ivan-mladenovic opened 6 years ago

ivan-mladenovic commented 6 years ago

Please add possibility to download and upload file by using RAML endpoints definition.

stojsavljevic commented 6 years ago

When it comes to download, there is a way to do it. Define a raml part like this:

get:
  responses: 
    200:
      body: 
        application/octet-stream: 
          type: file

and you will get decorator generated like this:

@RequestMapping(value = "", method = RequestMethod.GET)
public ResponseEntity<?> getObject() {
    return this.returnControllerDelegate.getObject();
}

So you got return type: ResponseEntity<?> and you can return a byte[] from your implementation.

This is more like a workaround and it's not ideal since generated code should enforce you to return a file (or byte[]).