diff --git a/docs/generators/spring.md b/docs/generators/spring.md index e7d64807746b..648064fd8202 100644 --- a/docs/generators/spring.md +++ b/docs/generators/spring.md @@ -170,6 +170,9 @@ CONFIG OPTIONS for spring hateoas Use Spring HATEOAS library to allow adding HATEOAS links (Default: false) + returnSuccessCode + Generated server returns 2xx code (Default: false) + library library template (sub-template) to use (Default: spring-boot) spring-boot - Spring-boot Server application using the SpringFox integration. diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java index 2ce583570687..2462a1418f6d 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java @@ -2365,7 +2365,13 @@ public class DefaultCodegen implements CodegenConfig { } // generate examples - op.examples = new ExampleGenerator(schemas, openAPI).generateFromResponseSchema(responseSchema, getProducesInfo(openAPI, operation)); + String exampleStatusCode = "200"; + for (String key : operation.getResponses().keySet()) { + if (operation.getResponses().get(key) == methodResponse && !key.equals("default")) { + exampleStatusCode = key; + } + } + op.examples = new ExampleGenerator(schemas, openAPI).generateFromResponseSchema(exampleStatusCode, responseSchema, getProducesInfo(openAPI, operation)); op.defaultResponse = toDefaultValue(responseSchema); op.returnType = cm.dataType; op.hasReference = schemas != null && schemas.containsKey(op.returnBaseType); diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/examples/ExampleGenerator.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/examples/ExampleGenerator.java index 47552634f4f3..2e0119184919 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/examples/ExampleGenerator.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/examples/ExampleGenerator.java @@ -42,6 +42,7 @@ public class ExampleGenerator { private static final String NONE = "none"; private static final String URL = "url"; private static final String URI = "uri"; + private static final String STATUS_CODE = "statusCode"; protected Map examples; private OpenAPI openAPI; @@ -54,7 +55,20 @@ public class ExampleGenerator { this.random = new Random("ExampleGenerator".hashCode()); } - public List> generateFromResponseSchema(Schema responseSchema, Set producesInfo) { + public List> generateFromResponseSchema(String statusCode, Schema responseSchema, Set producesInfo) { + List> examples = generateFromResponseSchema(responseSchema, producesInfo); + if (examples == null) { + return null; + } + + for (Map example : examples) { + example.put(STATUS_CODE, statusCode); + } + + return examples; + } + + private List> generateFromResponseSchema(Schema responseSchema, Set producesInfo) { if (responseSchema.getExample() == null && StringUtils.isEmpty(responseSchema.get$ref()) && !ModelUtils.isArraySchema(responseSchema)) { // no example provided return null; diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/SpringCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/SpringCodegen.java index 719c4a47042a..9865d665c2d0 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/SpringCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/SpringCodegen.java @@ -77,6 +77,7 @@ public class SpringCodegen extends AbstractJavaCodegen public static final String OPENAPI_DOCKET_CONFIG = "swaggerDocketConfig"; public static final String API_FIRST = "apiFirst"; public static final String HATEOAS = "hateoas"; + public static final String RETURN_SUCCESS_CODE = "returnSuccessCode"; protected String title = "OpenAPI Spring"; protected String configPackage = "org.openapitools.configuration"; @@ -98,6 +99,7 @@ public class SpringCodegen extends AbstractJavaCodegen protected boolean useOptional = false; protected boolean virtualService = false; protected boolean hateoas = false; + protected boolean returnSuccessCode = false; public SpringCodegen() { super(); @@ -131,6 +133,7 @@ public class SpringCodegen extends AbstractJavaCodegen cliOptions.add(CliOption.newBoolean(API_FIRST, "Generate the API from the OAI spec at server compile time (API first approach)", apiFirst)); cliOptions.add(CliOption.newBoolean(USE_OPTIONAL,"Use Optional container for optional parameters", useOptional)); cliOptions.add(CliOption.newBoolean(HATEOAS, "Use Spring HATEOAS library to allow adding HATEOAS links", hateoas)); + cliOptions.add(CliOption.newBoolean(RETURN_SUCCESS_CODE, "Generated server returns 2xx code", returnSuccessCode)); supportedLibraries.put(SPRING_BOOT, "Spring-boot Server application using the SpringFox integration."); supportedLibraries.put(SPRING_MVC_LIBRARY, "Spring-MVC Server application using the SpringFox integration."); @@ -277,6 +280,10 @@ public class SpringCodegen extends AbstractJavaCodegen this.setHateoas(Boolean.valueOf(additionalProperties.get(HATEOAS).toString())); } + if (additionalProperties.containsKey(RETURN_SUCCESS_CODE)) { + this.setReturnSuccessCode(Boolean.valueOf(additionalProperties.get(RETURN_SUCCESS_CODE).toString())); + } + typeMapping.put("file", "Resource"); importMapping.put("Resource", "org.springframework.core.io.Resource"); @@ -721,6 +728,10 @@ public class SpringCodegen extends AbstractJavaCodegen this.hateoas = hateoas; } + public void setReturnSuccessCode(boolean returnSuccessCode) { + this.returnSuccessCode = returnSuccessCode; + } + @Override public void postProcessModelProperty(CodegenModel model, CodegenProperty property) { super.postProcessModelProperty(model, property); diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/methodBody.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/methodBody.mustache index 8597a7419cac..40b041331ce3 100644 --- a/modules/openapi-generator/src/main/resources/JavaSpring/methodBody.mustache +++ b/modules/openapi-generator/src/main/resources/JavaSpring/methodBody.mustache @@ -16,7 +16,7 @@ return CompletableFuture.supplyAsync(()-> { {{#jdk8}} {{#async}} {{/async}} }); {{/jdk8}} -{{#async}} {{/async}} return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); +{{#async}} {{/async}} return new ResponseEntity<>({{#returnSuccessCode}}HttpStatus.valueOf({{{statusCode}}}){{/returnSuccessCode}}{{^returnSuccessCode}}HttpStatus.NOT_IMPLEMENTED{{/returnSuccessCode}}); {{#jdk8}} {{#async}} }, Runnable::run); @@ -25,14 +25,14 @@ return CompletableFuture.supplyAsync(()-> { {{/-last}} {{/examples}} {{^examples}} -return {{#jdk8}}{{#async}}CompletableFuture.completedFuture({{/async}}{{/jdk8}}new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED){{#jdk8}}{{#async}}){{/async}}{{/jdk8}}; +return {{#jdk8}}{{#async}}CompletableFuture.completedFuture({{/async}}{{/jdk8}}new ResponseEntity<>({{#returnSuccessCode}}HttpStatus.OK{{/returnSuccessCode}}{{^returnSuccessCode}}HttpStatus.NOT_IMPLEMENTED{{/returnSuccessCode}}){{#jdk8}}{{#async}}){{/async}}{{/jdk8}}; {{/examples}} {{/reactive}} {{#reactive}} -exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); - Mono result = Mono.empty(); +Mono result = Mono.empty(); {{#examples}} {{#-first}} + exchange.getResponse().setStatusCode({{#returnSuccessCode}}HttpStatus.valueOf({{{statusCode}}}){{/returnSuccessCode}}{{^returnSuccessCode}}HttpStatus.NOT_IMPLEMENTED{{/returnSuccessCode}}); for (MediaType mediaType : exchange.getRequest().getHeaders().getAccept()) { {{/-first}} if (mediaType.isCompatibleWith(MediaType.valueOf("{{{contentType}}}"))) { @@ -43,5 +43,8 @@ exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); } {{/-last}} {{/examples}} +{{^examples}} + exchange.getResponse().setStatusCode({{#returnSuccessCode}}HttpStatus.OK{{/returnSuccessCode}}{{^returnSuccessCode}}HttpStatus.NOT_IMPLEMENTED{{/returnSuccessCode}}); +{{/examples}} return result.then(Mono.empty()); {{/reactive}} \ No newline at end of file diff --git a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/AnotherFakeApiDelegate.java b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/AnotherFakeApiDelegate.java index ddc7c2a0e8f8..5f8fd137adb1 100644 --- a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/AnotherFakeApiDelegate.java +++ b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/AnotherFakeApiDelegate.java @@ -31,8 +31,8 @@ public interface AnotherFakeApiDelegate { */ default Mono> call123testSpecialTags(Mono client, ServerWebExchange exchange) { - exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); Mono result = Mono.empty(); + exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); for (MediaType mediaType : exchange.getRequest().getHeaders().getAccept()) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { result = ApiUtil.getExampleResponse(exchange, "{ \"client\" : \"client\"}"); diff --git a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeApiDelegate.java b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeApiDelegate.java index 3b3f23ccece5..7d71fc5afbf3 100644 --- a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeApiDelegate.java +++ b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeApiDelegate.java @@ -40,8 +40,8 @@ public interface FakeApiDelegate { */ default Mono> fakeOuterBooleanSerialize(Mono body, ServerWebExchange exchange) { - exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); Mono result = Mono.empty(); + exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); return result.then(Mono.empty()); } @@ -51,8 +51,8 @@ public interface FakeApiDelegate { */ default Mono> fakeOuterCompositeSerialize(Mono outerComposite, ServerWebExchange exchange) { - exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); Mono result = Mono.empty(); + exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); for (MediaType mediaType : exchange.getRequest().getHeaders().getAccept()) { if (mediaType.isCompatibleWith(MediaType.valueOf("*/*"))) { result = ApiUtil.getExampleResponse(exchange, "{ \"my_string\" : \"my_string\", \"my_number\" : 0.80082819046101150206595775671303272247314453125, \"my_boolean\" : true}"); @@ -68,8 +68,8 @@ public interface FakeApiDelegate { */ default Mono> fakeOuterNumberSerialize(Mono body, ServerWebExchange exchange) { - exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); Mono result = Mono.empty(); + exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); return result.then(Mono.empty()); } @@ -79,8 +79,8 @@ public interface FakeApiDelegate { */ default Mono> fakeOuterStringSerialize(Mono body, ServerWebExchange exchange) { - exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); Mono result = Mono.empty(); + exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); return result.then(Mono.empty()); } @@ -90,8 +90,8 @@ public interface FakeApiDelegate { */ default Mono> testBodyWithFileSchema(Mono fileSchemaTestClass, ServerWebExchange exchange) { - exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); Mono result = Mono.empty(); + exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); return result.then(Mono.empty()); } @@ -102,8 +102,8 @@ public interface FakeApiDelegate { default Mono> testBodyWithQueryParams(String query, Mono user, ServerWebExchange exchange) { - exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); Mono result = Mono.empty(); + exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); return result.then(Mono.empty()); } @@ -113,8 +113,8 @@ public interface FakeApiDelegate { */ default Mono> testClientModel(Mono client, ServerWebExchange exchange) { - exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); Mono result = Mono.empty(); + exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); for (MediaType mediaType : exchange.getRequest().getHeaders().getAccept()) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { result = ApiUtil.getExampleResponse(exchange, "{ \"client\" : \"client\"}"); @@ -143,8 +143,8 @@ public interface FakeApiDelegate { String password, String paramCallback, ServerWebExchange exchange) { - exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); Mono result = Mono.empty(); + exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); return result.then(Mono.empty()); } @@ -161,8 +161,8 @@ public interface FakeApiDelegate { List enumFormStringArray, String enumFormString, ServerWebExchange exchange) { - exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); Mono result = Mono.empty(); + exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); return result.then(Mono.empty()); } @@ -177,8 +177,8 @@ public interface FakeApiDelegate { Boolean booleanGroup, Long int64Group, ServerWebExchange exchange) { - exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); Mono result = Mono.empty(); + exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); return result.then(Mono.empty()); } @@ -188,8 +188,8 @@ public interface FakeApiDelegate { */ default Mono> testInlineAdditionalProperties(Mono requestBody, ServerWebExchange exchange) { - exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); Mono result = Mono.empty(); + exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); return result.then(Mono.empty()); } @@ -200,8 +200,8 @@ public interface FakeApiDelegate { default Mono> testJsonFormData(String param, String param2, ServerWebExchange exchange) { - exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); Mono result = Mono.empty(); + exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); return result.then(Mono.empty()); } @@ -213,8 +213,8 @@ public interface FakeApiDelegate { MultipartFile requiredFile, String additionalMetadata, ServerWebExchange exchange) { - exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); Mono result = Mono.empty(); + exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); for (MediaType mediaType : exchange.getRequest().getHeaders().getAccept()) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { result = ApiUtil.getExampleResponse(exchange, "{ \"code\" : 0, \"type\" : \"type\", \"message\" : \"message\"}"); diff --git a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeClassnameTestApiDelegate.java b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeClassnameTestApiDelegate.java index bffd475ef6b8..bef3cea1a08a 100644 --- a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeClassnameTestApiDelegate.java +++ b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeClassnameTestApiDelegate.java @@ -31,8 +31,8 @@ public interface FakeClassnameTestApiDelegate { */ default Mono> testClassname(Mono client, ServerWebExchange exchange) { - exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); Mono result = Mono.empty(); + exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); for (MediaType mediaType : exchange.getRequest().getHeaders().getAccept()) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { result = ApiUtil.getExampleResponse(exchange, "{ \"client\" : \"client\"}"); diff --git a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/PetApiDelegate.java b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/PetApiDelegate.java index 1606fac281d1..3cf894153de2 100644 --- a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/PetApiDelegate.java +++ b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/PetApiDelegate.java @@ -33,8 +33,8 @@ public interface PetApiDelegate { */ default Mono> addPet(Mono pet, ServerWebExchange exchange) { - exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); Mono result = Mono.empty(); + exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); return result.then(Mono.empty()); } @@ -45,8 +45,8 @@ public interface PetApiDelegate { default Mono> deletePet(Long petId, String apiKey, ServerWebExchange exchange) { - exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); Mono result = Mono.empty(); + exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); return result.then(Mono.empty()); } @@ -56,8 +56,8 @@ public interface PetApiDelegate { */ default Mono>> findPetsByStatus(List status, ServerWebExchange exchange) { - exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); Mono result = Mono.empty(); + exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); for (MediaType mediaType : exchange.getRequest().getHeaders().getAccept()) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { result = ApiUtil.getExampleResponse(exchange, "{ \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"default-name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"}"); @@ -77,8 +77,8 @@ public interface PetApiDelegate { */ default Mono>> findPetsByTags(List tags, ServerWebExchange exchange) { - exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); Mono result = Mono.empty(); + exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); for (MediaType mediaType : exchange.getRequest().getHeaders().getAccept()) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { result = ApiUtil.getExampleResponse(exchange, "{ \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"default-name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"}"); @@ -98,8 +98,8 @@ public interface PetApiDelegate { */ default Mono> getPetById(Long petId, ServerWebExchange exchange) { - exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); Mono result = Mono.empty(); + exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); for (MediaType mediaType : exchange.getRequest().getHeaders().getAccept()) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { result = ApiUtil.getExampleResponse(exchange, "{ \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"default-name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"}"); @@ -119,8 +119,8 @@ public interface PetApiDelegate { */ default Mono> updatePet(Mono pet, ServerWebExchange exchange) { - exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); Mono result = Mono.empty(); + exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); return result.then(Mono.empty()); } @@ -132,8 +132,8 @@ public interface PetApiDelegate { String name, String status, ServerWebExchange exchange) { - exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); Mono result = Mono.empty(); + exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); return result.then(Mono.empty()); } @@ -145,8 +145,8 @@ public interface PetApiDelegate { String additionalMetadata, MultipartFile file, ServerWebExchange exchange) { - exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); Mono result = Mono.empty(); + exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); for (MediaType mediaType : exchange.getRequest().getHeaders().getAccept()) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { result = ApiUtil.getExampleResponse(exchange, "{ \"code\" : 0, \"type\" : \"type\", \"message\" : \"message\"}"); diff --git a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/StoreApiDelegate.java b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/StoreApiDelegate.java index 8e95e0178b05..30ab1e9d3486 100644 --- a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/StoreApiDelegate.java +++ b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/StoreApiDelegate.java @@ -32,8 +32,8 @@ public interface StoreApiDelegate { */ default Mono> deleteOrder(String orderId, ServerWebExchange exchange) { - exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); Mono result = Mono.empty(); + exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); return result.then(Mono.empty()); } @@ -42,8 +42,8 @@ public interface StoreApiDelegate { * @see StoreApi#getInventory */ default Mono>> getInventory(ServerWebExchange exchange) { - exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); Mono result = Mono.empty(); + exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); return result.then(Mono.empty()); } @@ -53,8 +53,8 @@ public interface StoreApiDelegate { */ default Mono> getOrderById(Long orderId, ServerWebExchange exchange) { - exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); Mono result = Mono.empty(); + exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); for (MediaType mediaType : exchange.getRequest().getHeaders().getAccept()) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { result = ApiUtil.getExampleResponse(exchange, "{ \"petId\" : 6, \"quantity\" : 1, \"id\" : 0, \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\", \"complete\" : false, \"status\" : \"placed\"}"); @@ -74,8 +74,8 @@ public interface StoreApiDelegate { */ default Mono> placeOrder(Mono order, ServerWebExchange exchange) { - exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); Mono result = Mono.empty(); + exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); for (MediaType mediaType : exchange.getRequest().getHeaders().getAccept()) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { result = ApiUtil.getExampleResponse(exchange, "{ \"petId\" : 6, \"quantity\" : 1, \"id\" : 0, \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\", \"complete\" : false, \"status\" : \"placed\"}"); diff --git a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/UserApiDelegate.java b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/UserApiDelegate.java index 03de7cd2b49a..fbfafaaa378b 100644 --- a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/UserApiDelegate.java +++ b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/UserApiDelegate.java @@ -32,8 +32,8 @@ public interface UserApiDelegate { */ default Mono> createUser(Mono user, ServerWebExchange exchange) { - exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); Mono result = Mono.empty(); + exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); return result.then(Mono.empty()); } @@ -43,8 +43,8 @@ public interface UserApiDelegate { */ default Mono> createUsersWithArrayInput(Flux user, ServerWebExchange exchange) { - exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); Mono result = Mono.empty(); + exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); return result.then(Mono.empty()); } @@ -54,8 +54,8 @@ public interface UserApiDelegate { */ default Mono> createUsersWithListInput(Flux user, ServerWebExchange exchange) { - exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); Mono result = Mono.empty(); + exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); return result.then(Mono.empty()); } @@ -65,8 +65,8 @@ public interface UserApiDelegate { */ default Mono> deleteUser(String username, ServerWebExchange exchange) { - exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); Mono result = Mono.empty(); + exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); return result.then(Mono.empty()); } @@ -76,8 +76,8 @@ public interface UserApiDelegate { */ default Mono> getUserByName(String username, ServerWebExchange exchange) { - exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); Mono result = Mono.empty(); + exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); for (MediaType mediaType : exchange.getRequest().getHeaders().getAccept()) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { result = ApiUtil.getExampleResponse(exchange, "{ \"firstName\" : \"firstName\", \"lastName\" : \"lastName\", \"password\" : \"password\", \"userStatus\" : 6, \"phone\" : \"phone\", \"id\" : 0, \"email\" : \"email\", \"username\" : \"username\"}"); @@ -98,8 +98,8 @@ public interface UserApiDelegate { default Mono> loginUser(String username, String password, ServerWebExchange exchange) { - exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); Mono result = Mono.empty(); + exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); return result.then(Mono.empty()); } @@ -108,8 +108,8 @@ public interface UserApiDelegate { * @see UserApi#logoutUser */ default Mono> logoutUser(ServerWebExchange exchange) { - exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); Mono result = Mono.empty(); + exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); return result.then(Mono.empty()); } @@ -120,8 +120,8 @@ public interface UserApiDelegate { default Mono> updateUser(String username, Mono user, ServerWebExchange exchange) { - exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); Mono result = Mono.empty(); + exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); return result.then(Mono.empty()); }