This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch vc4
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 3665b8110abcafa4776c25fdc976313de7e87442
Author: Claus Ibsen <claus.ib...@gmail.com>
AuthorDate: Wed Jun 5 16:26:19 2024 +0200

    CAMEL-20832: Add rest-dsl client validator that can use atlassian validator 
in a plugin fashion
---
 bom/camel-bom/pom.xml                              |  5 ++
 catalog/camel-allcomponents/pom.xml                |  5 ++
 .../org/apache/camel/catalog/others.properties     |  1 +
 .../camel/catalog/others/openapi-validator.json    | 15 +++++
 components/camel-openapi-validator/pom.xml         | 70 ++++++++++++++++++++++
 .../services/org/apache/camel/other.properties     |  7 +++
 .../org/apache/camel/rest-client-validator-factory |  2 +
 .../src/generated/resources/openapi-validator.json | 15 +++++
 .../src/main/docs/openapi-validator.adoc           | 19 ++++++
 .../client/OpenApiRestClientRequestValidator.java  | 30 ++++++++++
 .../others/examples/json/openapi-validator.json    |  1 +
 docs/components/modules/others/nav.adoc            |  1 +
 .../modules/others/pages/openapi-validator.adoc    |  1 +
 parent/pom.xml                                     |  6 ++
 14 files changed, 178 insertions(+)

diff --git a/bom/camel-bom/pom.xml b/bom/camel-bom/pom.xml
index 5bfbac4377a..751c5536722 100644
--- a/bom/camel-bom/pom.xml
+++ b/bom/camel-bom/pom.xml
@@ -1532,6 +1532,11 @@
         <artifactId>camel-openapi-rest-dsl-generator</artifactId>
         <version>4.7.0-SNAPSHOT</version>
       </dependency>
+      <dependency>
+        <groupId>org.apache.camel</groupId>
+        <artifactId>camel-openapi-validator</artifactId>
+        <version>4.7.0-SNAPSHOT</version>
+      </dependency>
       <dependency>
         <groupId>org.apache.camel</groupId>
         <artifactId>camel-opensearch</artifactId>
diff --git a/catalog/camel-allcomponents/pom.xml 
b/catalog/camel-allcomponents/pom.xml
index 96f648880e9..b6ad183fa43 100644
--- a/catalog/camel-allcomponents/pom.xml
+++ b/catalog/camel-allcomponents/pom.xml
@@ -1322,6 +1322,11 @@
             <artifactId>camel-openapi-java</artifactId>
             <version>${project.version}</version>
         </dependency>
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-openapi-validator</artifactId>
+            <version>${project.version}</version>
+        </dependency>
         <dependency>
             <groupId>org.apache.camel</groupId>
             <artifactId>camel-opensearch</artifactId>
diff --git 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/others.properties
 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/others.properties
index 9b64a3dd84a..15e1b4bcb33 100644
--- 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/others.properties
+++ 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/others.properties
@@ -35,6 +35,7 @@ microprofile-fault-tolerance
 microprofile-health
 observation
 openapi-java
+openapi-validator
 opentelemetry
 platform-http-jolokia
 platform-http-main
diff --git 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/others/openapi-validator.json
 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/others/openapi-validator.json
