You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2018/01/15 11:41:48 UTC
[camel] branch master updated: CAMEL-12032: camel-json-validator -
switch to use networknt json parser as it does not use org.json JAR which
is incompatible with ASF licesing.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/master by this push:
new 2ddcf3c CAMEL-12032: camel-json-validator - switch to use networknt json parser as it does not use org.json JAR which is incompatible with ASF licesing.
2ddcf3c is described below
commit 2ddcf3c204f4ff1bc45d488a3b708aadb2c3f4b8
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Mon Jan 15 12:40:02 2018 +0100
CAMEL-12032: camel-json-validator - switch to use networknt json parser as it does not use org.json JAR which is incompatible with ASF licesing.
---
components/camel-json-validator/pom.xml | 16 ++---
.../src/main/docs/json-validator-component.adoc | 6 +-
.../jsonvalidator/DefaultJsonSchemaLoader.java | 17 ++---
.../DefaultJsonValidationErrorHandler.java | 18 ++---
.../component/jsonvalidator/JsonSchemaLoader.java | 12 +---
.../jsonvalidator/JsonValidationException.java | 32 +++++++--
.../jsonvalidator/JsonValidatorEndpoint.java | 47 ++++++------
.../jsonvalidator/JsonValidatorErrorHandler.java | 19 +++--
.../CustomSchemaLoaderValidatorRouteTest.java | 84 ----------------------
.../jsonvalidator/EvenCharNumValidator.java | 38 ----------
.../jsonvalidator/TestCustomSchemaLoader.java | 42 -----------
.../camel/component/jsonvalidator/schema.json | 4 +-
.../component/jsonvalidator/schemawithformat.json | 4 +-
parent/pom.xml | 2 +-
.../karaf/features/src/main/resources/features.xml | 14 ++--
.../camel-json-validator-starter/pom.xml | 16 -----
16 files changed, 102 insertions(+), 269 deletions(-)
diff --git a/components/camel-json-validator/pom.xml b/components/camel-json-validator/pom.xml
index 8d6f774..5d9bc83 100644
--- a/components/camel-json-validator/pom.xml
+++ b/components/camel-json-validator/pom.xml
@@ -26,7 +26,7 @@
<artifactId>camel-json-validator</artifactId>
<name>Camel :: JSON validator</name>
- <description>Camel JSON Schema validation based on Everit JSON-schema library</description>
+ <description>Camel JSON Schema validation based on NetworkNT SON-schema library</description>
<packaging>jar</packaging>
<properties>
@@ -36,13 +36,6 @@
</camel.osgi.export.service>
</properties>
- <!-- everit is distributed in jitpack and not Maven central -->
- <repositories>
- <repository>
- <id>jitpack.io</id>
- <url>https://jitpack.io</url>
- </repository>
- </repositories>
<dependencies>
<dependency>
@@ -50,9 +43,9 @@
<artifactId>camel-core</artifactId>
</dependency>
<dependency>
- <groupId>com.github.everit-org.json-schema</groupId>
- <artifactId>org.everit.json.schema</artifactId>
- <version>${everit-org-json-schema-version}</version>
+ <groupId>com.networknt</groupId>
+ <artifactId>json-schema-validator</artifactId>
+ <version>${networknt-json-schema-validator-version}</version>
</dependency>
<!-- for testing -->
@@ -83,4 +76,5 @@
</dependency>
</dependencies>
+
</project>
diff --git a/components/camel-json-validator/src/main/docs/json-validator-component.adoc b/components/camel-json-validator/src/main/docs/json-validator-component.adoc
index 5b00b1f..a6b29ae 100644
--- a/components/camel-json-validator/src/main/docs/json-validator-component.adoc
+++ b/components/camel-json-validator/src/main/docs/json-validator-component.adoc
@@ -3,8 +3,8 @@
*Available as of Camel version 2.20*
The JSON Schema Validator component performs bean validation of the message body
-agains JSON Schemas using the Everit.org JSON Schema library
-(https://github.com/everit-org/json-schema).
+against JSON Schemas v4 draft using the NetworkNT JSON Schema library
+(https://github.com/networknt/json-schema-validator).
Maven users will need to add the following dependency to their `pom.xml`
for this component:
@@ -84,7 +84,7 @@ Assumed we have the following JSON Schema
{
"$schema": "http://json-schema.org/draft-04/schema#",
"definitions": {},
- "id": "http://example.com/example.json",
+ "id": "my-schema",
"properties": {
"id": {
"default": 1,
diff --git a/components/camel-json-validator/src/main/java/org/apache/camel/component/jsonvalidator/DefaultJsonSchemaLoader.java b/components/camel-json-validator/src/main/java/org/apache/camel/component/jsonvalidator/DefaultJsonSchemaLoader.java
index 6746c10..c20a7e2 100644
--- a/components/camel-json-validator/src/main/java/org/apache/camel/component/jsonvalidator/DefaultJsonSchemaLoader.java
+++ b/components/camel-json-validator/src/main/java/org/apache/camel/component/jsonvalidator/DefaultJsonSchemaLoader.java
@@ -16,25 +16,18 @@
*/
package org.apache.camel.component.jsonvalidator;
-import java.io.IOException;
import java.io.InputStream;
+import com.networknt.schema.JsonSchema;
+import com.networknt.schema.JsonSchemaFactory;
import org.apache.camel.CamelContext;
-import org.everit.json.schema.Schema;
-import org.everit.json.schema.loader.SchemaLoader;
-import org.everit.json.schema.loader.SchemaLoader.SchemaLoaderBuilder;
-import org.json.JSONObject;
-import org.json.JSONTokener;
public class DefaultJsonSchemaLoader implements JsonSchemaLoader {
@Override
- public Schema createSchema(CamelContext camelContext, InputStream schemaInputStream) throws IOException {
- SchemaLoaderBuilder schemaLoaderBuilder = SchemaLoader.builder().draftV6Support();
- try (InputStream inputStream = schemaInputStream) {
- JSONObject rawSchema = new JSONObject(new JSONTokener(inputStream));
- return schemaLoaderBuilder.schemaJson(rawSchema).build().load().build();
- }
+ public JsonSchema createSchema(CamelContext camelContext, InputStream inputStream) throws Exception {
+ JsonSchemaFactory factory = JsonSchemaFactory.getInstance();
+ return factory.getSchema(inputStream);
}
}
diff --git a/components/camel-json-validator/src/main/java/org/apache/camel/component/jsonvalidator/DefaultJsonValidationErrorHandler.java b/components/camel-json-validator/src/main/java/org/apache/camel/component/jsonvalidator/DefaultJsonValidationErrorHandler.java
index da96a77..e4003fc 100644
--- a/components/camel-json-validator/src/main/java/org/apache/camel/component/jsonvalidator/DefaultJsonValidationErrorHandler.java
+++ b/components/camel-json-validator/src/main/java/org/apache/camel/component/jsonvalidator/DefaultJsonValidationErrorHandler.java
@@ -16,23 +16,23 @@
*/
package org.apache.camel.component.jsonvalidator;
+import java.util.Set;
+
+import com.networknt.schema.JsonSchema;
+import com.networknt.schema.ValidationMessage;
import org.apache.camel.Exchange;
import org.apache.camel.ValidationException;
public class DefaultJsonValidationErrorHandler implements JsonValidatorErrorHandler {
@Override
- public void reset() {
- // Do nothing since we do not keep state
+ public void handleErrors(Exchange exchange, JsonSchema schema, Set<ValidationMessage> errors) throws ValidationException {
+ throw new JsonValidationException(exchange, schema, errors);
}
-
+
@Override
- public void handleErrors(Exchange exchange, org.everit.json.schema.Schema schema, Exception e) throws ValidationException {
- if (e instanceof org.everit.json.schema.ValidationException) {
- throw new JsonValidationException(exchange, schema, (org.everit.json.schema.ValidationException)e);
- } else {
- throw new JsonValidationException(exchange, schema, e);
- }
+ public void handleErrors(Exchange exchange, JsonSchema schema, Exception e) throws ValidationException {
+ throw new JsonValidationException(exchange, schema, e);
}
}
diff --git a/components/camel-json-validator/src/main/java/org/apache/camel/component/jsonvalidator/JsonSchemaLoader.java b/components/camel-json-validator/src/main/java/org/apache/camel/component/jsonvalidator/JsonSchemaLoader.java
index 045052d..231116f 100644
--- a/components/camel-json-validator/src/main/java/org/apache/camel/component/jsonvalidator/JsonSchemaLoader.java
+++ b/components/camel-json-validator/src/main/java/org/apache/camel/component/jsonvalidator/JsonSchemaLoader.java
@@ -18,17 +18,11 @@ package org.apache.camel.component.jsonvalidator;
import java.io.InputStream;
+import com.networknt.schema.JsonSchema;
import org.apache.camel.CamelContext;
-import org.everit.json.schema.FormatValidator;
-import org.everit.json.schema.Schema;
/**
* Can be used to create custom schema for the JSON validator endpoint.
- * This interface is useful to add custom {@link FormatValidator} to the {@link Schema}
- *
- * For more information see
- * <a href="https://github.com/everit-org/json-schema#format-validators">Format Validators</a>
- * in the Everit JSON Schema documentation.
*/
public interface JsonSchemaLoader {
@@ -36,9 +30,9 @@ public interface JsonSchemaLoader {
* Create a new Schema based on the schema input stream.
*
* @param camelContext camel context
- * @param schemaInputStream the resource input stream
+ * @param inputStream the resource input stream
* @return a Schema to be used when validating incoming requests
*/
- Schema createSchema(CamelContext camelContext, InputStream schemaInputStream) throws Exception;
+ JsonSchema createSchema(CamelContext camelContext, InputStream inputStream) throws Exception;
}
diff --git a/components/camel-json-validator/src/main/java/org/apache/camel/component/jsonvalidator/JsonValidationException.java b/components/camel-json-validator/src/main/java/org/apache/camel/component/jsonvalidator/JsonValidationException.java
index d027f2e..2394f53 100644
--- a/components/camel-json-validator/src/main/java/org/apache/camel/component/jsonvalidator/JsonValidationException.java
+++ b/components/camel-json-validator/src/main/java/org/apache/camel/component/jsonvalidator/JsonValidationException.java
@@ -16,21 +16,41 @@
*/
package org.apache.camel.component.jsonvalidator;
-import java.util.stream.Collectors;
+import java.util.Set;
+import com.networknt.schema.JsonSchema;
+import com.networknt.schema.ValidationMessage;
import org.apache.camel.Exchange;
import org.apache.camel.ValidationException;
-import org.everit.json.schema.Schema;
public class JsonValidationException extends ValidationException {
private static final long serialVersionUID = 1L;
-
- public JsonValidationException(Exchange exchange, Schema schema, org.everit.json.schema.ValidationException e) {
- super(e.getAllMessages().stream().collect(Collectors.joining(", ")), exchange, e);
+
+ private final JsonSchema schema;
+ private final Set<ValidationMessage> errors;
+
+ public JsonValidationException(Exchange exchange, JsonSchema schema, Set<ValidationMessage> errors) {
+ super(exchange, "JSon validation error with " + errors.size() + " errors");
+ this.schema = schema;
+ this.errors = errors;
}
- public JsonValidationException(Exchange exchange, Schema schema, Exception e) {
+ public JsonValidationException(Exchange exchange, JsonSchema schema, Exception e) {
super(e.getMessage(), exchange, e);
+ this.schema = schema;
+ this.errors = null;
+ }
+
+ public JsonSchema getSchema() {
+ return schema;
+ }
+
+ public Set<ValidationMessage> getErrors() {
+ return errors;
+ }
+
+ public int getNumberOfErrors() {
+ return errors.size();
}
}
diff --git a/components/camel-json-validator/src/main/java/org/apache/camel/component/jsonvalidator/JsonValidatorEndpoint.java b/components/camel-json-validator/src/main/java/org/apache/camel/component/jsonvalidator/JsonValidatorEndpoint.java
index 0b5cc8d..a4706c0 100644
--- a/components/camel-json-validator/src/main/java/org/apache/camel/component/jsonvalidator/JsonValidatorEndpoint.java
+++ b/components/camel-json-validator/src/main/java/org/apache/camel/component/jsonvalidator/JsonValidatorEndpoint.java
@@ -17,22 +17,21 @@
package org.apache.camel.component.jsonvalidator;
import java.io.InputStream;
+import java.util.Set;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.networknt.schema.JsonSchema;
+import com.networknt.schema.ValidationMessage;
import org.apache.camel.Component;
import org.apache.camel.Exchange;
import org.apache.camel.ExchangePattern;
+import org.apache.camel.ValidationException;
import org.apache.camel.api.management.ManagedResource;
import org.apache.camel.component.ResourceEndpoint;
import org.apache.camel.spi.UriEndpoint;
import org.apache.camel.spi.UriParam;
import org.apache.camel.util.IOHelper;
-import org.everit.json.schema.ObjectSchema;
-import org.everit.json.schema.Schema;
-import org.everit.json.schema.ValidationException;
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-import org.json.JSONTokener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -46,7 +45,7 @@ public class JsonValidatorEndpoint extends ResourceEndpoint {
private static final Logger LOG = LoggerFactory.getLogger(JsonValidatorEndpoint.class);
- private volatile Schema schema;
+ private volatile JsonSchema schema;
@UriParam(defaultValue = "true")
private boolean failOnNullBody = true;
@@ -76,10 +75,10 @@ public class JsonValidatorEndpoint extends ResourceEndpoint {
@Override
protected void onExchange(Exchange exchange) throws Exception {
- Object jsonPayload;
InputStream is = null;
+
// Get a local copy of the current schema to improve concurrency.
- Schema localSchema = this.schema;
+ JsonSchema localSchema = this.schema;
if (localSchema == null) {
localSchema = getOrCreateSchema();
}
@@ -95,17 +94,25 @@ public class JsonValidatorEndpoint extends ResourceEndpoint {
}
}
if (is != null) {
- if (schema instanceof ObjectSchema) {
- jsonPayload = new JSONObject(new JSONTokener(is));
- } else {
- jsonPayload = new JSONArray(new JSONTokener(is));
+ ObjectMapper mapper = new ObjectMapper();
+ JsonNode node = mapper.readTree(is);
+ Set<ValidationMessage> errors = localSchema.validate(node);
+
+ if (errors.size() > 0) {
+ LOG.debug("Validated JSon has {} errors", errors.size());
+ this.errorHandler.handleErrors(exchange, schema, errors);
+ } else {
+ LOG.debug("Validated JSon success");
}
- // throws a ValidationException if this object is invalid
- schema.validate(jsonPayload);
- LOG.debug("JSON is valid");
}
- } catch (ValidationException | JSONException e) {
- this.errorHandler.handleErrors(exchange, schema, e);
+ } catch (Exception e) {
+ if (e instanceof ValidationException) {
+ // already as validation error
+ throw e;
+ } else {
+ // general error
+ this.errorHandler.handleErrors(exchange, schema, e);
+ }
} finally {
IOHelper.close(is);
}
@@ -128,7 +135,7 @@ public class JsonValidatorEndpoint extends ResourceEndpoint {
*
* @return The currently loaded schema
*/
- private Schema getOrCreateSchema() throws Exception {
+ private JsonSchema getOrCreateSchema() throws Exception {
synchronized (this) {
if (this.schema == null) {
this.schema = this.schemaLoader.createSchema(getCamelContext(), this.getResourceAsInputStream());
diff --git a/components/camel-json-validator/src/main/java/org/apache/camel/component/jsonvalidator/JsonValidatorErrorHandler.java b/components/camel-json-validator/src/main/java/org/apache/camel/component/jsonvalidator/JsonValidatorErrorHandler.java
index 830ccd4..04a1e96 100644
--- a/components/camel-json-validator/src/main/java/org/apache/camel/component/jsonvalidator/JsonValidatorErrorHandler.java
+++ b/components/camel-json-validator/src/main/java/org/apache/camel/component/jsonvalidator/JsonValidatorErrorHandler.java
@@ -16,24 +16,33 @@
*/
package org.apache.camel.component.jsonvalidator;
+import java.util.Set;
+
+import com.networknt.schema.JsonSchema;
+import com.networknt.schema.ValidationMessage;
import org.apache.camel.Exchange;
import org.apache.camel.ValidationException;
public interface JsonValidatorErrorHandler {
/**
- * Resets any state within this error handler
+ * Process any errors which may have occurred during validation
+ *
+ * @param exchange the exchange
+ * @param schema the schema
+ * @param errors the validation errors
+ * @throws ValidationException is thrown in case of validation errors
*/
- void reset();
+ void handleErrors(Exchange exchange, JsonSchema schema, Set<ValidationMessage> errors) throws ValidationException;
/**
- * Process any errors which may have occurred during validation
+ * Process a general error that happens during valdating
*
* @param exchange the exchange
* @param schema the schema
- * @param e the exception triggering the error
+ * @param e general error
* @throws ValidationException is thrown in case of validation errors
*/
- void handleErrors(Exchange exchange, org.everit.json.schema.Schema schema, Exception e) throws ValidationException;
+ void handleErrors(Exchange exchange, JsonSchema schema, Exception e) throws ValidationException;
}
diff --git a/components/camel-json-validator/src/test/java/org/apache/camel/component/jsonvalidator/CustomSchemaLoaderValidatorRouteTest.java b/components/camel-json-validator/src/test/java/org/apache/camel/component/jsonvalidator/CustomSchemaLoaderValidatorRouteTest.java
deleted file mode 100644
index a509f81..0000000
--- a/components/camel-json-validator/src/test/java/org/apache/camel/component/jsonvalidator/CustomSchemaLoaderValidatorRouteTest.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/**
- * 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.jsonvalidator;
-
-import org.apache.camel.EndpointInject;
-import org.apache.camel.ValidationException;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.impl.JndiRegistry;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
-
-public class CustomSchemaLoaderValidatorRouteTest extends CamelTestSupport {
-
- @EndpointInject(uri = "mock:valid")
- protected MockEndpoint validEndpoint;
-
- @EndpointInject(uri = "mock:finally")
- protected MockEndpoint finallyEndpoint;
-
- @EndpointInject(uri = "mock:invalid")
- protected MockEndpoint invalidEndpoint;
-
- @Test
- public void testValidMessage() throws Exception {
- validEndpoint.expectedMessageCount(1);
- finallyEndpoint.expectedMessageCount(1);
-
- template.sendBody("direct:start",
- "{ \"name\": \"Even Joe\", \"id\": 1, \"price\": 12.5 }");
-
- MockEndpoint.assertIsSatisfied(validEndpoint, invalidEndpoint, finallyEndpoint);
- }
-
- @Test
- public void testInvalidMessage() throws Exception {
- invalidEndpoint.expectedMessageCount(1);
- finallyEndpoint.expectedMessageCount(1);
-
- template.sendBody("direct:start",
- "{ \"name\": \"Odd Joe\", \"id\": 1, \"price\": 12.5 }");
-
- MockEndpoint.assertIsSatisfied(validEndpoint, invalidEndpoint, finallyEndpoint);
- }
-
- @Override
- protected JndiRegistry createRegistry() throws Exception {
- JndiRegistry jndiRegistry = super.createRegistry();
- jndiRegistry.bind("customSchemaLoader", new TestCustomSchemaLoader());
- return jndiRegistry;
- }
-
- @Override
- protected RouteBuilder createRouteBuilder() throws Exception {
- return new RouteBuilder() {
- @Override
- public void configure() throws Exception {
- from("direct:start")
- .doTry()
- .to("json-validator:org/apache/camel/component/jsonvalidator/schemawithformat.json?schemaLoader=#customSchemaLoader")
- .to("mock:valid")
- .doCatch(ValidationException.class)
- .to("mock:invalid")
- .doFinally()
- .to("mock:finally")
- .end();
- }
- };
- }
-}
diff --git a/components/camel-json-validator/src/test/java/org/apache/camel/component/jsonvalidator/EvenCharNumValidator.java b/components/camel-json-validator/src/test/java/org/apache/camel/component/jsonvalidator/EvenCharNumValidator.java
deleted file mode 100644
index 6b995ac..0000000
--- a/components/camel-json-validator/src/test/java/org/apache/camel/component/jsonvalidator/EvenCharNumValidator.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
- * 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.jsonvalidator;
-
-import java.util.Optional;
-
-import org.everit.json.schema.FormatValidator;
-
-public class EvenCharNumValidator implements FormatValidator {
-
- @Override
- public Optional<String> validate(final String subject) {
- if (subject.length() % 2 == 0) {
- return Optional.empty();
- } else {
- return Optional.of(String.format("the length of string [%s] is odd", subject));
- }
- }
-
- @Override
- public String formatName() {
- return "evenlength";
- }
-}
\ No newline at end of file
diff --git a/components/camel-json-validator/src/test/java/org/apache/camel/component/jsonvalidator/TestCustomSchemaLoader.java b/components/camel-json-validator/src/test/java/org/apache/camel/component/jsonvalidator/TestCustomSchemaLoader.java
deleted file mode 100644
index b7367eb..0000000
--- a/components/camel-json-validator/src/test/java/org/apache/camel/component/jsonvalidator/TestCustomSchemaLoader.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/**
- * 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.jsonvalidator;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import org.apache.camel.CamelContext;
-import org.everit.json.schema.Schema;
-import org.everit.json.schema.loader.SchemaLoader;
-import org.everit.json.schema.loader.SchemaLoader.SchemaLoaderBuilder;
-import org.json.JSONObject;
-import org.json.JSONTokener;
-
-public class TestCustomSchemaLoader implements JsonSchemaLoader {
-
- @Override
- public Schema createSchema(CamelContext camelContext, InputStream schemaInputStream) throws IOException {
-
- SchemaLoaderBuilder schemaLoaderBuilder = SchemaLoader.builder().draftV6Support();
-
- try (InputStream inputStream = schemaInputStream) {
- JSONObject rawSchema = new JSONObject(new JSONTokener(inputStream));
- return schemaLoaderBuilder.schemaJson(rawSchema).addFormatValidator(new EvenCharNumValidator()).build().load().build();
- }
- }
-
-}
diff --git a/components/camel-json-validator/src/test/resources/org/apache/camel/component/jsonvalidator/schema.json b/components/camel-json-validator/src/test/resources/org/apache/camel/component/jsonvalidator/schema.json
index 021640d..158a12d 100644
--- a/components/camel-json-validator/src/test/resources/org/apache/camel/component/jsonvalidator/schema.json
+++ b/components/camel-json-validator/src/test/resources/org/apache/camel/component/jsonvalidator/schema.json
@@ -1,7 +1,7 @@
{
- "$schema": "http://json-schema.org/draft-06/schema#",
+ "$schema": "http://json-schema.org/draft-04/schema#",
"definitions": {},
- "id": "http://example.com/example.json",
+ "id": "my-schema",
"properties": {
"id": {
"default": 1,
diff --git a/components/camel-json-validator/src/test/resources/org/apache/camel/component/jsonvalidator/schemawithformat.json b/components/camel-json-validator/src/test/resources/org/apache/camel/component/jsonvalidator/schemawithformat.json
index a365115..c943aff 100644
--- a/components/camel-json-validator/src/test/resources/org/apache/camel/component/jsonvalidator/schemawithformat.json
+++ b/components/camel-json-validator/src/test/resources/org/apache/camel/component/jsonvalidator/schemawithformat.json
@@ -1,7 +1,7 @@
{
- "$schema": "http://json-schema.org/draft-06/schema#",
+ "$schema": "http://json-schema.org/draft-04/schema#",
"definitions": {},
- "id": "http://example.com/example.json",
+ "id": "myother-schema",
"properties": {
"id": {
"default": 1,
diff --git a/parent/pom.xml b/parent/pom.xml
index f26e78f..b1941ee 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -209,7 +209,6 @@
<el-api-1.0-version>1.0.1</el-api-1.0-version>
<embedmongo-version>2.0.0</embedmongo-version>
<etcd4j-version>2.14.0</etcd4j-version>
- <everit-org-json-schema-version>1.6.1</everit-org-json-schema-version>
<exec-maven-plugin-version>1.6.0</exec-maven-plugin-version>
<ezmorph-bundle-version>1.0.6_1</ezmorph-bundle-version>
<fabric8-maven-plugin-version>3.5.33</fabric8-maven-plugin-version>
@@ -519,6 +518,7 @@
<netty3-version>3.10.6.Final</netty3-version>
<netty-version>4.1.19.Final</netty-version>
<netty40-version>4.0.54.Final</netty40-version>
+ <networknt-json-schema-validator-version>0.1.13</networknt-json-schema-validator-version>
<noggit-bundle-version>0.5_1</noggit-bundle-version>
<!-- should be in-sync with deltaspike -->
<openwebbeans1-version>1.2.7</openwebbeans1-version>
diff --git a/platforms/karaf/features/src/main/resources/features.xml b/platforms/karaf/features/src/main/resources/features.xml
index 66e6207..79f9b03 100644
--- a/platforms/karaf/features/src/main/resources/features.xml
+++ b/platforms/karaf/features/src/main/resources/features.xml
@@ -1263,15 +1263,11 @@
</feature>
<feature name='camel-json-validator' version='${project.version}' resolver='(obr)' start-level='50'>
<feature version='${project.version}'>camel-core</feature>
- <bundle dependency='true'>mvn:com.github.everit-org.json-schema/org.everit.json.schema/${everit-org-json-schema-version}</bundle>
- <bundle dependency='true'>mvn:org.json/json/20171018</bundle>
- <bundle dependency='true'>mvn:com.damnhandy/handy-uri-templates/2.1.6</bundle>
- <bundle dependency='true'>mvn:joda-time/joda-time/${jodatime2-bundle-version}</bundle>
- <bundle dependency='true'>mvn:com.google.guava/guava/22.0</bundle>
- <bundle dependency='true'>mvn:commons-collections/commons-collections/${commons-collections-version}</bundle>
- <bundle dependency='true'>mvn:commons-validator/commons-validator/1.6</bundle>
- <bundle dependency='true'>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.commons-beanutils/${commons-beanutils-bundle-version}</bundle>
- <bundle dependency='true'>mvn:commons-digester/commons-digester/${commons-digester-version}</bundle>
+ <bundle dependency='true'>wrap:com.networknt/json-schema-validator/${networknt-json-schema-validator-version}</bundle>
+ <bundle dependency='true'>mvn:com.fasterxml.jackson.core/jackson-core/${jackson2-version}</bundle>
+ <bundle dependency='true'>mvn:com.fasterxml.jackson.core/jackson-databind/${jackson2-version}</bundle>
+ <bundle dependency='true'>mvn:com.fasterxml.jackson.core/jackson-annotations/${jackson2-version}</bundle>
+ <bundle dependency='true'>mvn:org.apache.commons/commons-lang3/${commons-lang3-version}</bundle>
<bundle>mvn:org.apache.camel/camel-json-validator/${project.version}</bundle>
</feature>
<feature name='camel-jsonpath' version='${project.version}' resolver='(obr)' start-level='50'>
diff --git a/platforms/spring-boot/components-starter/camel-json-validator-starter/pom.xml b/platforms/spring-boot/components-starter/camel-json-validator-starter/pom.xml
index 94e56c6..69e60df 100644
--- a/platforms/spring-boot/components-starter/camel-json-validator-starter/pom.xml
+++ b/platforms/spring-boot/components-starter/camel-json-validator-starter/pom.xml
@@ -38,14 +38,6 @@
<groupId>org.apache.camel</groupId>
<artifactId>camel-json-validator</artifactId>
<version>${project.version}</version>
- <!--START OF GENERATED CODE-->
- <exclusions>
- <exclusion>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- </exclusion>
- </exclusions>
- <!--END OF GENERATED CODE-->
</dependency>
<!--START OF GENERATED CODE-->
<dependency>
@@ -58,12 +50,4 @@
</dependency>
<!--END OF GENERATED CODE-->
</dependencies>
- <!--START OF GENERATED CODE-->
- <repositories>
- <repository>
- <id>jitpack.io</id>
- <url>https://jitpack.io</url>
- </repository>
- </repositories>
- <!--END OF GENERATED CODE-->
</project>
--
To stop receiving notification emails like this one, please contact
['"commits@camel.apache.org" <co...@camel.apache.org>'].