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

jsinovassinnaik pushed a commit to branch UNOMI-775-add-validation-endpoint
in repository https://gitbox.apache.org/repos/asf/unomi.git


The following commit(s) were added to 
refs/heads/UNOMI-775-add-validation-endpoint by this push:
     new 47e631450 UNOMI-775 : add documentation
47e631450 is described below

commit 47e6314504fa3b70cdeba35e52eec18b7b44315b
Author: jsinovassin <jsinovassinn...@jahia.com>
AuthorDate: Fri Apr 28 18:41:09 2023 +0200

    UNOMI-775 : add documentation
---
 .../asciidoc/jsonSchema/json-schema-develop.adoc   | 60 ++++++++++++++++++++++
 1 file changed, 60 insertions(+)

diff --git a/manual/src/main/asciidoc/jsonSchema/json-schema-develop.adoc 
b/manual/src/main/asciidoc/jsonSchema/json-schema-develop.adoc
index 83bb9dc5b..45ec0d50a 100644
--- a/manual/src/main/asciidoc/jsonSchema/json-schema-develop.adoc
+++ b/manual/src/main/asciidoc/jsonSchema/json-schema-develop.adoc
@@ -78,3 +78,63 @@ towards the incorrect property:
        }
 ]
 ----
+
+==== validateEvents endpoint
+
+A dedicated Admin endpoint (requires authentication), accessible at: 
`cxs/jsonSchema/validateEvents`, was created to validate a list of event at 
once against JSON Schemas loaded in Apache Unomi.
+
+For example, sending a list of event not matching a schema:
+[source]
+----
+curl --request POST \
+  --url http://localhost:8181/cxs/jsonSchema/validateEvents \
+  --user karaf:karaf \
+  --header 'Content-Type: application/json' \
+  --data '[{
+    "eventType": "view",
+    "scope": "scope",
+    "properties": {
+        "workspace": "no_workspace",
+        "path": "some/path",
+        "unknowProperty": "not valid"
+    }, {
+    "eventType": "view",
+    "scope": "scope",
+    "properties": {
+        "workspace": "no_workspace",
+        "path": "some/path",
+        "unknowProperty": "not valid",
+        "secondUnknowProperty": "also not valid"
+    }, {
+    "eventType": "notKnownEvent",
+    "scope": "scope",
+    "properties": {
+        "workspace": "no_workspace",
+        "path": "some/path"
+    }
+}]'
+----
+
+Would return the errors grouped by event type as the following:
+
+[source]
+----
+{
+    "view": [
+        {
+            "error": "There are unevaluated properties at following paths 
$.properties.unknowProperty"
+        },
+        {
+            "error": "There are unevaluated properties at following paths 
$.properties.secondUnknowProperty"
+        }
+    ],
+    "notKnownEvent": [
+        {
+            "error": "No Schema found for this event type"
+        }
+    ]
+}
+----
+
+If several events have the same issue, only one message is returned for this 
issue.
+

Reply via email to