diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/bodyParams.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/bodyParams.mustache index 16ac260f9d9..c2a1faa8c9f 100644 --- a/modules/openapi-generator/src/main/resources/JavaSpring/bodyParams.mustache +++ b/modules/openapi-generator/src/main/resources/JavaSpring/bodyParams.mustache @@ -1 +1 @@ -{{#isBodyParam}}@ApiParam(value = "{{{description}}}" {{#required}},required=true{{/required}} {{^isContainer}}{{#allowableValues}}, allowableValues="{{{allowableValues}}}"{{/allowableValues}}{{#defaultValue}}, defaultValue={{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{{defaultValue}}}{{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{/defaultValue}}{{/isContainer}}) {{#useBeanValidation}}@Valid{{/useBeanValidation}} @RequestBody {{^reactive}}{{{dataType}}}{{/reactive}}{{#reactive}}{{^isListContainer}}Mono{{/isListContainer}}{{#isListContainer}}Flux{{/isListContainer}}<{{{baseType}}}>{{/reactive}} {{paramName}}{{/isBodyParam}} \ No newline at end of file +{{#isBodyParam}}@ApiParam(value = "{{{description}}}" {{#required}},required=true{{/required}} {{^isContainer}}{{#allowableValues}}, allowableValues="{{{allowableValues}}}"{{/allowableValues}}{{#defaultValue}}, defaultValue={{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{{defaultValue}}}{{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{/defaultValue}}{{/isContainer}}) {{#useBeanValidation}}@Valid{{/useBeanValidation}} @RequestBody{{^required}}(required = false){{/required}} {{^reactive}}{{{dataType}}}{{/reactive}}{{#reactive}}{{^isListContainer}}Mono{{/isListContainer}}{{#isListContainer}}Flux{{/isListContainer}}<{{{baseType}}}>{{/reactive}} {{paramName}}{{/isBodyParam}} \ No newline at end of file diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/spring/SpringCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/spring/SpringCodegenTest.java index 1febdfe86ee..dda7c67d3eb 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/spring/SpringCodegenTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/spring/SpringCodegenTest.java @@ -416,4 +416,28 @@ public class SpringCodegenTest { codegen.additionalProperties().put(CodegenConstants.LIBRARY, "spring-cloud"); codegen.processOpts(); } + + @Test + public void testDoGenerateRequestBodyRequiredAttribute_3134_Regression() throws Exception { + File output = Files.createTempDirectory("test").toFile().getCanonicalFile(); + output.deleteOnExit(); + String outputPath = output.getAbsolutePath().replace('\\', '/'); + + OpenAPI openAPI = new OpenAPIParser() + .readLocation("src/test/resources/3_0/3134-regression.yaml", null, new ParseOptions()).getOpenAPI(); + + SpringCodegen codegen = new SpringCodegen(); + codegen.setOutputDir(output.getAbsolutePath()); + codegen.additionalProperties().put(CXFServerFeatures.LOAD_TEST_DATA_FROM_FILE, "true"); + + ClientOptInput input = new ClientOptInput(); + input.setOpenAPI(openAPI); + input.setConfig(codegen); + + MockDefaultGenerator generator = new MockDefaultGenerator(); + generator.opts(input).generate(); + + checkFileContains(generator, outputPath + "/src/main/java/org/openapitools/api/ExampleApi.java", + "@RequestBody(required = false"); + } } diff --git a/modules/openapi-generator/src/test/resources/3_0/3134-regression.yaml b/modules/openapi-generator/src/test/resources/3_0/3134-regression.yaml new file mode 100644 index 00000000000..a9fc8fb4532 --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/3134-regression.yaml @@ -0,0 +1,23 @@ +openapi: 3.0.2 +info: + title: info + description: info + version: 0.1.0 + +paths: + /example/api: + post: + summary: summary + description: description + requestBody: + required: false + content: + application/json: + schema: + type: object + properties: + name: + type: string + responses: + 200: + description: response \ No newline at end of file diff --git a/samples/server/petstore/spring-mvc-j8-async/src/main/java/org/openapitools/api/FakeApi.java b/samples/server/petstore/spring-mvc-j8-async/src/main/java/org/openapitools/api/FakeApi.java index d3af74a0a22..fde21a6ef04 100644 --- a/samples/server/petstore/spring-mvc-j8-async/src/main/java/org/openapitools/api/FakeApi.java +++ b/samples/server/petstore/spring-mvc-j8-async/src/main/java/org/openapitools/api/FakeApi.java @@ -78,7 +78,7 @@ public interface FakeApi { @RequestMapping(value = "/fake/outer/boolean", produces = { "*/*" }, method = RequestMethod.POST) - default CompletableFuture> fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody Boolean body) { + default CompletableFuture> fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody(required = false) Boolean body) { return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)); } @@ -97,7 +97,7 @@ public interface FakeApi { @RequestMapping(value = "/fake/outer/composite", produces = { "*/*" }, method = RequestMethod.POST) - default CompletableFuture> fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody OuterComposite body) { + default CompletableFuture> fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody(required = false) OuterComposite body) { return CompletableFuture.supplyAsync(()-> { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { @@ -127,7 +127,7 @@ public interface FakeApi { @RequestMapping(value = "/fake/outer/number", produces = { "*/*" }, method = RequestMethod.POST) - default CompletableFuture> fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody BigDecimal body) { + default CompletableFuture> fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody(required = false) BigDecimal body) { return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)); } @@ -146,7 +146,7 @@ public interface FakeApi { @RequestMapping(value = "/fake/outer/string", produces = { "*/*" }, method = RequestMethod.POST) - default CompletableFuture> fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody String body) { + default CompletableFuture> fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody(required = false) String body) { return CompletableFuture.completedFuture(new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED)); } diff --git a/samples/server/petstore/spring-mvc-j8-localdatetime/src/main/java/org/openapitools/api/FakeApi.java b/samples/server/petstore/spring-mvc-j8-localdatetime/src/main/java/org/openapitools/api/FakeApi.java index 8f25bcb0ede..fcac0605ab6 100644 --- a/samples/server/petstore/spring-mvc-j8-localdatetime/src/main/java/org/openapitools/api/FakeApi.java +++ b/samples/server/petstore/spring-mvc-j8-localdatetime/src/main/java/org/openapitools/api/FakeApi.java @@ -77,7 +77,7 @@ public interface FakeApi { @RequestMapping(value = "/fake/outer/boolean", produces = { "*/*" }, method = RequestMethod.POST) - default ResponseEntity fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody Boolean body) { + default ResponseEntity fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody(required = false) Boolean body) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -96,7 +96,7 @@ public interface FakeApi { @RequestMapping(value = "/fake/outer/composite", produces = { "*/*" }, method = RequestMethod.POST) - default ResponseEntity fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody OuterComposite body) { + default ResponseEntity fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody(required = false) OuterComposite body) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("*/*"))) { @@ -124,7 +124,7 @@ public interface FakeApi { @RequestMapping(value = "/fake/outer/number", produces = { "*/*" }, method = RequestMethod.POST) - default ResponseEntity fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody BigDecimal body) { + default ResponseEntity fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody(required = false) BigDecimal body) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -143,7 +143,7 @@ public interface FakeApi { @RequestMapping(value = "/fake/outer/string", produces = { "*/*" }, method = RequestMethod.POST) - default ResponseEntity fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody String body) { + default ResponseEntity fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody(required = false) String body) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } diff --git a/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/FakeApi.java b/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/FakeApi.java index b8788d88f31..8734c49ea19 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/FakeApi.java +++ b/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/FakeApi.java @@ -66,7 +66,7 @@ public interface FakeApi { @RequestMapping(value = "/fake/outer/boolean", produces = { "*/*" }, method = RequestMethod.POST) - ResponseEntity fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody Boolean body); + ResponseEntity 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 fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody OuterComposite body); + ResponseEntity 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 fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody BigDecimal body); + ResponseEntity 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 fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody String body); + ResponseEntity fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody(required = false) String body); /** diff --git a/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/FakeApiController.java b/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/FakeApiController.java index aac6a3e3b1d..7b194d00458 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/FakeApiController.java +++ b/samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/FakeApiController.java @@ -62,7 +62,7 @@ public class FakeApiController implements FakeApi { * @return Output boolean (status code 200) * @see FakeApi#fakeOuterBooleanSerialize */ - public ResponseEntity fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody Boolean body) { + public ResponseEntity 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 fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody OuterComposite body) { + public ResponseEntity 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 fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody BigDecimal body) { + public ResponseEntity 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 fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody String body) { + public ResponseEntity fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody(required = false) String body) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/api/FakeApi.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/api/FakeApi.java index b8788d88f31..8734c49ea19 100644 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/api/FakeApi.java +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/api/FakeApi.java @@ -66,7 +66,7 @@ public interface FakeApi { @RequestMapping(value = "/fake/outer/boolean", produces = { "*/*" }, method = RequestMethod.POST) - ResponseEntity fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody Boolean body); + ResponseEntity 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 fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody OuterComposite body); + ResponseEntity 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 fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody BigDecimal body); + ResponseEntity 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 fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody String body); + ResponseEntity fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody(required = false) String body); /** diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/api/FakeApiController.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/api/FakeApiController.java index 828761ab32e..05c54707b03 100644 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/api/FakeApiController.java +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/api/FakeApiController.java @@ -62,7 +62,7 @@ public class FakeApiController implements FakeApi { * @return Output boolean (status code 200) * @see FakeApi#fakeOuterBooleanSerialize */ - public ResponseEntity fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody Boolean body) { + public ResponseEntity 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 fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody OuterComposite body) { + public ResponseEntity 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 fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody BigDecimal body) { + public ResponseEntity 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 fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody String body) { + public ResponseEntity fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody(required = false) String body) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } diff --git a/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/FakeApi.java b/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/FakeApi.java index 8042e0c8cbc..e90acd63c13 100644 --- a/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/FakeApi.java +++ b/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/FakeApi.java @@ -72,7 +72,7 @@ public interface FakeApi { @RequestMapping(value = "/fake/outer/boolean", produces = { "*/*" }, method = RequestMethod.POST) - default ResponseEntity fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody Boolean body) { + default ResponseEntity fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody(required = false) Boolean body) { return getDelegate().fakeOuterBooleanSerialize(body); } @@ -90,7 +90,7 @@ public interface FakeApi { @RequestMapping(value = "/fake/outer/composite", produces = { "*/*" }, method = RequestMethod.POST) - default ResponseEntity fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody OuterComposite body) { + default ResponseEntity fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody(required = false) OuterComposite body) { return getDelegate().fakeOuterCompositeSerialize(body); } @@ -108,7 +108,7 @@ public interface FakeApi { @RequestMapping(value = "/fake/outer/number", produces = { "*/*" }, method = RequestMethod.POST) - default ResponseEntity fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody BigDecimal body) { + default ResponseEntity fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody(required = false) BigDecimal body) { return getDelegate().fakeOuterNumberSerialize(body); } @@ -126,7 +126,7 @@ public interface FakeApi { @RequestMapping(value = "/fake/outer/string", produces = { "*/*" }, method = RequestMethod.POST) - default ResponseEntity fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody String body) { + default ResponseEntity fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody(required = false) String body) { return getDelegate().fakeOuterStringSerialize(body); } diff --git a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeApi.java b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeApi.java index b8788d88f31..8734c49ea19 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeApi.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeApi.java @@ -66,7 +66,7 @@ public interface FakeApi { @RequestMapping(value = "/fake/outer/boolean", produces = { "*/*" }, method = RequestMethod.POST) - ResponseEntity fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody Boolean body); + ResponseEntity 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 fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody OuterComposite body); + ResponseEntity 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 fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody BigDecimal body); + ResponseEntity 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 fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody String body); + ResponseEntity fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody(required = false) String body); /** diff --git a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeApiController.java b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeApiController.java index 705a9150f76..af0a6322c08 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeApiController.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeApiController.java @@ -59,7 +59,7 @@ public class FakeApiController implements FakeApi { * @return Output boolean (status code 200) * @see FakeApi#fakeOuterBooleanSerialize */ - public ResponseEntity fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody Boolean body) { + public ResponseEntity fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody(required = false) Boolean body) { return delegate.fakeOuterBooleanSerialize(body); } @@ -71,7 +71,7 @@ public class FakeApiController implements FakeApi { * @return Output composite (status code 200) * @see FakeApi#fakeOuterCompositeSerialize */ - public ResponseEntity fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody OuterComposite body) { + public ResponseEntity fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody(required = false) OuterComposite body) { return delegate.fakeOuterCompositeSerialize(body); } @@ -83,7 +83,7 @@ public class FakeApiController implements FakeApi { * @return Output number (status code 200) * @see FakeApi#fakeOuterNumberSerialize */ - public ResponseEntity fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody BigDecimal body) { + public ResponseEntity fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody(required = false) BigDecimal body) { return delegate.fakeOuterNumberSerialize(body); } @@ -95,7 +95,7 @@ public class FakeApiController implements FakeApi { * @return Output string (status code 200) * @see FakeApi#fakeOuterStringSerialize */ - public ResponseEntity fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody String body) { + public ResponseEntity fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody(required = false) String body) { return delegate.fakeOuterStringSerialize(body); } diff --git a/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/FakeApi.java b/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/FakeApi.java index 4d5a2b3f452..2e0ea64e1e9 100644 --- a/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/FakeApi.java +++ b/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/FakeApi.java @@ -81,7 +81,7 @@ public interface FakeApi { @RequestMapping(value = "/fake/outer/boolean", produces = { "*/*" }, method = RequestMethod.POST) - default ResponseEntity fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody Boolean body) { + default ResponseEntity fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody(required = false) Boolean body) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -102,7 +102,7 @@ public interface FakeApi { @RequestMapping(value = "/fake/outer/composite", produces = { "*/*" }, method = RequestMethod.POST) - default ResponseEntity fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody OuterComposite body) { + default ResponseEntity fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody(required = false) OuterComposite body) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("*/*"))) { @@ -132,7 +132,7 @@ public interface FakeApi { @RequestMapping(value = "/fake/outer/number", produces = { "*/*" }, method = RequestMethod.POST) - default ResponseEntity fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody BigDecimal body) { + default ResponseEntity fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody(required = false) BigDecimal body) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -153,7 +153,7 @@ public interface FakeApi { @RequestMapping(value = "/fake/outer/string", produces = { "*/*" }, method = RequestMethod.POST) - default ResponseEntity fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody String body) { + default ResponseEntity fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody(required = false) String body) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } diff --git a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeApi.java b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeApi.java index 849ea14cf07..029913c4504 100644 --- a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeApi.java +++ b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeApi.java @@ -75,7 +75,7 @@ public interface FakeApi { @RequestMapping(value = "/fake/outer/boolean", produces = { "*/*" }, method = RequestMethod.POST) - default Mono> fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody Mono body, ServerWebExchange exchange) { + default Mono> fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody(required = false) Mono body, ServerWebExchange exchange) { return getDelegate().fakeOuterBooleanSerialize(body, exchange); } @@ -93,7 +93,7 @@ public interface FakeApi { @RequestMapping(value = "/fake/outer/composite", produces = { "*/*" }, method = RequestMethod.POST) - default Mono> fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody Mono body, ServerWebExchange exchange) { + default Mono> fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody(required = false) Mono body, ServerWebExchange exchange) { return getDelegate().fakeOuterCompositeSerialize(body, exchange); } @@ -111,7 +111,7 @@ public interface FakeApi { @RequestMapping(value = "/fake/outer/number", produces = { "*/*" }, method = RequestMethod.POST) - default Mono> fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody Mono body, ServerWebExchange exchange) { + default Mono> fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody(required = false) Mono body, ServerWebExchange exchange) { return getDelegate().fakeOuterNumberSerialize(body, exchange); } @@ -129,7 +129,7 @@ public interface FakeApi { @RequestMapping(value = "/fake/outer/string", produces = { "*/*" }, method = RequestMethod.POST) - default Mono> fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody Mono body, ServerWebExchange exchange) { + default Mono> fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody(required = false) Mono body, ServerWebExchange exchange) { return getDelegate().fakeOuterStringSerialize(body, exchange); } diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/FakeApi.java b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/FakeApi.java index c461ca3c95e..0be38f0541a 100644 --- a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/FakeApi.java +++ b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/FakeApi.java @@ -77,7 +77,7 @@ public interface FakeApi { @RequestMapping(value = "/fake/outer/boolean", produces = { "*/*" }, method = RequestMethod.POST) - default ResponseEntity fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody Boolean body) { + default ResponseEntity fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody(required = false) Boolean body) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -96,7 +96,7 @@ public interface FakeApi { @RequestMapping(value = "/fake/outer/composite", produces = { "*/*" }, method = RequestMethod.POST) - default ResponseEntity fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody OuterComposite body) { + default ResponseEntity fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody(required = false) OuterComposite body) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("*/*"))) { @@ -124,7 +124,7 @@ public interface FakeApi { @RequestMapping(value = "/fake/outer/number", produces = { "*/*" }, method = RequestMethod.POST) - default ResponseEntity fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody BigDecimal body) { + default ResponseEntity fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody(required = false) BigDecimal body) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -143,7 +143,7 @@ public interface FakeApi { @RequestMapping(value = "/fake/outer/string", produces = { "*/*" }, method = RequestMethod.POST) - default ResponseEntity fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody String body) { + default ResponseEntity fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody(required = false) String body) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } diff --git a/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/api/FakeApi.java b/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/api/FakeApi.java index 72de95191f9..036f0530d41 100644 --- a/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/api/FakeApi.java +++ b/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/api/FakeApi.java @@ -82,7 +82,7 @@ public interface FakeApi { @RequestMapping(value = "/fake/outer/boolean", produces = { "*/*" }, method = RequestMethod.POST) - default ResponseEntity fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody Boolean body) { + default ResponseEntity fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody(required = false) Boolean body) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -102,7 +102,7 @@ public interface FakeApi { @RequestMapping(value = "/fake/outer/composite", produces = { "*/*" }, method = RequestMethod.POST) - default ResponseEntity fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody OuterComposite body) { + default ResponseEntity fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody(required = false) OuterComposite body) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("*/*"))) { @@ -131,7 +131,7 @@ public interface FakeApi { @RequestMapping(value = "/fake/outer/number", produces = { "*/*" }, method = RequestMethod.POST) - default ResponseEntity fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody BigDecimal body) { + default ResponseEntity fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody(required = false) BigDecimal body) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -151,7 +151,7 @@ public interface FakeApi { @RequestMapping(value = "/fake/outer/string", produces = { "*/*" }, method = RequestMethod.POST) - default ResponseEntity fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody String body) { + default ResponseEntity fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody(required = false) String body) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } diff --git a/samples/server/petstore/springboot/src/main/java/org/openapitools/api/FakeApi.java b/samples/server/petstore/springboot/src/main/java/org/openapitools/api/FakeApi.java index f1eb1304433..073b8698935 100644 --- a/samples/server/petstore/springboot/src/main/java/org/openapitools/api/FakeApi.java +++ b/samples/server/petstore/springboot/src/main/java/org/openapitools/api/FakeApi.java @@ -77,7 +77,7 @@ public interface FakeApi { @RequestMapping(value = "/fake/outer/boolean", produces = { "*/*" }, method = RequestMethod.POST) - default ResponseEntity fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody Boolean body) { + default ResponseEntity fakeOuterBooleanSerialize(@ApiParam(value = "Input boolean as post body" ) @Valid @RequestBody(required = false) Boolean body) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -96,7 +96,7 @@ public interface FakeApi { @RequestMapping(value = "/fake/outer/composite", produces = { "*/*" }, method = RequestMethod.POST) - default ResponseEntity fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody OuterComposite body) { + default ResponseEntity fakeOuterCompositeSerialize(@ApiParam(value = "Input composite as post body" ) @Valid @RequestBody(required = false) OuterComposite body) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("*/*"))) { @@ -124,7 +124,7 @@ public interface FakeApi { @RequestMapping(value = "/fake/outer/number", produces = { "*/*" }, method = RequestMethod.POST) - default ResponseEntity fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody BigDecimal body) { + default ResponseEntity fakeOuterNumberSerialize(@ApiParam(value = "Input number as post body" ) @Valid @RequestBody(required = false) BigDecimal body) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -143,7 +143,7 @@ public interface FakeApi { @RequestMapping(value = "/fake/outer/string", produces = { "*/*" }, method = RequestMethod.POST) - default ResponseEntity fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody String body) { + default ResponseEntity fakeOuterStringSerialize(@ApiParam(value = "Input string as post body" ) @Valid @RequestBody(required = false) String body) { return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); }