new file mode 100644
index 00000000000..4439b1cdd95
--- /dev/null
+++ 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/others/openapi-validator.json
@@ -0,0 +1,15 @@
+{
+  "other": {
+    "kind": "other",
+    "name": "openapi-validator",
+    "title": "Openapi Validator",
+    "description": "OpenAPI validator for Camel Rest DSL",
+    "deprecated": false,
+    "firstVersion": "4.7.0",
+    "label": "rest,api",
+    "supportLevel": "Preview",
+    "groupId": "org.apache.camel",
+    "artifactId": "camel-openapi-validator",
+    "version": "4.7.0-SNAPSHOT"
+  }
+}
diff --git a/components/camel-openapi-validator/pom.xml 
b/components/camel-openapi-validator/pom.xml
new file mode 100644
index 00000000000..da01b0cb916
--- /dev/null
+++ b/components/camel-openapi-validator/pom.xml
@@ -0,0 +1,70 @@
+<?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/maven-v4_0_0.xsd";>
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.camel</groupId>
+        <artifactId>components</artifactId>
+        <version>4.7.0-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>camel-openapi-validator</artifactId>
+    <packaging>jar</packaging>
+    <name>Camel :: OpenAPI :: Validator</name>
+    <description>OpenAPI validator for Camel Rest DSL</description>
+
+    <properties>
+        <firstVersion>4.7.0</firstVersion>
+        <label>rest,api</label>
+    </properties>
+
+    <dependencies>
+
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-support</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>com.atlassian.oai</groupId>
+            <artifactId>swagger-request-validator-core</artifactId>
+            <version>${swagger-request-validator-version}</version>
+        </dependency>
+
+        <!-- testing -->
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-test-junit5</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-mock</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.junit.jupiter</groupId>
+            <artifactId>junit-jupiter</artifactId>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+</project>
diff --git 
a/components/camel-openapi-validator/src/generated/resources/META-INF/services/org/apache/camel/other.properties
 
b/components/camel-openapi-validator/src/generated/resources/META-INF/services/org/apache/camel/other.properties
new file mode 100644
index 00000000000..9f935a73b63
--- /dev/null
+++ 
b/components/camel-openapi-validator/src/generated/resources/META-INF/services/org/apache/camel/other.properties
@@ -0,0 +1,7 @@
+# Generated by camel build tools - do NOT edit this file!
+name=openapi-validator
+groupId=org.apache.camel
+artifactId=camel-openapi-validator
+version=4.7.0-SNAPSHOT
+projectName=Camel :: OpenAPI :: Validator
+projectDescription=OpenAPI validator for Camel Rest DSL
diff --git 
a/components/camel-openapi-validator/src/generated/resources/META-INF/services/org/apache/camel/rest-client-validator-factory
 
b/components/camel-openapi-validator/src/generated/resources/META-INF/services/org/apache/camel/rest-client-validator-factory
new file mode 100644
index 00000000000..d8d8016f187
--- /dev/null
+++ 
b/components/camel-openapi-validator/src/generated/resources/META-INF/services/org/apache/camel/rest-client-validator-factory
@@ -0,0 +1,2 @@
+# Generated by camel build tools - do NOT edit this file!
+class=org.apache.camel.component.rest.openapi.validator.client.OpenApiRestClientRequestValidator
diff --git 
a/components/camel-openapi-validator/src/generated/resources/openapi-validator.json
 
b/components/camel-openapi-validator/src/generated/resources/openapi-validator.json
new file mode 100644
index 00000000000..4439b1cdd95
--- /dev/null
+++ 
b/components/camel-openapi-validator/src/generated/resources/openapi-validator.json
@@ -0,0 +1,15 @@
+{
+  "other": {
+    "kind": "other",
+    "name": "openapi-validator",
+    "title": "Openapi Validator",
+    "description": "OpenAPI validator for Camel Rest DSL",
+    "deprecated": false,
+    "firstVersion": "4.7.0",
+    "label": "rest,api",
+    "supportLevel": "Preview",
+    "groupId": "org.apache.camel",
+    "artifactId": "camel-openapi-validator",
+    "version": "4.7.0-SNAPSHOT"
+  }
+}
diff --git 
a/components/camel-openapi-validator/src/main/docs/openapi-validator.adoc 
b/components/camel-openapi-validator/src/main/docs/openapi-validator.adoc
new file mode 100644
index 00000000000..cc939abb2ce
--- /dev/null
+++ b/components/camel-openapi-validator/src/main/docs/openapi-validator.adoc
@@ -0,0 +1,19 @@
+= Openapi Validator Component
+:doctitle: Openapi Validator
+:shortname: openapi-validator
+:artifactid: camel-openapi-validator
+:description: OpenAPI validator for Camel Rest DSL
+:since: 4.7
+:supportlevel: Preview
+:tabs-sync-option:
+
+*Since Camel {since}*
+
+The OpenAPI Validator component is used for plugin a OpenAPI specific client 
request validator
+for the Camel Rest DSL.
+
+This validator uses the 
https://bitbucket.org/atlassian/swagger-request-validator/src/master/[Atlassian 
Swagger Request Validator].
+
+== Auto-detection from classpath
+
+To use this implementation all you need to do is to add the 
`camel-openapi-validator` dependency to the classpath.
diff --git 
a/components/camel-openapi-validator/src/main/java/org/apache/camel/component/rest/openapi/validator/client/OpenApiRestClientRequestValidator.java
 
