Elizabeth/Joy - adding example support if specified in the swagger spec

This commit is contained in:
Thomas, Elizabeth-CW
2017-04-13 09:31:07 -05:00
parent 78c4928908
commit 02bcad36fd
3 changed files with 13 additions and 3 deletions

View File

@@ -17,6 +17,8 @@ import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException;
import java.util.List;
{{#async}}
@@ -39,9 +41,15 @@ public class {{classname}}Controller implements {{classname}} {
{{^jdk8-no-delegate}}{{#operation}}
public {{#async}}Callable<{{/async}}ResponseEntity<{{>returnTypes}}>{{#async}}>{{/async}} {{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}},
{{/hasMore}}{{/allParams}}) {
{{/hasMore}}{{/allParams}}) {{#examples}}throws IOException{{/examples}} {
// do some magic!{{^isDelegate}}{{^async}}
return new ResponseEntity<{{>returnTypes}}>(HttpStatus.OK);{{/async}}{{#async}}
{{#examples}}
ObjectMapper objectMapper = new ObjectMapper();
return new ResponseEntity<{{>returnTypes}}>(objectMapper.readValue({{{example}}},{{>exampleReturnTypes}}.class), HttpStatus.OK);
{{/examples}}
{{^examples}}
return new ResponseEntity<{{>returnTypes}}>(HttpStatus.OK);{{/examples}}{{/async}}{{#async}}
return new Callable<ResponseEntity<{{>returnTypes}}>>() {
@Override
public ResponseEntity<{{>returnTypes}}> call() throws Exception {