This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch binding2 in repository https://gitbox.apache.org/repos/asf/camel.git
commit a7f84e296a794db51c0b132702bc4e4f21216d68 Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Wed Apr 3 16:12:18 2024 +0200 CAMEL-20557: Rest DSL to use openapi spec directly --- ...mHttpRestOpenApiConsumerRestDslBindingTest.java | 44 +++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/PlatformHttpRestOpenApiConsumerRestDslBindingTest.java b/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/PlatformHttpRestOpenApiConsumerRestDslBindingTest.java index ab62516d8c6..d36a362e056 100644 --- a/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/PlatformHttpRestOpenApiConsumerRestDslBindingTest.java +++ b/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/PlatformHttpRestOpenApiConsumerRestDslBindingTest.java @@ -19,6 +19,7 @@ package org.apache.camel.component.platform.http.vertx; import org.apache.camel.CamelContext; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.platform.http.vertx.model.Pet; +import org.apache.camel.component.rest.openapi.RestOpenApiComponent; import org.apache.camel.model.rest.RestBindingMode; import org.junit.jupiter.api.Test; @@ -28,7 +29,7 @@ import static org.hamcrest.Matchers.equalTo; public class PlatformHttpRestOpenApiConsumerRestDslBindingTest { @Test - public void testRestOpenApi() throws Exception { + public void testRestOpenApiOutType() throws Exception { final CamelContext context = VertxPlatformHttpEngineTest.createCamelContext(); try { @@ -65,4 +66,45 @@ public class PlatformHttpRestOpenApiConsumerRestDslBindingTest { } } + @Test + public void testRestOpenApiInType() throws Exception { + final CamelContext context = VertxPlatformHttpEngineTest.createCamelContext(); + + try { + context.addRoutes(new RouteBuilder() { + @Override + public void configure() { + // TODO: make it easy to set binding package name + RestOpenApiComponent rac = context.getComponent("rest-openapi", RestOpenApiComponent.class); + rac.setBindingPackageName(Pet.class.getPackageName()); + + restConfiguration().bindingMode(RestBindingMode.json); + + rest().openApi().specification("openapi-v3.json").missingOperation("ignore"); + + from("direct:updatePet") + .process(e -> { + Pet pet = e.getMessage().getBody(Pet.class); + pet.setStatus(Pet.Status.PENDING); + e.getMessage().setBody(pet); + }); + } + }); + + context.start(); + + given() + .when() + .contentType("application/json") + .body("{\"id\":123,\"name\":\"tony the tiger\"}") + .put("/api/v3/pet") + .then() + .statusCode(200) + .body(equalTo("{\"id\":123,\"name\":\"tony the tiger\",\"status\":\"PENDING\"}")); + + } finally { + context.stop(); + } + } + }