fix template for RequestBody, added 'required' attribute (#3134) (#4756)

* fix template for RequestBody, added 'required' attribute (#3134)

* update Spring samples (#3134)
This commit is contained in:
Andrii Hrytsiuk
2019-12-16 11:34:59 +02:00
committed by William Cheng
parent 7bd378c026
commit a9cc96b50f
17 changed files with 104 additions and 57 deletions

View File

@@ -66,7 +66,7 @@ public interface FakeApi {
@RequestMapping(value = "/fake/outer/boolean",
produces = { "*/*" },
method = RequestMethod.POST)
ResponseEntity<Boolean> fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody Boolean body);
ResponseEntity<Boolean> fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody(required = false) Boolean body);
/**
@@ -82,7 +82,7 @@ public interface FakeApi {
@RequestMapping(value = "/fake/outer/composite",
produces = { "*/*" },
method = RequestMethod.POST)
ResponseEntity<OuterComposite> fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody OuterComposite body);
ResponseEntity<OuterComposite> fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody(required = false) OuterComposite body);
/**
@@ -98,7 +98,7 @@ public interface FakeApi {
@RequestMapping(value = "/fake/outer/number",
produces = { "*/*" },
method = RequestMethod.POST)
ResponseEntity<BigDecimal> fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody BigDecimal body);
ResponseEntity<BigDecimal> fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody(required = false) BigDecimal body);
/**
@@ -114,7 +114,7 @@ public interface FakeApi {
@RequestMapping(value = "/fake/outer/string",
produces = { "*/*" },
method = RequestMethod.POST)
ResponseEntity<String> fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody String body);
ResponseEntity<String> fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody(required = false) String body);
/**

View File

@@ -62,7 +62,7 @@ public class FakeApiController implements FakeApi {
* @return Output boolean (status code 200)
* @see FakeApi#fakeOuterBooleanSerialize
*/
public ResponseEntity<Boolean> fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody Boolean body) {
public ResponseEntity<Boolean> fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody(required = false) Boolean body) {
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
}
@@ -75,7 +75,7 @@ public class FakeApiController implements FakeApi {
* @return Output composite (status code 200)
* @see FakeApi#fakeOuterCompositeSerialize
*/
public ResponseEntity<OuterComposite> fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody OuterComposite body) {
public ResponseEntity<OuterComposite> fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody(required = false) OuterComposite body) {
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
if (mediaType.isCompatibleWith(MediaType.valueOf("*/*"))) {
String exampleString = "{ \"my_string\" : \"my_string\", \"my_number\" : 0.8008281904610115, \"my_boolean\" : true }";
@@ -95,7 +95,7 @@ public class FakeApiController implements FakeApi {
* @return Output number (status code 200)
* @see FakeApi#fakeOuterNumberSerialize
*/
public ResponseEntity<BigDecimal> fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody BigDecimal body) {
public ResponseEntity<BigDecimal> fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody(required = false) BigDecimal body) {
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
}
@@ -108,7 +108,7 @@ public class FakeApiController implements FakeApi {
* @return Output string (status code 200)
* @see FakeApi#fakeOuterStringSerialize
*/
public ResponseEntity<String> fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody String body) {
public ResponseEntity<String> fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody(required = false) String body) {
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
}