This is an automated email from the ASF dual-hosted git repository.
jamesnetherton pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
The following commit(s) were added to refs/heads/main by this push:
new 07ca6e5f829 Fixes #9550. Add camel-quarkus-xsd-json extension
07ca6e5f829 is described below
commit 07ca6e5f8296465e7bde4c31ab70c2a1dbf15759
Author: James Netherton <[email protected]>
AuthorDate: Thu Dec 3 16:46:53 2026 +0000
Fixes #9550. Add camel-quarkus-xsd-json extension
Adds JVM and native support for the xsdJson data format introduced in
Camel 4.24. quarkus-jaxp is included so that XML parser error messages
are available in native mode.
Co-authored-by: Claude Opus 5.5 <[email protected]>
---
catalog/pom.xml | 13 ++
docs/modules/ROOT/examples/dataformats/xsdJson.yml | 13 ++
docs/modules/ROOT/nav.adoc | 1 +
.../ROOT/pages/reference/extensions/xsd-json.adoc | 61 +++++++
extensions/pom.xml | 1 +
extensions/xsd-json/deployment/pom.xml | 67 ++++++++
.../xsd/json/deployment/XsdJsonProcessor.java | 30 ++++
extensions/xsd-json/pom.xml | 39 +++++
extensions/xsd-json/runtime/pom.xml | 105 +++++++++++
.../xsd-json/runtime/src/main/doc/usage.adoc | 11 ++
.../main/resources/META-INF/quarkus-extension.yaml | 36 ++++
integration-tests/pom.xml | 1 +
integration-tests/xsd-json/pom.xml | 129 ++++++++++++++
.../component/xsd/json/it/XsdJsonResource.java | 91 ++++++++++
.../component/xsd/json/it/XsdJsonRoutes.java | 70 ++++++++
.../src/main/resources/application.properties | 18 ++
.../src/main/resources/xsd-json/common/common.xsd | 29 ++++
.../src/main/resources/xsd-json/doctype.xsd | 23 +++
.../src/main/resources/xsd-json/orders.wsdl | 57 ++++++
.../xsd-json/src/main/resources/xsd-json/shop.xsd | 47 +++++
.../quarkus/component/xsd/json/it/XsdJsonIT.java | 24 +++
.../quarkus/component/xsd/json/it/XsdJsonTest.java | 191 +++++++++++++++++++++
poms/bom/pom.xml | 15 ++
poms/bom/src/main/generated/flattened-full-pom.xml | 15 ++
.../src/main/generated/flattened-reduced-pom.xml | 15 ++
.../generated/flattened-reduced-verbose-pom.xml | 15 ++
tooling/scripts/test-categories.yaml | 1 +
27 files changed, 1118 insertions(+)
diff --git a/catalog/pom.xml b/catalog/pom.xml
index 3539fc95148..d2655d88d88 100644
--- a/catalog/pom.xml
+++ b/catalog/pom.xml
@@ -4673,6 +4673,19 @@
</exclusion>
</exclusions>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-xsd-json</artifactId>
+ <version>${project.version}</version>
+ <type>pom</type>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>*</groupId>
+ <artifactId>*</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-xslt</artifactId>
diff --git a/docs/modules/ROOT/examples/dataformats/xsdJson.yml
b/docs/modules/ROOT/examples/dataformats/xsdJson.yml
new file mode 100644
index 00000000000..103f64d2c3b
--- /dev/null
+++ b/docs/modules/ROOT/examples/dataformats/xsdJson.yml
@@ -0,0 +1,13 @@
+# Do not edit directly!
+# This file was generated by
camel-quarkus-maven-plugin:update-extension-doc-page
+cqArtifactId: camel-quarkus-xsd-json
+cqArtifactIdBase: xsd-json
+cqNativeSupported: true
+cqStatus: Stable
+cqDeprecated: false
+cqJvmSince: 4.0.0
+cqNativeSince: 4.0.0
+cqCamelPartName: xsdJson
+cqCamelPartTitle: XSD JSON
+cqCamelPartDescription: Unmarshal XML to JSON and marshal JSON to XML, driven
by an XML Schema (an XSD, or the types of a WSDL), which gives the types,
arrays, order and namespaces.
+cqExtensionPageTitle: XSD JSON
diff --git a/docs/modules/ROOT/nav.adoc b/docs/modules/ROOT/nav.adoc
index 0d69d03b216..a33d75a48d4 100644
--- a/docs/modules/ROOT/nav.adoc
+++ b/docs/modules/ROOT/nav.adoc
@@ -357,6 +357,7 @@
*** xref:reference/extensions/xmpp.adoc[XMPP]
*** xref:reference/extensions/xpath.adoc[XPath]
*** xref:reference/extensions/saxon.adoc[XQuery]
+*** xref:reference/extensions/xsd-json.adoc[XSD JSON]
*** xref:reference/extensions/xslt.adoc[XSLT]
*** xref:reference/extensions/xslt-saxon.adoc[XSLT Saxon]
*** xref:reference/extensions/yaml-dsl.adoc[YAML DSL]
diff --git a/docs/modules/ROOT/pages/reference/extensions/xsd-json.adoc
b/docs/modules/ROOT/pages/reference/extensions/xsd-json.adoc
new file mode 100644
index 00000000000..a3acba74c20
--- /dev/null
+++ b/docs/modules/ROOT/pages/reference/extensions/xsd-json.adoc
@@ -0,0 +1,61 @@
+// Do not edit directly!
+// This file was generated by
camel-quarkus-maven-plugin:update-extension-doc-page
+[id="extensions-xsd-json"]
+= XSD JSON
+:linkattrs:
+:cq-artifact-id: camel-quarkus-xsd-json
+:cq-native-supported: true
+:cq-status: Stable
+:cq-status-deprecation: Stable
+:cq-description: Unmarshal XML to JSON and marshal JSON to XML, driven by an
XML Schema (an XSD, or the types of a WSDL), which gives the types, arrays,
order and namespaces.
+:cq-deprecated: false
+:cq-jvm-since: 4.0.0
+:cq-native-since: 4.0.0
+
+ifeval::[{doc-show-badges} == true]
+[.badges]
+[.badge-key]##JVM since##[.badge-supported]##4.0.0## [.badge-key]##Native
since##[.badge-supported]##4.0.0##
+endif::[]
+
+Unmarshal XML to JSON and marshal JSON to XML, driven by an XML Schema (an
XSD, or the types of a WSDL), which gives the types, arrays, order and
namespaces.
+
+[id="extensions-xsd-json-whats-inside"]
+== What's inside
+
+* xref:{cq-camel-components}:dataformats:xsdJson-dataformat.adoc[XSD JSON data
format]
+
+Please refer to the above link for usage and configuration details.
+
+[id="extensions-xsd-json-maven-coordinates"]
+== Maven coordinates
+
+https://{link-quarkus-code-generator}/?extension-search=camel-quarkus-xsd-json[Create
a new project with this extension on {link-quarkus-code-generator},
window="_blank"]
+
+Or add the coordinates to your existing project:
+
+[source,xml]
+----
+<dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-xsd-json</artifactId>
+</dependency>
+----
+ifeval::[{doc-show-user-guide-link} == true]
+Check the xref:user-guide/index.adoc[User guide] for more information about
writing Camel Quarkus applications.
+endif::[]
+
+[id="extensions-xsd-json-usage"]
+== Usage
+[id="extensions-xsd-json-usage-schemas-in-native-mode"]
+=== Schemas in native mode
+
+When the `schema` option refers to the classpath, the schema must be included
in the native image. This also applies to any schemas that it imports or
includes.
+For example, in `application.properties`:
+
+[source,properties]
+----
+quarkus.native.resources.includes = schemas/*.wsdl,schemas/*.xsd
+----
+
+More information about selecting resources for inclusion in the native image
can be found in the
xref:user-guide/native-mode.adoc#embedding-resource-in-native-executable[native
mode user guide].
+
diff --git a/extensions/pom.xml b/extensions/pom.xml
index 203ef612268..a6ab513ef6a 100644
--- a/extensions/pom.xml
+++ b/extensions/pom.xml
@@ -298,6 +298,7 @@
<module>xj</module>
<module>xmlsecurity</module>
<module>xpath</module>
+ <module>xsd-json</module>
<module>xslt</module>
<module>xslt-saxon</module>
<module>zendesk</module>
diff --git a/extensions/xsd-json/deployment/pom.xml
b/extensions/xsd-json/deployment/pom.xml
new file mode 100644
index 00000000000..e082422b08e
--- /dev/null
+++ b/extensions/xsd-json/deployment/pom.xml
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-xsd-json-parent</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>camel-quarkus-xsd-json-deployment</artifactId>
+ <name>Camel Quarkus :: XSD JSON :: Deployment</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-jaxp-deployment</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-core-deployment</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-xsd-json</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <annotationProcessorPaths>
+ <path>
+ <groupId>io.quarkus</groupId>
+
<artifactId>quarkus-extension-processor</artifactId>
+ <version>${quarkus.version}</version>
+ </path>
+ </annotationProcessorPaths>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git
a/extensions/xsd-json/deployment/src/main/java/org/apache/camel/quarkus/component/xsd/json/deployment/XsdJsonProcessor.java
b/extensions/xsd-json/deployment/src/main/java/org/apache/camel/quarkus/component/xsd/json/deployment/XsdJsonProcessor.java
new file mode 100644
index 00000000000..59e5f34f880
--- /dev/null
+++
b/extensions/xsd-json/deployment/src/main/java/org/apache/camel/quarkus/component/xsd/json/deployment/XsdJsonProcessor.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.xsd.json.deployment;
+
+import io.quarkus.deployment.annotations.BuildStep;
+import io.quarkus.deployment.builditem.FeatureBuildItem;
+
+class XsdJsonProcessor {
+
+ private static final String FEATURE = "camel-xsd-json";
+
+ @BuildStep
+ FeatureBuildItem feature() {
+ return new FeatureBuildItem(FEATURE);
+ }
+}
diff --git a/extensions/xsd-json/pom.xml b/extensions/xsd-json/pom.xml
new file mode 100644
index 00000000000..791c4ce732a
--- /dev/null
+++ b/extensions/xsd-json/pom.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-extensions</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>camel-quarkus-xsd-json-parent</artifactId>
+ <name>Camel Quarkus :: XSD JSON</name>
+ <packaging>pom</packaging>
+
+ <modules>
+ <module>deployment</module>
+ <module>runtime</module>
+ </modules>
+</project>
diff --git a/extensions/xsd-json/runtime/pom.xml
b/extensions/xsd-json/runtime/pom.xml
new file mode 100644
index 00000000000..a20bb03dd02
--- /dev/null
+++ b/extensions/xsd-json/runtime/pom.xml
@@ -0,0 +1,105 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-xsd-json-parent</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>camel-quarkus-xsd-json</artifactId>
+ <name>Camel Quarkus :: XSD JSON :: Runtime</name>
+ <description>Unmarshal XML to JSON and marshal JSON to XML, driven by an
XML Schema (an XSD, or the types of a WSDL), which gives the types, arrays,
order and namespaces.</description>
+
+ <properties>
+ <camel.quarkus.jvmSince>4.0.0</camel.quarkus.jvmSince>
+ <camel.quarkus.nativeSince>4.0.0</camel.quarkus.nativeSince>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-jaxp</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-xsd-json</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-extension-maven-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <annotationProcessorPaths>
+ <path>
+ <groupId>io.quarkus</groupId>
+
<artifactId>quarkus-extension-processor</artifactId>
+ <version>${quarkus.version}</version>
+ </path>
+ </annotationProcessorPaths>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+
+ <profiles>
+ <profile>
+ <id>full</id>
+ <activation>
+ <property>
+ <name>!quickly</name>
+ </property>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>update-extension-doc-page</id>
+ <goals>
+ <goal>update-extension-doc-page</goal>
+ </goals>
+ <phase>process-classes</phase>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+</project>
diff --git a/extensions/xsd-json/runtime/src/main/doc/usage.adoc
b/extensions/xsd-json/runtime/src/main/doc/usage.adoc
new file mode 100644
index 00000000000..84ee9f45dcb
--- /dev/null
+++ b/extensions/xsd-json/runtime/src/main/doc/usage.adoc
@@ -0,0 +1,11 @@
+=== Schemas in native mode
+
+When the `schema` option refers to the classpath, the schema must be included
in the native image. This also applies to any schemas that it imports or
includes.
+For example, in `application.properties`:
+
+[source,properties]
+----
+quarkus.native.resources.includes = schemas/*.wsdl,schemas/*.xsd
+----
+
+More information about selecting resources for inclusion in the native image
can be found in the
xref:user-guide/native-mode.adoc#embedding-resource-in-native-executable[native
mode user guide].
diff --git
a/extensions/xsd-json/runtime/src/main/resources/META-INF/quarkus-extension.yaml
b/extensions/xsd-json/runtime/src/main/resources/META-INF/quarkus-extension.yaml
new file mode 100644
index 00000000000..eea8dd50cec
--- /dev/null
+++
b/extensions/xsd-json/runtime/src/main/resources/META-INF/quarkus-extension.yaml
@@ -0,0 +1,36 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# This is a generated file. Do not edit directly!
+# To re-generate, run the following command from the top level directory:
+#
+# mvn -N cq:update-quarkus-metadata
+#
+---
+name: "Camel XSD JSON"
+description: "Unmarshal XML to JSON and marshal JSON to XML, driven by an XML
Schema (an XSD, or the types of a WSDL), which gives the types, arrays, order
and namespaces"
+metadata:
+ icon-url:
"https://raw.githubusercontent.com/apache/camel-website/main/antora-ui-camel/src/img/logo-d.svg"
+ sponsor: "Apache Software Foundation"
+ guide:
"https://camel.apache.org/camel-quarkus/latest/reference/extensions/xsd-json.html"
+ categories:
+ - "integration"
+ status: "preview"
+ integrates:
+ - name: "Camel"
+ artifact: "org.apache.camel:camel-base"
+ version: "${camel.version}"
\ No newline at end of file
diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml
index 2c442f077eb..7cdc586cb25 100644
--- a/integration-tests/pom.xml
+++ b/integration-tests/pom.xml
@@ -274,6 +274,7 @@
<module>xml-jaxp</module>
<module>xmlsecurity</module>
<module>xpath</module>
+ <module>xsd-json</module>
<module>xslt-saxon</module>
<module>zendesk</module>
</modules>
diff --git a/integration-tests/xsd-json/pom.xml
b/integration-tests/xsd-json/pom.xml
new file mode 100644
index 00000000000..64ed0b57a2b
--- /dev/null
+++ b/integration-tests/xsd-json/pom.xml
@@ -0,0 +1,129 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-build-parent-it</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ <relativePath>../../poms/build-parent-it/pom.xml</relativePath>
+ </parent>
+
+ <artifactId>camel-quarkus-integration-test-xsd-json</artifactId>
+ <name>Camel Quarkus :: Integration Tests :: XSD JSON</name>
+ <description>Integration tests for Camel Quarkus XSD JSON
extension</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-xsd-json</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-direct</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-resteasy</artifactId>
+ </dependency>
+
+ <!-- test dependencies -->
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>io.rest-assured</groupId>
+ <artifactId>rest-assured</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <profiles>
+ <profile>
+ <id>native</id>
+ <activation>
+ <property>
+ <name>native</name>
+ </property>
+ </activation>
+ <properties>
+ <quarkus.native.enabled>true</quarkus.native.enabled>
+ </properties>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-failsafe-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>integration-test</goal>
+ <goal>verify</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ <profile>
+ <id>virtualDependencies</id>
+ <activation>
+ <property>
+ <name>!noVirtualDependencies</name>
+ </property>
+ </activation>
+ <dependencies>
+ <!-- The following dependencies guarantee that this module is
built after them. You can update them by running `mvn process-resources
-Pformat -N` from the source tree root directory -->
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-direct-deployment</artifactId>
+ <version>${project.version}</version>
+ <type>pom</type>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>*</groupId>
+ <artifactId>*</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-xsd-json-deployment</artifactId>
+ <version>${project.version}</version>
+ <type>pom</type>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>*</groupId>
+ <artifactId>*</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ </dependencies>
+ </profile>
+ </profiles>
+
+</project>
diff --git
a/integration-tests/xsd-json/src/main/java/org/apache/camel/quarkus/component/xsd/json/it/XsdJsonResource.java
b/integration-tests/xsd-json/src/main/java/org/apache/camel/quarkus/component/xsd/json/it/XsdJsonResource.java
new file mode 100644
index 00000000000..082597f8a28
--- /dev/null
+++
b/integration-tests/xsd-json/src/main/java/org/apache/camel/quarkus/component/xsd/json/it/XsdJsonResource.java
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.xsd.json.it;
+
+import jakarta.enterprise.context.ApplicationScoped;
+import jakarta.inject.Inject;
+import jakarta.ws.rs.Consumes;
+import jakarta.ws.rs.POST;
+import jakarta.ws.rs.Path;
+import jakarta.ws.rs.PathParam;
+import jakarta.ws.rs.Produces;
+import jakarta.ws.rs.QueryParam;
+import jakarta.ws.rs.core.MediaType;
+import jakarta.ws.rs.core.Response;
+import org.apache.camel.CamelContext;
+import org.apache.camel.CamelExecutionException;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.dataformat.xsdjson.XsdJsonDataFormat;
+
+@Path("/xsd-json")
+@ApplicationScoped
+public class XsdJsonResource {
+
+ @Inject
+ CamelContext context;
+
+ @Inject
+ ProducerTemplate producerTemplate;
+
+ @Path("/{route}")
+ @POST
+ @Consumes(MediaType.TEXT_PLAIN)
+ @Produces(MediaType.TEXT_PLAIN)
+ public Response process(@PathParam("route") String route,
@QueryParam("element") String element, String body) {
+ try {
+ return Response.ok(
+ producerTemplate.requestBodyAndHeader("direct:" + route,
body, XsdJsonDataFormat.ELEMENT, element,
+ String.class))
+ .build();
+ } catch (CamelExecutionException e) {
+ return
Response.serverError().entity(e.getCause().getMessage()).build();
+ }
+ }
+
+ /**
+ * Unmarshals with a schema that is only known at runtime.
+ */
+ @Path("/dynamic/unmarshal")
+ @POST
+ @Consumes(MediaType.TEXT_PLAIN)
+ @Produces(MediaType.TEXT_PLAIN)
+ public Response dynamicUnmarshal(@QueryParam("schema") String schema,
String body) throws Exception {
+ String routeId = "dynamic-unmarshal";
+ try {
+ context.addRoutes(new RouteBuilder() {
+ @Override
+ public void configure() {
+ from("direct:dynamic-unmarshal").routeId(routeId)
+ .unmarshal().xsdJson(schema);
+ }
+ });
+ return
Response.ok(producerTemplate.requestBody("direct:dynamic-unmarshal", body,
String.class)).build();
+ } catch (Exception e) {
+ Throwable cause = e;
+ while (cause.getCause() != null && !(cause instanceof
IllegalArgumentException)) {
+ cause = cause.getCause();
+ }
+ return
Response.serverError().entity(String.valueOf(cause.getMessage())).build();
+ } finally {
+ if (context.getRoute(routeId) != null) {
+ context.getRouteController().stopRoute(routeId);
+ }
+ context.removeRoute(routeId);
+ }
+ }
+}
diff --git
a/integration-tests/xsd-json/src/main/java/org/apache/camel/quarkus/component/xsd/json/it/XsdJsonRoutes.java
b/integration-tests/xsd-json/src/main/java/org/apache/camel/quarkus/component/xsd/json/it/XsdJsonRoutes.java
new file mode 100644
index 00000000000..dda7afdcde4
--- /dev/null
+++
b/integration-tests/xsd-json/src/main/java/org/apache/camel/quarkus/component/xsd/json/it/XsdJsonRoutes.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.xsd.json.it;
+
+import org.apache.camel.builder.RouteBuilder;
+
+public class XsdJsonRoutes extends RouteBuilder {
+
+ private static final String WSDL = "classpath:xsd-json/orders.wsdl";
+ private static final String XSD = "classpath:xsd-json/shop.xsd";
+
+ @Override
+ public void configure() {
+ from("direct:wsdl-unmarshal")
+ .unmarshal().xsdJson(WSDL);
+
+ from("direct:wsdl-marshal")
+
.marshal(dataFormat().xsdJson().schema(WSDL).element("getOrder").end())
+ .convertBodyTo(String.class);
+
+ from("direct:wsdl-unmarshal-include-root")
+
.unmarshal(dataFormat().xsdJson().schema(WSDL).includeRoot(true).end());
+
+ from("direct:wsdl-marshal-include-root")
+
.marshal(dataFormat().xsdJson().schema(WSDL).includeRoot(true).end())
+ .convertBodyTo(String.class);
+
+ from("direct:xsd-unmarshal")
+ .unmarshal().xsdJson(XSD);
+
+ from("direct:xsd-marshal")
+
.marshal(dataFormat().xsdJson().schema(XSD).element("{urn:shop}order").end())
+ .convertBodyTo(String.class);
+
+ from("direct:xsd-unmarshal-custom-names")
+
.unmarshal(dataFormat().xsdJson().schema(XSD).attributePrefix("_").textName("text").end());
+
+ from("direct:xsd-marshal-custom-names")
+
.marshal(dataFormat().xsdJson().schema(XSD).element("order").attributePrefix("_").textName("text").end())
+ .convertBodyTo(String.class);
+
+ from("direct:wsdl-unmarshal-ignore-unknown")
+
.unmarshal(dataFormat().xsdJson().schema(WSDL).ignoreUnknown(true).end());
+
+ from("direct:wsdl-marshal-ignore-unknown")
+
.marshal(dataFormat().xsdJson().schema(WSDL).element("getOrder").ignoreUnknown(true).end())
+ .convertBodyTo(String.class);
+
+ from("direct:wsdl-unmarshal-pretty-print")
+
.unmarshal(dataFormat().xsdJson().schema(WSDL).prettyPrint(true).end());
+
+ from("direct:wsdl-marshal-pretty-print")
+
.marshal(dataFormat().xsdJson().schema(WSDL).element("getOrder").prettyPrint(true).end())
+ .convertBodyTo(String.class);
+ }
+}
diff --git
a/integration-tests/xsd-json/src/main/resources/application.properties
b/integration-tests/xsd-json/src/main/resources/application.properties
new file mode 100644
index 00000000000..71d905c8b96
--- /dev/null
+++ b/integration-tests/xsd-json/src/main/resources/application.properties
@@ -0,0 +1,18 @@
+## ---------------------------------------------------------------------------
+## Licensed to the Apache Software Foundation (ASF) under one or more
+## contributor license agreements. See the NOTICE file distributed with
+## this work for additional information regarding copyright ownership.
+## The ASF licenses this file to You under the Apache License, Version 2.0
+## (the "License"); you may not use this file except in compliance with
+## the License. You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+## ---------------------------------------------------------------------------
+
+quarkus.native.resources.includes=xsd-json/*.wsdl,xsd-json/**/*.xsd
diff --git
a/integration-tests/xsd-json/src/main/resources/xsd-json/common/common.xsd
b/integration-tests/xsd-json/src/main/resources/xsd-json/common/common.xsd
new file mode 100644
index 00000000000..d9c366d455c
--- /dev/null
+++ b/integration-tests/xsd-json/src/main/resources/xsd-json/common/common.xsd
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="urn:common">
+ <xs:element name="address">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="street" type="xs:string"/>
+ </xs:sequence>
+ <xs:attribute name="country" type="xs:string"/>
+ </xs:complexType>
+ </xs:element>
+</xs:schema>
diff --git a/integration-tests/xsd-json/src/main/resources/xsd-json/doctype.xsd
b/integration-tests/xsd-json/src/main/resources/xsd-json/doctype.xsd
new file mode 100644
index 00000000000..a7558dc9701
--- /dev/null
+++ b/integration-tests/xsd-json/src/main/resources/xsd-json/doctype.xsd
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<!DOCTYPE xs:schema [<!ENTITY name "root">]>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <xs:element name="root" type="xs:string"/>
+</xs:schema>
diff --git a/integration-tests/xsd-json/src/main/resources/xsd-json/orders.wsdl
b/integration-tests/xsd-json/src/main/resources/xsd-json/orders.wsdl
new file mode 100644
index 00000000000..1498411d243
--- /dev/null
+++ b/integration-tests/xsd-json/src/main/resources/xsd-json/orders.wsdl
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<wsdl:definitions name="OrderService"
+ targetNamespace="http://example.com/orders"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:tns="http://example.com/orders">
+ <wsdl:types>
+ <xs:schema targetNamespace="http://example.com/orders"
elementFormDefault="qualified">
+ <xs:complexType name="Item">
+ <xs:sequence>
+ <xs:element name="sku" type="xs:string"/>
+ <xs:element name="quantity" type="xs:int"/>
+ <xs:element name="price" type="xs:decimal"/>
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType name="Order">
+ <xs:sequence>
+ <xs:element name="orderId" type="xs:string"/>
+ <xs:element name="customer" type="xs:string"/>
+ <xs:element name="item" type="tns:Item"
maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType name="OrderRef">
+ <xs:sequence>
+ <xs:element name="orderId" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+ <xs:element name="getOrder" type="tns:OrderRef"/>
+ <xs:element name="orderNotFound" type="tns:OrderRef"/>
+ <xs:element name="getOrderResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="order" type="tns:Order"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:schema>
+ </wsdl:types>
+</wsdl:definitions>
diff --git a/integration-tests/xsd-json/src/main/resources/xsd-json/shop.xsd
b/integration-tests/xsd-json/src/main/resources/xsd-json/shop.xsd
new file mode 100644
index 00000000000..86a55a5bc5f
--- /dev/null
+++ b/integration-tests/xsd-json/src/main/resources/xsd-json/shop.xsd
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:s="urn:shop"
xmlns:c="urn:common"
+ targetNamespace="urn:shop" elementFormDefault="qualified">
+ <xs:import namespace="urn:common" schemaLocation="common/common.xsd"/>
+ <xs:simpleType name="Status">
+ <xs:restriction base="xs:string">
+ <xs:enumeration value="NEW"/>
+ <xs:enumeration value="SHIPPED"/>
+ </xs:restriction>
+ </xs:simpleType>
+ <xs:complexType name="Money">
+ <xs:simpleContent>
+ <xs:extension base="xs:decimal">
+ <xs:attribute name="currency" type="xs:string" use="required"/>
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+ <xs:element name="order">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="status" type="s:Status"/>
+ <xs:element ref="c:address"/>
+ <xs:element name="price" type="s:Money"/>
+ <xs:element name="gift" type="xs:boolean"/>
+ </xs:sequence>
+ <xs:attribute name="version" type="xs:int"/>
+ </xs:complexType>
+ </xs:element>
+</xs:schema>
diff --git
a/integration-tests/xsd-json/src/test/java/org/apache/camel/quarkus/component/xsd/json/it/XsdJsonIT.java
b/integration-tests/xsd-json/src/test/java/org/apache/camel/quarkus/component/xsd/json/it/XsdJsonIT.java
new file mode 100644
index 00000000000..e555d25e5a5
--- /dev/null
+++
b/integration-tests/xsd-json/src/test/java/org/apache/camel/quarkus/component/xsd/json/it/XsdJsonIT.java
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.xsd.json.it;
+
+import io.quarkus.test.junit.QuarkusIntegrationTest;
+
+@QuarkusIntegrationTest
+class XsdJsonIT extends XsdJsonTest {
+
+}
diff --git
a/integration-tests/xsd-json/src/test/java/org/apache/camel/quarkus/component/xsd/json/it/XsdJsonTest.java
b/integration-tests/xsd-json/src/test/java/org/apache/camel/quarkus/component/xsd/json/it/XsdJsonTest.java
new file mode 100644
index 00000000000..59f3636b7c9
--- /dev/null
+++
b/integration-tests/xsd-json/src/test/java/org/apache/camel/quarkus/component/xsd/json/it/XsdJsonTest.java
@@ -0,0 +1,191 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.xsd.json.it;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Map;
+
+import io.quarkus.test.junit.QuarkusTest;
+import io.restassured.RestAssured;
+import io.restassured.http.ContentType;
+import io.restassured.response.ValidatableResponse;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
+
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.endsWith;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.matchesPattern;
+
+@QuarkusTest
+class XsdJsonTest {
+
+ private static final String ORDER_RESPONSE_XML = """
+ <getOrderResponse xmlns="http://example.com/orders"><order>
+ <orderId>42</orderId><customer>Ann</customer>
+
<item><sku>A</sku><quantity>2</quantity><price>9.95</price></item>
+ </order></getOrderResponse>""";
+ private static final String ORDER_RESPONSE_JSON =
"{\"order\":{\"orderId\":\"42\",\"customer\":\"Ann\","
+ + "\"item\":[{\"sku\":\"A\",\"quantity\":2,\"price\":9.95}]}}";
+ private static final String GET_ORDER_XML = "<tns:getOrder
xmlns:tns=\"http://example.com/orders\">"
+ + "<tns:orderId>42</tns:orderId></tns:getOrder>";
+
+ private static final String SHOP_ORDER_XML = "<s:order
xmlns:s=\"urn:shop\" xmlns:c=\"urn:common\" version=\"1\">"
+ + "<s:status>NEW</s:status>"
+ + "<c:address country=\"GB\"><street>High
Street</street></c:address>"
+ + "<s:price currency=\"EUR\">9.95</s:price>"
+ + "<s:gift>true</s:gift>"
+ + "</s:order>";
+ private static final String SHOP_ORDER_JSON =
"{\"version\":1,\"status\":\"NEW\","
+ + "\"address\":{\"country\":\"GB\",\"street\":\"High Street\"},"
+ + "\"price\":{\"currency\":\"EUR\",\"value\":9.95},\"gift\":true}";
+
+ @Test
+ void wsdlUnmarshal() {
+ post("wsdl-unmarshal",
ORDER_RESPONSE_XML).statusCode(200).body(is(ORDER_RESPONSE_JSON));
+ }
+
+ @Test
+ void wsdlMarshal() {
+ post("wsdl-marshal",
"{\"orderId\":\"42\"}").statusCode(200).body(endsWith(GET_ORDER_XML));
+ }
+
+ @Test
+ void wsdlMarshalWithElementHeader() {
+ post("wsdl-marshal", "{\"orderId\":\"43\"}", "element",
"{http://example.com/orders}orderNotFound")
+ .statusCode(200)
+ .body(endsWith("<tns:orderNotFound
xmlns:tns=\"http://example.com/orders\">"
+ +
"<tns:orderId>43</tns:orderId></tns:orderNotFound>"));
+ }
+
+ @Test
+ void wsdlIncludeRoot() {
+ post("wsdl-unmarshal-include-root", GET_ORDER_XML)
+ .statusCode(200)
+ .body(is("{\"getOrder\":{\"orderId\":\"42\"}}"));
+ post("wsdl-marshal-include-root",
"{\"getOrder\":{\"orderId\":\"42\"}}")
+ .statusCode(200)
+ .body(endsWith(GET_ORDER_XML));
+ }
+
+ @Test
+ void xsdWithImportUnmarshal() {
+ post("xsd-unmarshal",
SHOP_ORDER_XML).statusCode(200).body(is(SHOP_ORDER_JSON));
+ }
+
+ @Test
+ void xsdWithImportMarshal() {
+ // JSON fields are written in the order of the schema, so the result
must unmarshal to the same JSON
+ String xml = post("xsd-marshal",
"{\"gift\":true,\"price\":{\"value\":9.95,\"currency\":\"EUR\"},"
+ + "\"address\":{\"street\":\"High
Street\",\"country\":\"GB\"},\"status\":\"NEW\",\"version\":1}")
+ .statusCode(200)
+ .extract().asString();
+ post("xsd-unmarshal", xml).statusCode(200).body(is(SHOP_ORDER_JSON));
+ }
+
+ @Test
+ void undeclaredElementIsRejected() {
+ post("wsdl-unmarshal", "<getOrder
xmlns=\"http://example.com/orders\"><unknown/></getOrder>")
+ .statusCode(500)
+ .body(containsString("unknown"));
+ }
+
+ @Test
+ void undeclaredFieldIsRejected() {
+ post("wsdl-marshal", "{\"orderId\":\"42\",\"unknown\":\"x\"}")
+ .statusCode(500)
+ .body(containsString("unknown"));
+ }
+
+ @Test
+ void ignoreUnknown() {
+ post("wsdl-unmarshal-ignore-unknown", "<getOrder
xmlns=\"http://example.com/orders\" other=\"x\">"
+ + "<unknown>x</unknown><orderId>42</orderId></getOrder>")
+ .statusCode(200)
+ .body(is("{\"orderId\":\"42\"}"));
+ post("wsdl-marshal-ignore-unknown",
"{\"unknown\":\"x\",\"orderId\":\"42\"}")
+ .statusCode(200)
+ .body(endsWith(GET_ORDER_XML));
+ }
+
+ @Test
+ void attributePrefixAndTextName() {
+ String json = post("xsd-unmarshal-custom-names", SHOP_ORDER_XML)
+ .statusCode(200)
+ .body(is("{\"_version\":1,\"status\":\"NEW\","
+ + "\"address\":{\"_country\":\"GB\",\"street\":\"High
Street\"},"
+ +
"\"price\":{\"_currency\":\"EUR\",\"text\":9.95},\"gift\":true}"))
+ .extract().asString();
+ String xml = post("xsd-marshal-custom-names",
json).statusCode(200).extract().asString();
+ post("xsd-unmarshal", xml).statusCode(200).body(is(SHOP_ORDER_JSON));
+ }
+
+ @Test
+ void prettyPrint() {
+ post("wsdl-unmarshal-pretty-print", ORDER_RESPONSE_XML)
+ .statusCode(200)
+
.body(matchesPattern("(?s)\\{\\R\\s+\"order\".*\\R\\s+\"orderId\": ?\"42\".*"));
+ post("wsdl-marshal-pretty-print", "{\"orderId\":\"42\"}")
+ .statusCode(200)
+ .body(matchesPattern("(?s).*<tns:getOrder
[^>]+>\\R\\s+<tns:orderId>42</tns:orderId>\\R</tns:getOrder>\\s*"));
+ }
+
+ @Test
+ void fileSchemaWithImport(@TempDir Path dir) throws IOException {
+ Files.createDirectory(dir.resolve("common"));
+ copySchema("shop.xsd", dir);
+ copySchema("common/common.xsd", dir);
+ // Imports are resolved relative to the last '/' in the schema location
+ String schema = "file:" +
dir.resolve("shop.xsd").toString().replace('\\', '/');
+ post("dynamic/unmarshal", SHOP_ORDER_XML, "schema", schema)
+ .statusCode(200)
+ .body(is(SHOP_ORDER_JSON));
+ }
+
+ @Test
+ void schemaWithDoctypeIsRejected() {
+ post("dynamic/unmarshal", "<root/>", "schema",
"classpath:xsd-json/doctype.xsd")
+ .statusCode(500)
+ .body(containsString("a DOCTYPE is not allowed in a schema"));
+ }
+
+ private static ValidatableResponse post(String path, String body) {
+ return post(path, body, Map.of());
+ }
+
+ private static ValidatableResponse post(String path, String body, String
queryParam, String value) {
+ return post(path, body, Map.of(queryParam, value));
+ }
+
+ private static ValidatableResponse post(String path, String body,
Map<String, String> queryParams) {
+ return RestAssured.given()
+ .contentType(ContentType.TEXT)
+ .queryParams(queryParams)
+ .body(body)
+ .post("/xsd-json/" + path)
+ .then();
+ }
+
+ private static void copySchema(String name, Path dir) throws IOException {
+ try (InputStream in =
XsdJsonTest.class.getResourceAsStream("/xsd-json/" + name)) {
+ Files.copy(in, dir.resolve(name));
+ }
+ }
+}
diff --git a/poms/bom/pom.xml b/poms/bom/pom.xml
index 6f5073631bf..f4b12ff4a20 100644
--- a/poms/bom/pom.xml
+++ b/poms/bom/pom.xml
@@ -3402,6 +3402,11 @@
<artifactId>camel-xpath</artifactId>
<version>${camel.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-xsd-json</artifactId>
+ <version>${camel.version}</version>
+ </dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-xslt</artifactId>
@@ -7042,6 +7047,16 @@
<artifactId>camel-quarkus-xpath-deployment</artifactId>
<version>${camel-quarkus.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-xsd-json</artifactId>
+ <version>${camel-quarkus.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-xsd-json-deployment</artifactId>
+ <version>${camel-quarkus.version}</version>
+ </dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-xslt</artifactId>
diff --git a/poms/bom/src/main/generated/flattened-full-pom.xml
b/poms/bom/src/main/generated/flattened-full-pom.xml
index eee836331c6..9fe597f8b2d 100644
--- a/poms/bom/src/main/generated/flattened-full-pom.xml
+++ b/poms/bom/src/main/generated/flattened-full-pom.xml
@@ -3325,6 +3325,11 @@
<artifactId>camel-xpath</artifactId>
<version>4.24.0</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-xsd-json</artifactId>
+ <version>4.24.0</version>
+ </dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-xslt</artifactId>
@@ -6963,6 +6968,16 @@
<artifactId>camel-quarkus-xpath-deployment</artifactId>
<version>4.0.0-SNAPSHOT</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-xsd-json</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-xsd-json-deployment</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ </dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-xslt</artifactId>
diff --git a/poms/bom/src/main/generated/flattened-reduced-pom.xml
b/poms/bom/src/main/generated/flattened-reduced-pom.xml
index 65f7b9f0276..9300c164571 100644
--- a/poms/bom/src/main/generated/flattened-reduced-pom.xml
+++ b/poms/bom/src/main/generated/flattened-reduced-pom.xml
@@ -4767,6 +4767,11 @@
<artifactId>camel-xpath</artifactId>
<version>4.24.0</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-xsd-json</artifactId>
+ <version>4.24.0</version>
+ </dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-xslt</artifactId>
@@ -8410,6 +8415,16 @@
<artifactId>camel-quarkus-xpath-deployment</artifactId>
<version>4.0.0-SNAPSHOT</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-xsd-json</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-xsd-json-deployment</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ </dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-xslt</artifactId>
diff --git a/poms/bom/src/main/generated/flattened-reduced-verbose-pom.xml
b/poms/bom/src/main/generated/flattened-reduced-verbose-pom.xml
index 3659c23d8ec..4652c7e79d3 100644
--- a/poms/bom/src/main/generated/flattened-reduced-verbose-pom.xml
+++ b/poms/bom/src/main/generated/flattened-reduced-verbose-pom.xml
@@ -4767,6 +4767,11 @@
<artifactId>camel-xpath</artifactId>
<version>4.24.0</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-xsd-json</artifactId>
+ <version>4.24.0</version>
+ </dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-xslt</artifactId>
@@ -8410,6 +8415,16 @@
<artifactId>camel-quarkus-xpath-deployment</artifactId>
<version>4.0.0-SNAPSHOT</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-xsd-json</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-xsd-json-deployment</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ </dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-xslt</artifactId>
diff --git a/tooling/scripts/test-categories.yaml
b/tooling/scripts/test-categories.yaml
index 4b681bb97db..ed4d3e1bc17 100644
--- a/tooling/scripts/test-categories.yaml
+++ b/tooling/scripts/test-categories.yaml
@@ -227,6 +227,7 @@ group-11:
- velocity
- xj
- xml-grouped
+ - xsd-json
- xslt-saxon
group-12:
- ai-resource