dgriffon commented on code in PR #597:
URL: https://github.com/apache/unomi/pull/597#discussion_r1145756152


##########
extensions/json-schema/rest/src/main/java/org/apache/unomi/schema/rest/JsonSchemaEndPoint.java:
##########
@@ -114,4 +116,22 @@ public Response save(String jsonSchema) {
     public boolean remove(String id) {
         return schemaService.deleteSchema(id);
     }
+
+    /**
+     * Being able to validate a given event is useful when you want to develop 
custom events and associated schemas
+     * @param event the event to be validated
+     * @return Validation error messages if there is some
+     */
+    @POST
+    @Produces(MediaType.APPLICATION_JSON + ";charset=UTF-8")
+    @Consumes({ MediaType.TEXT_PLAIN, MediaType.APPLICATION_JSON })
+    @Path("/validateEvent")
+    public Collection<ValidationError> validateEvent(String event) {
+        try {
+            return schemaService.validateEvent(event);

Review Comment:
   There is small inconsistency in this method, we should return an error code 
always when the schema is invalid.
   All the errors could be handled by the Exception and have 
`schemaService.validateEvent()` to return a boolean (or nothing). The 
`Collection<ValidationError>` can be carried by the ValidateException. 
   If we don't want to do such change, at least we should return an error code 
in case of invalid event. 
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@unomi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to