This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-spring-boot-examples.git
The following commit(s) were added to refs/heads/main by this push:
new 07b47de CAMEL-22116: Add openapi validator
07b47de is described below
commit 07b47de4a4a0868cff7592e247d440d8f3d324a9
Author: Claus Ibsen <[email protected]>
AuthorDate: Sat May 31 15:15:31 2025 +0200
CAMEL-22116: Add openapi validator
---
openapi-contract-first/pom.xml | 5 +++++
.../src/main/java/sample/petstore/PetStoreRoute.java | 4 +++-
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/openapi-contract-first/pom.xml b/openapi-contract-first/pom.xml
index 61308f9..c130728 100644
--- a/openapi-contract-first/pom.xml
+++ b/openapi-contract-first/pom.xml
@@ -81,6 +81,11 @@
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-rest-openapi-starter</artifactId>
</dependency>
+ <!-- enable validation -->
+ <dependency>
+ <groupId>org.apache.camel.springboot</groupId>
+ <artifactId>camel-openapi-validator-starter</artifactId>
+ </dependency>
<!-- json support -->
<dependency>
<groupId>org.apache.camel.springboot</groupId>
diff --git
a/openapi-contract-first/src/main/java/sample/petstore/PetStoreRoute.java
b/openapi-contract-first/src/main/java/sample/petstore/PetStoreRoute.java
index 7ae3f0f..f7581c1 100644
--- a/openapi-contract-first/src/main/java/sample/petstore/PetStoreRoute.java
+++ b/openapi-contract-first/src/main/java/sample/petstore/PetStoreRoute.java
@@ -37,7 +37,9 @@ public class PetStoreRoute extends RouteBuilder {
public void configure() throws Exception {
// turn on json binding and scan for POJO classes in the model package
restConfiguration().bindingMode(RestBindingMode.json)
- .bindingPackageScan("sample.petstore.model");
+ .bindingPackageScan("sample.petstore.model")
+ // turn on request validation
+ .clientRequestValidation(true);
rest().openApi().specification("petstore.json").missingOperation("ignore");