b/components/camel-openapi-validator/src/main/java/org/apache/camel/component/rest/openapi/validator/client/OpenApiRestClientRequestValidator.java
new file mode 100644
index 00000000000..7c8c37fff76
--- /dev/null
+++ 
b/components/camel-openapi-validator/src/main/java/org/apache/camel/component/rest/openapi/validator/client/OpenApiRestClientRequestValidator.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.component.rest.openapi.validator.client;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.spi.RestClientRequestValidator;
+import org.apache.camel.spi.annotations.JdkService;
+
+@JdkService(RestClientRequestValidator.FACTORY)
+public class OpenApiRestClientRequestValidator implements 
RestClientRequestValidator{
+
+    @Override
+    public ValidationError validate(Exchange exchange, ValidationContext 
validationContent) {
+        return null;
+    }
+}
diff --git 
a/docs/components/modules/others/examples/json/openapi-validator.json 
b/docs/components/modules/others/examples/json/openapi-validator.json
new file mode 120000
index 00000000000..84ddb3ecd63
--- /dev/null
+++ b/docs/components/modules/others/examples/json/openapi-validator.json
@@ -0,0 +1 @@
+../../../../../../components/camel-openapi-validator/src/generated/resources/openapi-validator.json
\ No newline at end of file
diff --git a/docs/components/modules/others/nav.adoc 
b/docs/components/modules/others/nav.adoc
index eadda6ee2ae..3dc86d9b5cd 100644
--- a/docs/components/modules/others/nav.adoc
+++ b/docs/components/modules/others/nav.adoc
@@ -38,6 +38,7 @@
 ** xref:microprofile-fault-tolerance.adoc[Microprofile Fault Tolerance]
 ** xref:microprofile-health.adoc[Microprofile Health]
 ** xref:openapi-java.adoc[Openapi Java]
+** xref:openapi-validator.adoc[Openapi Validator]
 ** xref:opentelemetry.adoc[OpenTelemetry]
 ** xref:platform-http-main.adoc[Platform Http Main]
 ** xref:platform-http-vertx.adoc[Platform Http Vertx]
diff --git a/docs/components/modules/others/pages/openapi-validator.adoc 
b/docs/components/modules/others/pages/openapi-validator.adoc
new file mode 120000
index 00000000000..a492e8a124c
--- /dev/null
+++ b/docs/components/modules/others/pages/openapi-validator.adoc
@@ -0,0 +1 @@
+../../../../../components/camel-openapi-validator/src/main/docs/openapi-validator.adoc
\ No newline at end of file
diff --git a/parent/pom.xml b/parent/pom.xml
index fe6452de994..748e01fa640 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -462,6 +462,7 @@
         <swagger-openapi3-version>2.2.22</swagger-openapi3-version>
         <swagger-java-parser-version>1.0.65</swagger-java-parser-version>
         
<swagger-openapi3-java-parser-version>2.1.22</swagger-openapi3-java-parser-version>
+        
<swagger-request-validator-version>2.24.0</swagger-request-validator-version>
         <stax-api-version>1.0.1</stax-api-version>
         <stringtemplate-version>4.3.4</stringtemplate-version>
         <testcontainers-version>1.19.8</testcontainers-version>
@@ -1940,6 +1941,11 @@
                 <artifactId>camel-openapi-java</artifactId>
                 <version>${project.version}</version>
             </dependency>
+            <dependency>
+                <groupId>org.apache.camel</groupId>
+                <artifactId>camel-openapi-validator</artifactId>
+                <version>${project.version}</version>
+            </dependency>
             <dependency>
                 <groupId>org.apache.camel</groupId>
                 <artifactId>camel-opensearch</artifactId>

Reply via email to