This is an automated email from the ASF dual-hosted git repository. nfilotto pushed a commit to branch CAMEL-18548/add-flag-to-disable-list-support in repository https://gitbox.apache.org/repos/asf/camel.git
commit 62342faee0f8bb15d15263fa66023ca33be84dbf Author: Nicolas Filotto <[email protected]> AuthorDate: Sat Sep 24 11:13:19 2022 +0200 CAMEL-18548: camel-jsonpath - Add flag to disable the list and map support --- components/camel-cxf/camel-cxf-rest/pom.xml | 11 +- .../cxf/jaxrs/CxfRsConsumerWithBeanTest.java | 29 +++- .../jaxrs/testbean/CustomerServiceResource.java | 7 + .../org/apache/camel/jsonpath/jsonpath.json | 1 + .../org/apache/camel/jsonpath/JsonPathEngine.java | 41 ++--- .../apache/camel/jsonpath/JsonPathExpression.java | 17 ++- .../apache/camel/jsonpath/JsonPathLanguage.java | 18 ++- .../camel/jsonpath/JsonPathLanguageTest.java | 166 ++++++++++++++++++++- .../org/apache/camel/model/language/jsonpath.json | 1 + .../camel/builder/ExpressionClauseSupport.java | 133 +++++++++++++++++ .../camel/model/language/JsonPathExpression.java | 15 ++ .../language/JsonPathExpressionReifier.java | 3 +- .../java/org/apache/camel/xml/in/ModelParser.java | 155 +++++++++++++++++-- 13 files changed, 555 insertions(+), 42 deletions(-) diff --git a/components/camel-cxf/camel-cxf-rest/pom.xml b/components/camel-cxf/camel-cxf-rest/pom.xml index ede12cca949..f3389e9a2b2 100644 --- a/components/camel-cxf/camel-cxf-rest/pom.xml +++ b/components/camel-cxf/camel-cxf-rest/pom.xml @@ -126,7 +126,16 @@ <artifactId>camel-xpath</artifactId> <scope>test</scope> </dependency> - + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-jsonpath</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-jackson</artifactId> + <scope>test</scope> + </dependency> <dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-test-junit5</artifactId> diff --git a/components/camel-cxf/camel-cxf-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsConsumerWithBeanTest.java b/components/camel-cxf/camel-cxf-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsConsumerWithBeanTest.java index 6a2ef98bb3e..4eb829421a3 100644 --- a/components/camel-cxf/camel-cxf-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsConsumerWithBeanTest.java +++ b/components/camel-cxf/camel-cxf-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsConsumerWithBeanTest.java @@ -22,6 +22,7 @@ import org.apache.camel.component.cxf.jaxrs.testbean.ServiceUtil; import org.apache.camel.spi.Registry; import org.apache.camel.test.junit5.CamelTestSupport; import org.apache.http.HttpResponse; +import org.apache.http.client.methods.HttpPost; import org.apache.http.client.methods.HttpPut; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.CloseableHttpClient; @@ -31,7 +32,7 @@ import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; -public class CxfRsConsumerWithBeanTest extends CamelTestSupport { +class CxfRsConsumerWithBeanTest extends CamelTestSupport { private static final String CXT = CXFTestSupport.getPort1() + "/CxfRsConsumerWithBeanTest"; private static final String CXF_RS_ENDPOINT_URI = "cxfrs://http://localhost:" + CXT @@ -39,10 +40,14 @@ public class CxfRsConsumerWithBeanTest extends CamelTestSupport { private static final String CXF_RS_ENDPOINT_URI_2 = "cxfrs://http://localhost:" + CXT + "/rest2?resourceClasses=org.apache.camel.component.cxf.jaxrs.testbean.CustomerServiceResource"; + private static final String CXF_RS_ENDPOINT_URI_3 + = "cxfrs://http://localhost:" + CXT + + "/rest3?resourceClasses=org.apache.camel.component.cxf.jaxrs.testbean.CustomerServiceResource"; @Override protected void bindToRegistry(Registry registry) throws Exception { registry.bind("service", new ServiceUtil()); + // registry.bind("jsonpath-language", LanguageCustomizer.builder(JsonPathLanguage.class).build(l -> l.setSupportPojoAsMapAndList(false))); } @Override @@ -51,12 +56,26 @@ public class CxfRsConsumerWithBeanTest extends CamelTestSupport { public void configure() { from(CXF_RS_ENDPOINT_URI).to("bean://service?method=invoke(${body[0]}, ${body[1]})"); from(CXF_RS_ENDPOINT_URI_2).bean(ServiceUtil.class, "invoke(${body[0]}, ${body[1]})"); + from(CXF_RS_ENDPOINT_URI_3).setBody().jsonpath("$.name"); } }; } @Test - public void testPutConsumer() throws Exception { + void testPostConsumer() throws Exception { + HttpPost post = new HttpPost("http://localhost:" + CXT + "/rest3/customerservice/customer"); + StringEntity entity = new StringEntity("{\"name\":\"John\", \"age\":30, \"car\":null}"); + post.setEntity(entity); + entity.setContentType("application/json"); + try (CloseableHttpClient httpclient = HttpClientBuilder.create().build()) { + HttpResponse response = httpclient.execute(post); + assertEquals(200, response.getStatusLine().getStatusCode()); + assertEquals("John", EntityUtils.toString(response.getEntity())); + } + } + + @Test + void testPutConsumer() throws Exception { sendPutRequest("http://localhost:" + CXT + "/rest/customerservice/c20"); sendPutRequest("http://localhost:" + CXT + "/rest2/customerservice/c20"); } @@ -66,14 +85,10 @@ public class CxfRsConsumerWithBeanTest extends CamelTestSupport { StringEntity entity = new StringEntity("string"); entity.setContentType("text/plain"); put.setEntity(entity); - CloseableHttpClient httpclient = HttpClientBuilder.create().build(); - - try { + try (CloseableHttpClient httpclient = HttpClientBuilder.create().build()) { HttpResponse response = httpclient.execute(put); assertEquals(200, response.getStatusLine().getStatusCode()); assertEquals("c20string", EntityUtils.toString(response.getEntity())); - } finally { - httpclient.close(); } } } diff --git a/components/camel-cxf/camel-cxf-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/testbean/CustomerServiceResource.java b/components/camel-cxf/camel-cxf-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/testbean/CustomerServiceResource.java index e36313746a1..760f7ad0696 100644 --- a/components/camel-cxf/camel-cxf-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/testbean/CustomerServiceResource.java +++ b/components/camel-cxf/camel-cxf-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/testbean/CustomerServiceResource.java @@ -18,6 +18,7 @@ package org.apache.camel.component.cxf.jaxrs.testbean; import javax.ws.rs.Consumes; import javax.ws.rs.GET; +import javax.ws.rs.POST; import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.PathParam; @@ -47,5 +48,11 @@ public interface CustomerServiceResource { Object invoke( @PathParam("id") String id, String payload); + + @Path("/customer") + @POST + @Consumes({ "application/json" }) + @Produces({ "application/json" }) + Object createCustomer(String payload); } // END SNIPPET: example diff --git a/components/camel-jsonpath/src/generated/resources/org/apache/camel/jsonpath/jsonpath.json b/components/camel-jsonpath/src/generated/resources/org/apache/camel/jsonpath/jsonpath.json index df4c7cc3c77..329407229df 100644 --- a/components/camel-jsonpath/src/generated/resources/org/apache/camel/jsonpath/jsonpath.json +++ b/components/camel-jsonpath/src/generated/resources/org/apache/camel/jsonpath/jsonpath.json @@ -21,6 +21,7 @@ "suppressExceptions": { "kind": "attribute", "displayName": "Suppress Exceptions", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether to suppress exceptions such as PathNotFoundException." }, "allowSimple": { "kind": "attribute", "displayName": "Allow Simple", "label": "advanced", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether to allow in inlined Simple exceptions in the JSONPath expression" }, "allowEasyPredicate": { "kind": "attribute", "displayName": "Allow Easy Predicate", "label": "advanced", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether to allow using the easy predicate parser to pre-parse predicates." }, + "supportPojoAsMapAndList": { "kind": "attribute", "displayName": "Support Pojo As Map And List", "label": "advanced", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "To indicate whether a Map or List should be processed natively or the default behavior is expected (Auto converted into InputStream ). This flag has been added for backward compatibility reasons." }, "writeAsString": { "kind": "attribute", "displayName": "Write As String", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether to write the output of each row\/element as a JSON String value instead of a Map\/POJO value." }, "headerName": { "kind": "attribute", "displayName": "Header Name", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Name of header to use as input, instead of the message body" }, "option": { "kind": "attribute", "displayName": "Option", "label": "advanced", "required": false, "type": "enum", "javaType": "java.lang.String", "enum": [ "DEFAULT_PATH_LEAF_TO_NULL", "ALWAYS_RETURN_LIST", "AS_PATH_LIST", "SUPPRESS_EXCEPTIONS", "REQUIRE_PROPERTIES" ], "deprecated": false, "autowired": false, "secret": false, "description": "To configure additional options on JSONPath. Multiple values can be separated by comma." }, diff --git a/components/camel-jsonpath/src/main/java/org/apache/camel/jsonpath/JsonPathEngine.java b/components/camel-jsonpath/src/main/java/org/apache/camel/jsonpath/JsonPathEngine.java index 7db4b17afcc..c3c4df6ec18 100644 --- a/components/camel-jsonpath/src/main/java/org/apache/camel/jsonpath/JsonPathEngine.java +++ b/components/camel-jsonpath/src/main/java/org/apache/camel/jsonpath/JsonPathEngine.java @@ -58,16 +58,17 @@ public class JsonPathEngine { private final String headerName; private final Configuration configuration; private final boolean hasSimple; + private final boolean supportPojoAsMapAndList; private JsonPathAdapter adapter; private volatile boolean initJsonAdapter; @Deprecated public JsonPathEngine(String expression) { - this(expression, false, false, true, null, null, null); + this(expression, false, false, true, true, null, null, null); } public JsonPathEngine(String expression, boolean writeAsString, boolean suppressExceptions, boolean allowSimple, - String headerName, Option[] options, CamelContext context) { + boolean supportPojoAsMapAndList, String headerName, Option[] options, CamelContext context) { this.expression = expression; this.writeAsString = writeAsString; this.headerName = headerName; @@ -100,6 +101,7 @@ public class JsonPathEngine { } } this.hasSimple = simpleInUse; + this.supportPojoAsMapAndList = supportPojoAsMapAndList; } private ObjectMapper findRegisteredMapper(CamelContext context) { @@ -189,25 +191,26 @@ public class JsonPathEngine { LOG.trace("JSonPath: {} is read as String: {}", path, json); String str = (String) json; return JsonPath.using(configuration).parse(str).read(path); - } else if (json instanceof Map) { - LOG.trace("JSonPath: {} is read as Map: {}", path, json); - Map map = (Map) json; - return JsonPath.using(configuration).parse(map).read(path); - } else if (json instanceof List) { - LOG.trace("JSonPath: {} is read as List: {}", path, json); - List list = (List) json; - return JsonPath.using(configuration).parse(list).read(path); - } else { - //try to auto convert into inputStream - Object answer = readWithInputStream(path, exchange); - if (answer == null) { - // fallback and attempt an adapter which can read the message body/header - answer = readWithAdapter(path, exchange); - } - if (answer != null) { - return answer; + } else if (supportPojoAsMapAndList) { + if (json instanceof Map) { + LOG.trace("JSonPath: {} is read as Map: {}", path, json); + Map<?, ?> map = (Map<?, ?>) json; + return JsonPath.using(configuration).parse(map).read(path); + } else if (json instanceof List) { + LOG.trace("JSonPath: {} is read as List: {}", path, json); + List<?> list = (List<?>) json; + return JsonPath.using(configuration).parse(list).read(path); } } + //try to auto convert into inputStream + Object answer = readWithInputStream(path, exchange); + if (answer == null) { + // fallback and attempt an adapter which can read the message body/header + answer = readWithAdapter(path, exchange); + } + if (answer != null) { + return answer; + } // is json path configured to suppress exceptions if (configuration.getOptions().contains(SUPPRESS_EXCEPTIONS)) { diff --git a/components/camel-jsonpath/src/main/java/org/apache/camel/jsonpath/JsonPathExpression.java b/components/camel-jsonpath/src/main/java/org/apache/camel/jsonpath/JsonPathExpression.java index c2cb7df322a..07819e87b62 100644 --- a/components/camel-jsonpath/src/main/java/org/apache/camel/jsonpath/JsonPathExpression.java +++ b/components/camel-jsonpath/src/main/java/org/apache/camel/jsonpath/JsonPathExpression.java @@ -42,6 +42,7 @@ public class JsonPathExpression extends ExpressionAdapter { private boolean allowSimple = true; private boolean allowEasyPredicate = true; private boolean writeAsString; + private boolean supportPojoAsMapAndList = true; private String headerName; private Option[] options; @@ -138,6 +139,18 @@ public class JsonPathExpression extends ExpressionAdapter { this.options = options; } + public boolean isSupportPojoAsMapAndList() { + return supportPojoAsMapAndList; + } + + /** + * To indicate whether a {@code Map} or {@code List} should be processed natively or the default behavior is + * expected (Auto converted into {@code InputStream}). This flag has been added for backward compatibility reasons. + */ + public void setSupportPojoAsMapAndList(boolean supportPojoAsMapAndList) { + this.supportPojoAsMapAndList = supportPojoAsMapAndList; + } + @Override public Object evaluate(Exchange exchange) { try { @@ -175,7 +188,9 @@ public class JsonPathExpression extends ExpressionAdapter { LOG.debug("Initializing {} using: {}", predicate ? "predicate" : "expression", exp); try { - engine = new JsonPathEngine(exp, writeAsString, suppressExceptions, allowSimple, headerName, options, context); + engine = new JsonPathEngine( + exp, writeAsString, suppressExceptions, allowSimple, supportPojoAsMapAndList, headerName, + options, context); } catch (Exception e) { throw new ExpressionIllegalSyntaxException(exp, e); } diff --git a/components/camel-jsonpath/src/main/java/org/apache/camel/jsonpath/JsonPathLanguage.java b/components/camel-jsonpath/src/main/java/org/apache/camel/jsonpath/JsonPathLanguage.java index 5b79903c03e..7598b6a0622 100644 --- a/components/camel-jsonpath/src/main/java/org/apache/camel/jsonpath/JsonPathLanguage.java +++ b/components/camel-jsonpath/src/main/java/org/apache/camel/jsonpath/JsonPathLanguage.java @@ -37,6 +37,7 @@ public class JsonPathLanguage extends LanguageSupport implements PropertyConfigu private boolean suppressExceptions; private boolean allowSimple = true; private boolean allowEasyPredicate = true; + private boolean supportPojoAsMapAndList = true; private boolean writeAsString; private String headerName; private Option[] options; @@ -97,6 +98,14 @@ public class JsonPathLanguage extends LanguageSupport implements PropertyConfigu this.options = options; } + public boolean isSupportPojoAsMapAndList() { + return supportPojoAsMapAndList; + } + + public void setSupportPojoAsMapAndList(boolean supportPojoAsMapAndList) { + this.supportPojoAsMapAndList = supportPojoAsMapAndList; + } + @Override public Predicate createPredicate(String expression) { JsonPathExpression answer = (JsonPathExpression) createExpression(expression); @@ -113,8 +122,8 @@ public class JsonPathLanguage extends LanguageSupport implements PropertyConfigu answer.setAllowEasyPredicate(allowEasyPredicate); answer.setHeaderName(headerName); answer.setWriteAsString(writeAsString); - answer.setHeaderName(headerName); answer.setOptions(options); + answer.setSupportPojoAsMapAndList(supportPojoAsMapAndList); answer.init(getCamelContext()); return answer; } @@ -141,8 +150,9 @@ public class JsonPathLanguage extends LanguageSupport implements PropertyConfigu for (String s : option.split(",")) { list.add(getCamelContext().getTypeConverter().convertTo(Option.class, s)); } - answer.setOptions(list.toArray(new Option[list.size()])); + answer.setOptions(list.toArray(new Option[0])); } + answer.setSupportPojoAsMapAndList(property(boolean.class, properties, 7, supportPojoAsMapAndList)); answer.init(getCamelContext()); return answer; } @@ -192,6 +202,10 @@ public class JsonPathLanguage extends LanguageSupport implements PropertyConfigu case "writeAsString": setWriteAsString(PropertyConfigurerSupport.property(camelContext, boolean.class, value)); return true; + case "supportpojoasmapandlist": + case "supportPojoAsMapAndList": + setSupportPojoAsMapAndList(PropertyConfigurerSupport.property(camelContext, boolean.class, value)); + return true; case "options": setOptions(PropertyConfigurerSupport.property(camelContext, Option[].class, value)); return true; diff --git a/components/camel-jsonpath/src/test/java/org/apache/camel/jsonpath/JsonPathLanguageTest.java b/components/camel-jsonpath/src/test/java/org/apache/camel/jsonpath/JsonPathLanguageTest.java index 8b9f068f64f..8159f72e7fb 100644 --- a/components/camel-jsonpath/src/test/java/org/apache/camel/jsonpath/JsonPathLanguageTest.java +++ b/components/camel-jsonpath/src/test/java/org/apache/camel/jsonpath/JsonPathLanguageTest.java @@ -16,7 +16,11 @@ */ package org.apache.camel.jsonpath; +import java.io.ByteArrayInputStream; import java.io.File; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -25,8 +29,11 @@ import com.jayway.jsonpath.Option; import org.apache.camel.Exchange; import org.apache.camel.Expression; import org.apache.camel.Predicate; +import org.apache.camel.component.file.GenericFile; +import org.apache.camel.converter.stream.ByteArrayInputStreamCache; import org.apache.camel.spi.Language; import org.apache.camel.support.DefaultExchange; +import org.apache.camel.support.SimpleTypeConverter; import org.apache.camel.test.junit5.CamelTestSupport; import org.junit.jupiter.api.Test; import org.slf4j.Logger; @@ -87,9 +94,93 @@ public class JsonPathLanguageTest extends CamelTestSupport { } @Test - public void testExpressionPojo() { + public void testExpressionInputStream() { Exchange exchange = new DefaultExchange(context); - Map pojo = new HashMap(); + exchange.getIn().setBody( + new ByteArrayInputStreamCache( + new ByteArrayInputStream( + "{\"kind\": \"full\", \"type\": \"customer\"}".getBytes(StandardCharsets.UTF_8)))); + + Language lan = context.resolveLanguage("jsonpath"); + Expression exp = lan.createExpression("$.kind"); + String kind = exp.evaluate(exchange, String.class); + + assertNotNull(kind); + assertEquals("full", kind); + + exp = lan.createExpression("$.type"); + String type = exp.evaluate(exchange, String.class); + assertNotNull(type); + assertEquals("customer", type); + } + + @Test + public void testExpressionInputStreamWithEncoding() { + Exchange exchange = new DefaultExchange(context); + exchange.getIn().setBody( + new ByteArrayInputStreamCache( + new ByteArrayInputStream( + "{\"kind\": \"full\", \"type\": \"customer\"}".getBytes(StandardCharsets.UTF_8)))); + exchange.getIn().setHeader(JsonPathConstants.HEADER_JSON_ENCODING, "UTF-8"); + + Language lan = context.resolveLanguage("jsonpath"); + Expression exp = lan.createExpression("$.kind"); + String kind = exp.evaluate(exchange, String.class); + + assertNotNull(kind); + assertEquals("full", kind); + + exp = lan.createExpression("$.type"); + String type = exp.evaluate(exchange, String.class); + assertNotNull(type); + assertEquals("customer", type); + } + + @Test + public void testExpressionGenericFile() { + Exchange exchange = new DefaultExchange(context); + GenericFile<File> body = new GenericFile<>(); + body.setFile(new File("src/test/resources/type.json")); + exchange.getIn().setBody(body); + + Language lan = context.resolveLanguage("jsonpath"); + Expression exp = lan.createExpression("$.kind"); + String kind = exp.evaluate(exchange, String.class); + + assertNotNull(kind); + assertEquals("full", kind); + + exp = lan.createExpression("$.type"); + String type = exp.evaluate(exchange, String.class); + assertNotNull(type); + assertEquals("customer", type); + } + + @Test + public void testExpressionGenericFileWithCharset() { + Exchange exchange = new DefaultExchange(context); + GenericFile<File> body = new GenericFile<>(); + body.setCharset("UTF-8"); + body.setFile(new File("src/test/resources/type.json")); + exchange.getIn().setBody(body); + + Language lan = context.resolveLanguage("jsonpath"); + Expression exp = lan.createExpression("$.kind"); + String kind = exp.evaluate(exchange, String.class); + + assertNotNull(kind); + assertEquals("full", kind); + + exp = lan.createExpression("$.type"); + String type = exp.evaluate(exchange, String.class); + assertNotNull(type); + assertEquals("customer", type); + } + + @Test + public void testExpressionMap() { + Exchange exchange = new DefaultExchange(context); + Map<String, String> pojo = new HashMap<>(); pojo.put("kind", "full"); pojo.put("type", "customer"); exchange.getIn().setBody(pojo); @@ -107,6 +198,72 @@ public class JsonPathLanguageTest extends CamelTestSupport { assertEquals("customer", type); } + @Test + public void testExpressionListOfMap() { + Exchange exchange = new DefaultExchange(context); + Map<String, String> pojo = new HashMap<>(); + pojo.put("kind", "full"); + pojo.put("type", "customer"); + exchange.getIn().setBody(List.of(pojo)); + + Language lan = context.resolveLanguage("jsonpath"); + Expression exp = lan.createExpression("$..kind"); + List<?> kinds = exp.evaluate(exchange, List.class); + + assertNotNull(kinds); + assertEquals(1, kinds.size()); + assertEquals("full", kinds.get(0)); + + exp = lan.createExpression("$..type"); + List<?> types = exp.evaluate(exchange, List.class); + assertNotNull(types); + assertEquals(1, types.size()); + assertEquals("customer", types.get(0)); + } + + @Test + public void testExpressionListOfCustomList() { + context.getTypeConverterRegistry().addTypeConverter( + InputStream.class, CustomList.class, + new SimpleTypeConverter( + false, + (Class<?> type, Exchange exchange, Object value) -> new ByteArrayInputStream( + ((String) (((List<?>) value).get(0))).getBytes(StandardCharsets.UTF_8)))); + Exchange exchange = new DefaultExchange(context); + exchange.getIn().setBody(new CustomList("{\"kind\": \"full\", \"type\": \"customer\"}")); + + JsonPathLanguage lan = (JsonPathLanguage) context.resolveLanguage("jsonpath"); + lan.setSupportPojoAsMapAndList(false); + Expression exp = lan.createExpression("$.kind"); + String kind = exp.evaluate(exchange, String.class); + + assertNotNull(kind); + assertEquals("full", kind); + + exp = lan.createExpression("$.type"); + String type = exp.evaluate(exchange, String.class); + assertNotNull(type); + assertEquals("customer", type); + } + + @Test + public void testExpressionString() { + Exchange exchange = new DefaultExchange(context); + exchange.getIn().setBody("{\"kind\": \"full\", \"type\": \"customer\"}"); + + Language lan = context.resolveLanguage("jsonpath"); + Expression exp = lan.createExpression("$.kind"); + String kind = exp.evaluate(exchange, String.class); + + assertNotNull(kind); + assertEquals("full", kind); + + exp = lan.createExpression("$.type"); + String type = exp.evaluate(exchange, String.class); + assertNotNull(type); + assertEquals("customer", type); + } + @Test public void testPredicate() { // Test books.json file @@ -137,4 +294,9 @@ public class JsonPathLanguageTest extends CamelTestSupport { assertNull(nofoo); } + public static class CustomList extends ArrayList<String> { + public CustomList(String value) { + add(value); + } + } } diff --git a/core/camel-core-model/src/generated/resources/org/apache/camel/model/language/jsonpath.json b/core/camel-core-model/src/generated/resources/org/apache/camel/model/language/jsonpath.json index 108923ff497..66120cea597 100644 --- a/core/camel-core-model/src/generated/resources/org/apache/camel/model/language/jsonpath.json +++ b/core/camel-core-model/src/generated/resources/org/apache/camel/model/language/jsonpath.json @@ -18,6 +18,7 @@ "suppressExceptions": { "kind": "attribute", "displayName": "Suppress Exceptions", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether to suppress exceptions such as PathNotFoundException." }, "allowSimple": { "kind": "attribute", "displayName": "Allow Simple", "label": "advanced", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether to allow in inlined Simple exceptions in the JSONPath expression" }, "allowEasyPredicate": { "kind": "attribute", "displayName": "Allow Easy Predicate", "label": "advanced", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether to allow using the easy predicate parser to pre-parse predicates." }, + "supportPojoAsMapAndList": { "kind": "attribute", "displayName": "Support Pojo As Map And List", "label": "advanced", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "To indicate whether a Map or List should be processed natively or the default behavior is expected (Auto converted into InputStream ). This flag has been added for backward compatibility reasons." }, "writeAsString": { "kind": "attribute", "displayName": "Write As String", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether to write the output of each row\/element as a JSON String value instead of a Map\/POJO value." }, "headerName": { "kind": "attribute", "displayName": "Header Name", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Name of header to use as input, instead of the message body" }, "option": { "kind": "attribute", "displayName": "Option", "label": "advanced", "required": false, "type": "enum", "javaType": "java.lang.String", "enum": [ "DEFAULT_PATH_LEAF_TO_NULL", "ALWAYS_RETURN_LIST", "AS_PATH_LIST", "SUPPRESS_EXCEPTIONS", "REQUIRE_PROPERTIES" ], "deprecated": false, "autowired": false, "secret": false, "description": "To configure additional options on JSONPath. Multiple values can be separated by comma." }, diff --git a/core/camel-core-model/src/main/java/org/apache/camel/builder/ExpressionClauseSupport.java b/core/camel-core-model/src/main/java/org/apache/camel/builder/ExpressionClauseSupport.java index df03eed5add..b584d15a08d 100644 --- a/core/camel-core-model/src/main/java/org/apache/camel/builder/ExpressionClauseSupport.java +++ b/core/camel-core-model/src/main/java/org/apache/camel/builder/ExpressionClauseSupport.java @@ -506,6 +506,24 @@ public class ExpressionClauseSupport<T> implements ExpressionFactoryAware, Predi return expression(expression); } + /** + * Evaluates a <a href="http://camel.apache.org/jsonpath.html">Json Path expression</a> + * + * @param text the expression to be evaluated + * @param suppressExceptions whether to suppress exceptions such as PathNotFoundException + * @param allowSimple whether to allow in inlined simple exceptions in the json path expression + * @param supportPojoAsMapAndList whether a {@code Map} or {@code List} should be processed natively or the default + * behavior is expected (Auto converted into {@code InputStream}) + * @return the builder to continue processing the DSL + */ + public T jsonpath(String text, boolean suppressExceptions, boolean allowSimple, boolean supportPojoAsMapAndList) { + JsonPathExpression expression = new JsonPathExpression(text); + expression.setSuppressExceptions(Boolean.toString(suppressExceptions)); + expression.setAllowSimple(Boolean.toString(allowSimple)); + expression.setSupportPojoAsMapAndList(Boolean.toString(supportPojoAsMapAndList)); + return expression(expression); + } + /** * Evaluates a <a href="http://camel.apache.org/jsonpath.html">Json Path expression</a> * @@ -554,6 +572,29 @@ public class ExpressionClauseSupport<T> implements ExpressionFactoryAware, Predi return result; } + /** + * Evaluates a <a href="http://camel.apache.org/jsonpath.html">Json Path expression</a> + * + * @param text the expression to be evaluated + * @param suppressExceptions whether to suppress exceptions such as PathNotFoundException + * @param allowSimple whether to allow in inlined simple exceptions in the json path expression + * @param supportPojoAsMapAndList whether a {@code Map} or {@code List} should be processed natively or the default + * behavior is expected (Auto converted into {@code InputStream}) + * @param resultType the return type expected by the expression + * @return the builder to continue processing the DSL + */ + public T jsonpath( + String text, boolean suppressExceptions, boolean allowSimple, boolean supportPojoAsMapAndList, + Class<?> resultType) { + JsonPathExpression expression = new JsonPathExpression(text); + expression.setSuppressExceptions(Boolean.toString(suppressExceptions)); + expression.setAllowSimple(Boolean.toString(allowSimple)); + expression.setSupportPojoAsMapAndList(Boolean.toString(supportPojoAsMapAndList)); + expression.setResultType(resultType); + expression(expression); + return result; + } + /** * Evaluates a <a href="http://camel.apache.org/jsonpath.html">Json Path expression</a> * @@ -574,6 +615,31 @@ public class ExpressionClauseSupport<T> implements ExpressionFactoryAware, Predi return result; } + /** + * Evaluates a <a href="http://camel.apache.org/jsonpath.html">Json Path expression</a> + * + * @param text the expression to be evaluated + * @param suppressExceptions whether to suppress exceptions such as PathNotFoundException + * @param allowSimple whether to allow in inlined simple exceptions in the json path expression + * @param supportPojoAsMapAndList whether a {@code Map} or {@code List} should be processed natively or the default + * behavior is expected (Auto converted into {@code InputStream}) + * @param resultType the return type expected by the expression + * @param headerName the name of the header to apply the expression to + * @return the builder to continue processing the DSL + */ + public T jsonpath( + String text, boolean suppressExceptions, boolean allowSimple, boolean supportPojoAsMapAndList, Class<?> resultType, + String headerName) { + JsonPathExpression expression = new JsonPathExpression(text); + expression.setSuppressExceptions(Boolean.toString(suppressExceptions)); + expression.setAllowSimple(Boolean.toString(allowSimple)); + expression.setSupportPojoAsMapAndList(Boolean.toString(supportPojoAsMapAndList)); + expression.setResultType(resultType); + expression.setHeaderName(headerName); + expression(expression); + return result; + } + /** * Evaluates a <a href="http://camel.apache.org/jsonpath.html">Json Path expression</a> with writeAsString enabled. * @@ -641,6 +707,26 @@ public class ExpressionClauseSupport<T> implements ExpressionFactoryAware, Predi return expression(expression); } + /** + * Evaluates a <a href="http://camel.apache.org/jsonpath.html">Json Path expression</a> with writeAsString enabled. + * + * @param text the expression to be evaluated + * @param suppressExceptions whether to suppress exceptions such as PathNotFoundException + * @param allowSimple whether to allow in inlined simple exceptions in the json path expression + * @param supportPojoAsMapAndList whether a {@code Map} or {@code List} should be processed natively or the default + * behavior is expected (Auto converted into {@code InputStream}) + * @return the builder to continue processing the DSL + */ + public T jsonpathWriteAsString( + String text, boolean suppressExceptions, boolean allowSimple, boolean supportPojoAsMapAndList) { + JsonPathExpression expression = new JsonPathExpression(text); + expression.setWriteAsString(Boolean.toString(true)); + expression.setSuppressExceptions(Boolean.toString(suppressExceptions)); + expression.setAllowSimple(Boolean.toString(allowSimple)); + expression.setSupportPojoAsMapAndList(Boolean.toString(supportPojoAsMapAndList)); + return expression(expression); + } + /** * Evaluates a <a href="http://camel.apache.org/jsonpath.html">Json Path expression</a> with writeAsString enabled. * @@ -659,6 +745,28 @@ public class ExpressionClauseSupport<T> implements ExpressionFactoryAware, Predi return expression(expression); } + /** + * Evaluates a <a href="http://camel.apache.org/jsonpath.html">Json Path expression</a> with writeAsString enabled. + * + * @param text the expression to be evaluated + * @param suppressExceptions whether to suppress exceptions such as PathNotFoundException + * @param allowSimple whether to allow in inlined simple exceptions in the json path expression + * @param supportPojoAsMapAndList whether a {@code Map} or {@code List} should be processed natively or the default + * behavior is expected (Auto converted into {@code InputStream}) + * @param headerName the name of the header to apply the expression to + * @return the builder to continue processing the DSL + */ + public T jsonpathWriteAsString( + String text, boolean suppressExceptions, boolean allowSimple, boolean supportPojoAsMapAndList, String headerName) { + JsonPathExpression expression = new JsonPathExpression(text); + expression.setWriteAsString(Boolean.toString(true)); + expression.setSuppressExceptions(Boolean.toString(suppressExceptions)); + expression.setAllowSimple(Boolean.toString(allowSimple)); + expression.setSupportPojoAsMapAndList(Boolean.toString(supportPojoAsMapAndList)); + expression.setHeaderName(headerName); + return expression(expression); + } + /** * Evaluates a <a href="http://camel.apache.org/jsonpath.html">Json Path expression</a> with writeAsString enabled. * @@ -680,6 +788,31 @@ public class ExpressionClauseSupport<T> implements ExpressionFactoryAware, Predi return expression(expression); } + /** + * Evaluates a <a href="http://camel.apache.org/jsonpath.html">Json Path expression</a> with writeAsString enabled. + * + * @param text the expression to be evaluated + * @param suppressExceptions whether to suppress exceptions such as PathNotFoundException + * @param allowSimple whether to allow in inlined simple exceptions in the json path expression + * @param supportPojoAsMapAndList whether a {@code Map} or {@code List} should be processed natively or the default + * behavior is expected (Auto converted into {@code InputStream}) + * @param headerName the name of the header to apply the expression to + * @param resultType the return type expected by the expression + * @return the builder to continue processing the DSL + */ + public T jsonpathWriteAsString( + String text, boolean suppressExceptions, boolean allowSimple, boolean supportPojoAsMapAndList, String headerName, + Class<?> resultType) { + JsonPathExpression expression = new JsonPathExpression(text); + expression.setWriteAsString(Boolean.toString(true)); + expression.setSuppressExceptions(Boolean.toString(suppressExceptions)); + expression.setAllowSimple(Boolean.toString(allowSimple)); + expression.setSupportPojoAsMapAndList(Boolean.toString(supportPojoAsMapAndList)); + expression.setHeaderName(headerName); + expression.setResultType(resultType); + return expression(expression); + } + /** * Evaluates an <a href="http://camel.apache.org/ognl.html">OGNL expression</a> * diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/language/JsonPathExpression.java b/core/camel-core-model/src/main/java/org/apache/camel/model/language/JsonPathExpression.java index bae9b501d86..70004494c6f 100644 --- a/core/camel-core-model/src/main/java/org/apache/camel/model/language/JsonPathExpression.java +++ b/core/camel-core-model/src/main/java/org/apache/camel/model/language/JsonPathExpression.java @@ -46,6 +46,9 @@ public class JsonPathExpression extends ExpressionDefinition { @Metadata(label = "advanced", defaultValue = "true", javaType = "java.lang.Boolean") private String allowEasyPredicate; @XmlAttribute + @Metadata(label = "advanced", defaultValue = "true", javaType = "java.lang.Boolean") + private String supportPojoAsMapAndList; + @XmlAttribute @Metadata(defaultValue = "false", javaType = "java.lang.Boolean") private String writeAsString; @XmlAttribute @@ -151,6 +154,18 @@ public class JsonPathExpression extends ExpressionDefinition { this.option = option; } + public String getSupportPojoAsMapAndList() { + return supportPojoAsMapAndList; + } + + /** + * To indicate whether a {@code Map} or {@code List} should be processed natively or the default behavior is + * expected (Auto converted into {@code InputStream}). This flag has been added for backward compatibility reasons. + */ + public void setSupportPojoAsMapAndList(String supportPojoAsMapAndList) { + this.supportPojoAsMapAndList = supportPojoAsMapAndList; + } + @Override public String getLanguage() { return "jsonpath"; diff --git a/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/language/JsonPathExpressionReifier.java b/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/language/JsonPathExpressionReifier.java index 5ef7d1eaec5..b546e40e2df 100644 --- a/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/language/JsonPathExpressionReifier.java +++ b/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/language/JsonPathExpressionReifier.java @@ -43,7 +43,7 @@ public class JsonPathExpressionReifier extends ExpressionReifier<JsonPathExpress } private Object[] createProperties() { - Object[] properties = new Object[7]; + Object[] properties = new Object[8]; properties[0] = definition.getResultType(); properties[1] = parseBoolean(definition.getSuppressExceptions()); properties[2] = parseBoolean(definition.getAllowSimple()); @@ -51,6 +51,7 @@ public class JsonPathExpressionReifier extends ExpressionReifier<JsonPathExpress properties[4] = parseBoolean(definition.getWriteAsString()); properties[5] = parseString(definition.getHeaderName()); properties[6] = parseString(definition.getOption()); + properties[7] = parseBoolean(definition.getSupportPojoAsMapAndList()); return properties; } diff --git a/core/camel-xml-io/src/generated/java/org/apache/camel/xml/in/ModelParser.java b/core/camel-xml-io/src/generated/java/org/apache/camel/xml/in/ModelParser.java index d0db623bb8e..7bdf1933ff7 100644 --- a/core/camel-xml-io/src/generated/java/org/apache/camel/xml/in/ModelParser.java +++ b/core/camel-xml-io/src/generated/java/org/apache/camel/xml/in/ModelParser.java @@ -29,18 +29,154 @@ import java.io.Reader; import java.util.ArrayList; import java.util.List; import java.util.Optional; + import org.apache.camel.model.*; -import org.apache.camel.model.cloud.*; +import org.apache.camel.model.cloud.BlacklistServiceCallServiceFilterConfiguration; +import org.apache.camel.model.cloud.CachingServiceCallServiceDiscoveryConfiguration; +import org.apache.camel.model.cloud.CombinedServiceCallServiceDiscoveryConfiguration; +import org.apache.camel.model.cloud.CombinedServiceCallServiceFilterConfiguration; +import org.apache.camel.model.cloud.ConsulServiceCallServiceDiscoveryConfiguration; +import org.apache.camel.model.cloud.CustomServiceCallServiceFilterConfiguration; +import org.apache.camel.model.cloud.DefaultServiceCallServiceLoadBalancerConfiguration; +import org.apache.camel.model.cloud.DnsServiceCallServiceDiscoveryConfiguration; +import org.apache.camel.model.cloud.HealthyServiceCallServiceFilterConfiguration; +import org.apache.camel.model.cloud.KubernetesServiceCallServiceDiscoveryConfiguration; +import org.apache.camel.model.cloud.PassThroughServiceCallServiceFilterConfiguration; +import org.apache.camel.model.cloud.ServiceCallConfiguration; +import org.apache.camel.model.cloud.ServiceCallConfigurationDefinition; +import org.apache.camel.model.cloud.ServiceCallDefinition; +import org.apache.camel.model.cloud.ServiceCallExpressionConfiguration; +import org.apache.camel.model.cloud.ServiceCallServiceChooserConfiguration; +import org.apache.camel.model.cloud.ServiceCallServiceDiscoveryConfiguration; +import org.apache.camel.model.cloud.ServiceCallServiceFilterConfiguration; +import org.apache.camel.model.cloud.ServiceCallServiceLoadBalancerConfiguration; +import org.apache.camel.model.cloud.StaticServiceCallServiceDiscoveryConfiguration; +import org.apache.camel.model.cloud.ZooKeeperServiceCallServiceDiscoveryConfiguration; import org.apache.camel.model.config.BatchResequencerConfig; -import org.apache.camel.model.config.ResequencerConfig; import org.apache.camel.model.config.StreamResequencerConfig; -import org.apache.camel.model.dataformat.*; -import org.apache.camel.model.errorhandler.*; -import org.apache.camel.model.language.*; -import org.apache.camel.model.loadbalancer.*; -import org.apache.camel.model.rest.*; -import org.apache.camel.model.transformer.*; -import org.apache.camel.model.validator.*; +import org.apache.camel.model.dataformat.ASN1DataFormat; +import org.apache.camel.model.dataformat.Any23DataFormat; +import org.apache.camel.model.dataformat.AvroDataFormat; +import org.apache.camel.model.dataformat.AvroLibrary; +import org.apache.camel.model.dataformat.BarcodeDataFormat; +import org.apache.camel.model.dataformat.Base64DataFormat; +import org.apache.camel.model.dataformat.BindyDataFormat; +import org.apache.camel.model.dataformat.CBORDataFormat; +import org.apache.camel.model.dataformat.CryptoDataFormat; +import org.apache.camel.model.dataformat.CsvDataFormat; +import org.apache.camel.model.dataformat.CustomDataFormat; +import org.apache.camel.model.dataformat.DataFormatsDefinition; +import org.apache.camel.model.dataformat.FhirDataformat; +import org.apache.camel.model.dataformat.FhirJsonDataFormat; +import org.apache.camel.model.dataformat.FhirXmlDataFormat; +import org.apache.camel.model.dataformat.FlatpackDataFormat; +import org.apache.camel.model.dataformat.GrokDataFormat; +import org.apache.camel.model.dataformat.GzipDeflaterDataFormat; +import org.apache.camel.model.dataformat.HL7DataFormat; +import org.apache.camel.model.dataformat.IcalDataFormat; +import org.apache.camel.model.dataformat.JacksonXMLDataFormat; +import org.apache.camel.model.dataformat.JaxbDataFormat; +import org.apache.camel.model.dataformat.JsonApiDataFormat; +import org.apache.camel.model.dataformat.JsonDataFormat; +import org.apache.camel.model.dataformat.JsonLibrary; +import org.apache.camel.model.dataformat.LZFDataFormat; +import org.apache.camel.model.dataformat.MimeMultipartDataFormat; +import org.apache.camel.model.dataformat.PGPDataFormat; +import org.apache.camel.model.dataformat.ProtobufDataFormat; +import org.apache.camel.model.dataformat.ProtobufLibrary; +import org.apache.camel.model.dataformat.RssDataFormat; +import org.apache.camel.model.dataformat.SoapDataFormat; +import org.apache.camel.model.dataformat.SyslogDataFormat; +import org.apache.camel.model.dataformat.TarFileDataFormat; +import org.apache.camel.model.dataformat.ThriftDataFormat; +import org.apache.camel.model.dataformat.TidyMarkupDataFormat; +import org.apache.camel.model.dataformat.UniVocityAbstractDataFormat; +import org.apache.camel.model.dataformat.UniVocityCsvDataFormat; +import org.apache.camel.model.dataformat.UniVocityFixedDataFormat; +import org.apache.camel.model.dataformat.UniVocityHeader; +import org.apache.camel.model.dataformat.UniVocityTsvDataFormat; +import org.apache.camel.model.dataformat.XMLSecurityDataFormat; +import org.apache.camel.model.dataformat.XStreamDataFormat; +import org.apache.camel.model.dataformat.YAMLDataFormat; +import org.apache.camel.model.dataformat.YAMLLibrary; +import org.apache.camel.model.dataformat.YAMLTypeFilterDefinition; +import org.apache.camel.model.dataformat.ZipDeflaterDataFormat; +import org.apache.camel.model.dataformat.ZipFileDataFormat; +import org.apache.camel.model.errorhandler.DeadLetterChannelDefinition; +import org.apache.camel.model.errorhandler.DefaultErrorHandlerDefinition; +import org.apache.camel.model.errorhandler.ErrorHandlerRefDefinition; +import org.apache.camel.model.errorhandler.JtaTransactionErrorHandlerDefinition; +import org.apache.camel.model.errorhandler.NoErrorHandlerDefinition; +import org.apache.camel.model.errorhandler.SpringTransactionErrorHandlerDefinition; +import org.apache.camel.model.errorhandler.TransactionErrorHandlerDefinition; +import org.apache.camel.model.language.CSimpleExpression; +import org.apache.camel.model.language.ConstantExpression; +import org.apache.camel.model.language.DatasonnetExpression; +import org.apache.camel.model.language.ExchangePropertyExpression; +import org.apache.camel.model.language.ExpressionDefinition; +import org.apache.camel.model.language.GroovyExpression; +import org.apache.camel.model.language.HeaderExpression; +import org.apache.camel.model.language.Hl7TerserExpression; +import org.apache.camel.model.language.JoorExpression; +import org.apache.camel.model.language.JqExpression; +import org.apache.camel.model.language.JsonPathExpression; +import org.apache.camel.model.language.LanguageExpression; +import org.apache.camel.model.language.MethodCallExpression; +import org.apache.camel.model.language.MvelExpression; +import org.apache.camel.model.language.NamespaceAwareExpression; +import org.apache.camel.model.language.OgnlExpression; +import org.apache.camel.model.language.RefExpression; +import org.apache.camel.model.language.SimpleExpression; +import org.apache.camel.model.language.SpELExpression; +import org.apache.camel.model.language.TokenizerExpression; +import org.apache.camel.model.language.XMLTokenizerExpression; +import org.apache.camel.model.language.XPathExpression; +import org.apache.camel.model.language.XQueryExpression; +import org.apache.camel.model.loadbalancer.CustomLoadBalancerDefinition; +import org.apache.camel.model.loadbalancer.FailoverLoadBalancerDefinition; +import org.apache.camel.model.loadbalancer.RandomLoadBalancerDefinition; +import org.apache.camel.model.loadbalancer.RoundRobinLoadBalancerDefinition; +import org.apache.camel.model.loadbalancer.StickyLoadBalancerDefinition; +import org.apache.camel.model.loadbalancer.TopicLoadBalancerDefinition; +import org.apache.camel.model.loadbalancer.WeightedLoadBalancerDefinition; +import org.apache.camel.model.rest.ApiKeyDefinition; +import org.apache.camel.model.rest.BasicAuthDefinition; +import org.apache.camel.model.rest.BearerTokenDefinition; +import org.apache.camel.model.rest.CollectionFormat; +import org.apache.camel.model.rest.DeleteDefinition; +import org.apache.camel.model.rest.GetDefinition; +import org.apache.camel.model.rest.HeadDefinition; +import org.apache.camel.model.rest.MutualTLSDefinition; +import org.apache.camel.model.rest.OAuth2Definition; +import org.apache.camel.model.rest.OpenIdConnectDefinition; +import org.apache.camel.model.rest.ParamDefinition; +import org.apache.camel.model.rest.PatchDefinition; +import org.apache.camel.model.rest.PostDefinition; +import org.apache.camel.model.rest.PutDefinition; +import org.apache.camel.model.rest.ResponseHeaderDefinition; +import org.apache.camel.model.rest.ResponseMessageDefinition; +import org.apache.camel.model.rest.RestBindingDefinition; +import org.apache.camel.model.rest.RestBindingMode; +import org.apache.camel.model.rest.RestConfigurationDefinition; +import org.apache.camel.model.rest.RestDefinition; +import org.apache.camel.model.rest.RestHostNameResolver; +import org.apache.camel.model.rest.RestParamType; +import org.apache.camel.model.rest.RestPropertyDefinition; +import org.apache.camel.model.rest.RestSecuritiesDefinition; +import org.apache.camel.model.rest.RestSecurityDefinition; +import org.apache.camel.model.rest.RestsDefinition; +import org.apache.camel.model.rest.SecurityDefinition; +import org.apache.camel.model.rest.VerbDefinition; +import org.apache.camel.model.transformer.CustomTransformerDefinition; +import org.apache.camel.model.transformer.DataFormatTransformerDefinition; +import org.apache.camel.model.transformer.EndpointTransformerDefinition; +import org.apache.camel.model.transformer.TransformerDefinition; +import org.apache.camel.model.transformer.TransformersDefinition; +import org.apache.camel.model.validator.CustomValidatorDefinition; +import org.apache.camel.model.validator.EndpointValidatorDefinition; +import org.apache.camel.model.validator.PredicateValidatorDefinition; +import org.apache.camel.model.validator.ValidatorDefinition; +import org.apache.camel.model.validator.ValidatorsDefinition; import org.apache.camel.xml.io.XmlPullParserException; @SuppressWarnings("unused") @@ -2670,6 +2806,7 @@ public class ModelParser extends BaseParser { case "headerName": def.setHeaderName(val); break; case "option": def.setOption(val); break; case "resultType": def.setResultTypeName(val); break; + case "supportPojoAsMapAndList": def.setSupportPojoAsMapAndList(val); break; case "suppressExceptions": def.setSuppressExceptions(val); break; case "writeAsString": def.setWriteAsString(val); break; default: return expressionDefinitionAttributeHandler().accept(def, key, val);
