Document MissingParams error message for /ari/events
[asterisk/asterisk.git] / res / stasis_http / ari_model_validators.c
index c721727..14b5d69 100644 (file)
@@ -864,36 +864,36 @@ int ari_validate_application_replaced(struct ast_json *json)
 {
        int res = 1;
        struct ast_json_iter *iter;
-       int has_application = 0;
        int has_type = 0;
+       int has_application = 0;
 
        for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
-               if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
+               if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
                        int prop_is_valid;
-                       has_application = 1;
+                       has_type = 1;
                        prop_is_valid = ari_validate_string(
                                ast_json_object_iter_value(iter));
                        if (!prop_is_valid) {
-                               ast_log(LOG_ERROR, "ARI ApplicationReplaced field application failed validation\n");
+                               ast_log(LOG_ERROR, "ARI ApplicationReplaced field type failed validation\n");
                                res = 0;
                        }
                } else
-               if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
+               if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
                        int prop_is_valid;
-                       prop_is_valid = ari_validate_date(
+                       has_application = 1;
+                       prop_is_valid = ari_validate_string(
                                ast_json_object_iter_value(iter));
                        if (!prop_is_valid) {
-                               ast_log(LOG_ERROR, "ARI ApplicationReplaced field timestamp failed validation\n");
+                               ast_log(LOG_ERROR, "ARI ApplicationReplaced field application failed validation\n");
                                res = 0;
                        }
                } else
-               if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
+               if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
                        int prop_is_valid;
-                       has_type = 1;
-                       prop_is_valid = ari_validate_string(
+                       prop_is_valid = ari_validate_date(
                                ast_json_object_iter_value(iter));
                        if (!prop_is_valid) {
-                               ast_log(LOG_ERROR, "ARI ApplicationReplaced field type failed validation\n");
+                               ast_log(LOG_ERROR, "ARI ApplicationReplaced field timestamp failed validation\n");
                                res = 0;
                        }
                } else
@@ -905,13 +905,13 @@ int ari_validate_application_replaced(struct ast_json *json)
                }
        }
 
-       if (!has_application) {
-               ast_log(LOG_ERROR, "ARI ApplicationReplaced missing required field application\n");
+       if (!has_type) {
+               ast_log(LOG_ERROR, "ARI ApplicationReplaced missing required field type\n");
                res = 0;
        }
 
-       if (!has_type) {
-               ast_log(LOG_ERROR, "ARI ApplicationReplaced missing required field type\n");
+       if (!has_application) {
+               ast_log(LOG_ERROR, "ARI ApplicationReplaced missing required field application\n");
                res = 0;
        }
 
@@ -927,37 +927,37 @@ int ari_validate_bridge_created(struct ast_json *json)
 {
        int res = 1;
        struct ast_json_iter *iter;
-       int has_application = 0;
        int has_type = 0;
+       int has_application = 0;
        int has_bridge = 0;
 
        for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
-               if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
+               if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
                        int prop_is_valid;
-                       has_application = 1;
+                       has_type = 1;
                        prop_is_valid = ari_validate_string(
                                ast_json_object_iter_value(iter));
                        if (!prop_is_valid) {
-                               ast_log(LOG_ERROR, "ARI BridgeCreated field application failed validation\n");
+                               ast_log(LOG_ERROR, "ARI BridgeCreated field type failed validation\n");
                                res = 0;
                        }
                } else
-               if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
+               if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
                        int prop_is_valid;
-                       prop_is_valid = ari_validate_date(
+                       has_application = 1;
+                       prop_is_valid = ari_validate_string(
                                ast_json_object_iter_value(iter));
                        if (!prop_is_valid) {
-                               ast_log(LOG_ERROR, "ARI BridgeCreated field timestamp failed validation\n");
+                               ast_log(LOG_ERROR, "ARI BridgeCreated field application failed validation\n");
                                res = 0;
                        }
                } else
-               if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
+               if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
                        int prop_is_valid;
-                       has_type = 1;
-                       prop_is_valid = ari_validate_string(
+                       prop_is_valid = ari_validate_date(
                                ast_json_object_iter_value(iter));
                        if (!prop_is_valid) {
-                               ast_log(LOG_ERROR, "ARI BridgeCreated field type failed validation\n");
+                               ast_log(LOG_ERROR, "ARI BridgeCreated field timestamp failed validation\n");
                                res = 0;
                        }
                } else
@@ -979,13 +979,13 @@ int ari_validate_bridge_created(struct ast_json *json)
                }
        }
 
-       if (!has_application) {
-               ast_log(LOG_ERROR, "ARI BridgeCreated missing required field application\n");
+       if (!has_type) {
+               ast_log(LOG_ERROR, "ARI BridgeCreated missing required field type\n");
                res = 0;
        }
 
-       if (!has_type) {
-               ast_log(LOG_ERROR, "ARI BridgeCreated missing required field type\n");
+       if (!has_application) {
+               ast_log(LOG_ERROR, "ARI BridgeCreated missing required field application\n");
                res = 0;
        }
 
@@ -1006,37 +1006,37 @@ int ari_validate_bridge_destroyed(struct ast_json *json)
 {
        int res = 1;
        struct ast_json_iter *iter;
-       int has_application = 0;
        int has_type = 0;
+       int has_application = 0;
        int has_bridge = 0;
 
        for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
-               if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
+               if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
                        int prop_is_valid;
-                       has_application = 1;
+                       has_type = 1;
                        prop_is_valid = ari_validate_string(
                                ast_json_object_iter_value(iter));
                        if (!prop_is_valid) {
-                               ast_log(LOG_ERROR, "ARI BridgeDestroyed field application failed validation\n");
+                               ast_log(LOG_ERROR, "ARI BridgeDestroyed field type failed validation\n");
                                res = 0;
                        }
                } else
-               if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
+               if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
                        int prop_is_valid;
-                       prop_is_valid = ari_validate_date(
+                       has_application = 1;
+                       prop_is_valid = ari_validate_string(
                                ast_json_object_iter_value(iter));
                        if (!prop_is_valid) {
-                               ast_log(LOG_ERROR, "ARI BridgeDestroyed field timestamp failed validation\n");
+                               ast_log(LOG_ERROR, "ARI BridgeDestroyed field application failed validation\n");
                                res = 0;
                        }
                } else
-               if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
+               if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
                        int prop_is_valid;
-                       has_type = 1;
-                       prop_is_valid = ari_validate_string(
+                       prop_is_valid = ari_validate_date(
                                ast_json_object_iter_value(iter));
                        if (!prop_is_valid) {
-                               ast_log(LOG_ERROR, "ARI BridgeDestroyed field type failed validation\n");
+                               ast_log(LOG_ERROR, "ARI BridgeDestroyed field timestamp failed validation\n");
                                res = 0;
                        }
                } else
@@ -1058,13 +1058,13 @@ int ari_validate_bridge_destroyed(struct ast_json *json)
                }
        }
 
-       if (!has_application) {
-               ast_log(LOG_ERROR, "ARI BridgeDestroyed missing required field application\n");
+       if (!has_type) {
+               ast_log(LOG_ERROR, "ARI BridgeDestroyed missing required field type\n");
                res = 0;
        }
 
-       if (!has_type) {
-               ast_log(LOG_ERROR, "ARI BridgeDestroyed missing required field type\n");
+       if (!has_application) {
+               ast_log(LOG_ERROR, "ARI BridgeDestroyed missing required field application\n");
                res = 0;
        }
 
@@ -1085,38 +1085,38 @@ int ari_validate_bridge_merged(struct ast_json *json)
 {
        int res = 1;
        struct ast_json_iter *iter;
-       int has_application = 0;
        int has_type = 0;
+       int has_application = 0;
        int has_bridge = 0;
        int has_bridge_from = 0;
 
        for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
-               if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
+               if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
                        int prop_is_valid;
-                       has_application = 1;
+                       has_type = 1;
                        prop_is_valid = ari_validate_string(
                                ast_json_object_iter_value(iter));
                        if (!prop_is_valid) {
-                               ast_log(LOG_ERROR, "ARI BridgeMerged field application failed validation\n");
+                               ast_log(LOG_ERROR, "ARI BridgeMerged field type failed validation\n");
                                res = 0;
                        }
                } else
-               if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
+               if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
                        int prop_is_valid;
-                       prop_is_valid = ari_validate_date(
+                       has_application = 1;
+                       prop_is_valid = ari_validate_string(
                                ast_json_object_iter_value(iter));
                        if (!prop_is_valid) {
-                               ast_log(LOG_ERROR, "ARI BridgeMerged field timestamp failed validation\n");
+                               ast_log(LOG_ERROR, "ARI BridgeMerged field application failed validation\n");
                                res = 0;
                        }
                } else
-               if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
+               if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
                        int prop_is_valid;
-                       has_type = 1;
-                       prop_is_valid = ari_validate_string(
+                       prop_is_valid = ari_validate_date(
                                ast_json_object_iter_value(iter));
                        if (!prop_is_valid) {
-                               ast_log(LOG_ERROR, "ARI BridgeMerged field type failed validation\n");
+                               ast_log(LOG_ERROR, "ARI BridgeMerged field timestamp failed validation\n");
                                res = 0;
                        }
                } else
@@ -1148,13 +1148,13 @@ int ari_validate_bridge_merged(struct ast_json *json)
                }
        }
 
-       if (!has_application) {
-               ast_log(LOG_ERROR, "ARI BridgeMerged missing required field application\n");
+       if (!has_type) {
+               ast_log(LOG_ERROR, "ARI BridgeMerged missing required field type\n");
                res = 0;
        }
 
-       if (!has_type) {
-               ast_log(LOG_ERROR, "ARI BridgeMerged missing required field type\n");
+       if (!has_application) {
+               ast_log(LOG_ERROR, "ARI BridgeMerged missing required field application\n");
                res = 0;
        }
 
@@ -1180,39 +1180,39 @@ int ari_validate_channel_caller_id(struct ast_json *json)
 {
        int res = 1;
        struct ast_json_iter *iter;
-       int has_application = 0;
        int has_type = 0;
+       int has_application = 0;
        int has_caller_presentation = 0;
        int has_caller_presentation_txt = 0;
        int has_channel = 0;
 
        for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
-               if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
+               if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
                        int prop_is_valid;
-                       has_application = 1;
+                       has_type = 1;
                        prop_is_valid = ari_validate_string(
                                ast_json_object_iter_value(iter));
                        if (!prop_is_valid) {
-                               ast_log(LOG_ERROR, "ARI ChannelCallerId field application failed validation\n");
+                               ast_log(LOG_ERROR, "ARI ChannelCallerId field type failed validation\n");
                                res = 0;
                        }
                } else
-               if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
+               if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
                        int prop_is_valid;
-                       prop_is_valid = ari_validate_date(
+                       has_application = 1;
+                       prop_is_valid = ari_validate_string(
                                ast_json_object_iter_value(iter));
                        if (!prop_is_valid) {
-                               ast_log(LOG_ERROR, "ARI ChannelCallerId field timestamp failed validation\n");
+                               ast_log(LOG_ERROR, "ARI ChannelCallerId field application failed validation\n");
                                res = 0;
                        }
                } else
-               if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
+               if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
                        int prop_is_valid;
-                       has_type = 1;
-                       prop_is_valid = ari_validate_string(
+                       prop_is_valid = ari_validate_date(
                                ast_json_object_iter_value(iter));
                        if (!prop_is_valid) {
-                               ast_log(LOG_ERROR, "ARI ChannelCallerId field type failed validation\n");
+                               ast_log(LOG_ERROR, "ARI ChannelCallerId field timestamp failed validation\n");
                                res = 0;
                        }
                } else
@@ -1254,13 +1254,13 @@ int ari_validate_channel_caller_id(struct ast_json *json)
                }
        }
 
-       if (!has_application) {
-               ast_log(LOG_ERROR, "ARI ChannelCallerId missing required field application\n");
+       if (!has_type) {
+               ast_log(LOG_ERROR, "ARI ChannelCallerId missing required field type\n");
                res = 0;
        }
 
-       if (!has_type) {
-               ast_log(LOG_ERROR, "ARI ChannelCallerId missing required field type\n");
+       if (!has_application) {
+               ast_log(LOG_ERROR, "ARI ChannelCallerId missing required field application\n");
                res = 0;
        }
 
@@ -1291,37 +1291,37 @@ int ari_validate_channel_created(struct ast_json *json)
 {
        int res = 1;
        struct ast_json_iter *iter;
-       int has_application = 0;
        int has_type = 0;
+       int has_application = 0;
        int has_channel = 0;
 
        for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
-               if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
+               if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
                        int prop_is_valid;
-                       has_application = 1;
+                       has_type = 1;
                        prop_is_valid = ari_validate_string(
                                ast_json_object_iter_value(iter));
                        if (!prop_is_valid) {
-                               ast_log(LOG_ERROR, "ARI ChannelCreated field application failed validation\n");
+                               ast_log(LOG_ERROR, "ARI ChannelCreated field type failed validation\n");
                                res = 0;
                        }
                } else
-               if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
+               if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
                        int prop_is_valid;
-                       prop_is_valid = ari_validate_date(
+                       has_application = 1;
+                       prop_is_valid = ari_validate_string(
                                ast_json_object_iter_value(iter));
                        if (!prop_is_valid) {
-                               ast_log(LOG_ERROR, "ARI ChannelCreated field timestamp failed validation\n");
+                               ast_log(LOG_ERROR, "ARI ChannelCreated field application failed validation\n");
                                res = 0;
                        }
                } else
-               if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
+               if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
                        int prop_is_valid;
-                       has_type = 1;
-                       prop_is_valid = ari_validate_string(
+                       prop_is_valid = ari_validate_date(
                                ast_json_object_iter_value(iter));
                        if (!prop_is_valid) {
-                               ast_log(LOG_ERROR, "ARI ChannelCreated field type failed validation\n");
+                               ast_log(LOG_ERROR, "ARI ChannelCreated field timestamp failed validation\n");
                                res = 0;
                        }
                } else
@@ -1343,13 +1343,13 @@ int ari_validate_channel_created(struct ast_json *json)
                }
        }
 
-       if (!has_application) {
-               ast_log(LOG_ERROR, "ARI ChannelCreated missing required field application\n");
+       if (!has_type) {
+               ast_log(LOG_ERROR, "ARI ChannelCreated missing required field type\n");
                res = 0;
        }
 
-       if (!has_type) {
-               ast_log(LOG_ERROR, "ARI ChannelCreated missing required field type\n");
+       if (!has_application) {
+               ast_log(LOG_ERROR, "ARI ChannelCreated missing required field application\n");
                res = 0;
        }
 
@@ -1370,39 +1370,39 @@ int ari_validate_channel_destroyed(struct ast_json *json)
 {
        int res = 1;
        struct ast_json_iter *iter;
-       int has_application = 0;
        int has_type = 0;
+       int has_application = 0;
        int has_cause = 0;
        int has_cause_txt = 0;
        int has_channel = 0;
 
        for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
-               if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
+               if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
                        int prop_is_valid;
-                       has_application = 1;
+                       has_type = 1;
                        prop_is_valid = ari_validate_string(
                                ast_json_object_iter_value(iter));
                        if (!prop_is_valid) {
-                               ast_log(LOG_ERROR, "ARI ChannelDestroyed field application failed validation\n");
+                               ast_log(LOG_ERROR, "ARI ChannelDestroyed field type failed validation\n");
                                res = 0;
                        }
                } else
-               if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
+               if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
                        int prop_is_valid;
-                       prop_is_valid = ari_validate_date(
+                       has_application = 1;
+                       prop_is_valid = ari_validate_string(
                                ast_json_object_iter_value(iter));
                        if (!prop_is_valid) {
-                               ast_log(LOG_ERROR, "ARI ChannelDestroyed field timestamp failed validation\n");
+                               ast_log(LOG_ERROR, "ARI ChannelDestroyed field application failed validation\n");
                                res = 0;
                        }
                } else
-               if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
+               if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
                        int prop_is_valid;
-                       has_type = 1;
-                       prop_is_valid = ari_validate_string(
+                       prop_is_valid = ari_validate_date(
                                ast_json_object_iter_value(iter));
                        if (!prop_is_valid) {
-                               ast_log(LOG_ERROR, "ARI ChannelDestroyed field type failed validation\n");
+                               ast_log(LOG_ERROR, "ARI ChannelDestroyed field timestamp failed validation\n");
                                res = 0;
                        }
                } else
@@ -1444,13 +1444,13 @@ int ari_validate_channel_destroyed(struct ast_json *json)
                }
        }
 
-       if (!has_application) {
-               ast_log(LOG_ERROR, "ARI ChannelDestroyed missing required field application\n");
+       if (!has_type) {
+               ast_log(LOG_ERROR, "ARI ChannelDestroyed missing required field type\n");
                res = 0;
        }
 
-       if (!has_type) {
-               ast_log(LOG_ERROR, "ARI ChannelDestroyed missing required field type\n");
+       if (!has_application) {
+               ast_log(LOG_ERROR, "ARI ChannelDestroyed missing required field application\n");
                res = 0;
        }
 
@@ -1481,39 +1481,39 @@ int ari_validate_channel_dialplan(struct ast_json *json)
 {
        int res = 1;
        struct ast_json_iter *iter;
-       int has_application = 0;
        int has_type = 0;
+       int has_application = 0;
        int has_channel = 0;
        int has_dialplan_app = 0;
        int has_dialplan_app_data = 0;
 
        for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
-               if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
+               if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
                        int prop_is_valid;
-                       has_application = 1;
+                       has_type = 1;
                        prop_is_valid = ari_validate_string(
                                ast_json_object_iter_value(iter));
                        if (!prop_is_valid) {
-                               ast_log(LOG_ERROR, "ARI ChannelDialplan field application failed validation\n");
+                               ast_log(LOG_ERROR, "ARI ChannelDialplan field type failed validation\n");
                                res = 0;
                        }
                } else
-               if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
+               if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
                        int prop_is_valid;
-                       prop_is_valid = ari_validate_date(
+                       has_application = 1;
+                       prop_is_valid = ari_validate_string(
                                ast_json_object_iter_value(iter));
                        if (!prop_is_valid) {
-                               ast_log(LOG_ERROR, "ARI ChannelDialplan field timestamp failed validation\n");
+                               ast_log(LOG_ERROR, "ARI ChannelDialplan field application failed validation\n");
                                res = 0;
                        }
                } else
-               if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
+               if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
                        int prop_is_valid;
-                       has_type = 1;
-                       prop_is_valid = ari_validate_string(
+                       prop_is_valid = ari_validate_date(
                                ast_json_object_iter_value(iter));
                        if (!prop_is_valid) {
-                               ast_log(LOG_ERROR, "ARI ChannelDialplan field type failed validation\n");
+                               ast_log(LOG_ERROR, "ARI ChannelDialplan field timestamp failed validation\n");
                                res = 0;
                        }
                } else
@@ -1555,13 +1555,13 @@ int ari_validate_channel_dialplan(struct ast_json *json)
                }
        }
 
-       if (!has_application) {
-               ast_log(LOG_ERROR, "ARI ChannelDialplan missing required field application\n");
+       if (!has_type) {
+               ast_log(LOG_ERROR, "ARI ChannelDialplan missing required field type\n");
                res = 0;
        }
 
-       if (!has_type) {
-               ast_log(LOG_ERROR, "ARI ChannelDialplan missing required field type\n");
+       if (!has_application) {
+               ast_log(LOG_ERROR, "ARI ChannelDialplan missing required field application\n");
                res = 0;
        }
 
@@ -1592,13 +1592,23 @@ int ari_validate_channel_dtmf_received(struct ast_json *json)
 {
        int res = 1;
        struct ast_json_iter *iter;
-       int has_application = 0;
        int has_type = 0;
+       int has_application = 0;
        int has_channel = 0;
        int has_digit = 0;
        int has_duration_ms = 0;
 
        for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
+               if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
+                       int prop_is_valid;
+                       has_type = 1;
+                       prop_is_valid = ari_validate_string(
+                               ast_json_object_iter_value(iter));
+                       if (!prop_is_valid) {
+                               ast_log(LOG_ERROR, "ARI ChannelDtmfReceived field type failed validation\n");
+                               res = 0;
+                       }
+               } else
                if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
                        int prop_is_valid;
                        has_application = 1;
@@ -1618,17 +1628,7 @@ int ari_validate_channel_dtmf_received(struct ast_json *json)
                                res = 0;
                        }
                } else
-               if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
-                       int prop_is_valid;
-                       has_type = 1;
-                       prop_is_valid = ari_validate_string(
-                               ast_json_object_iter_value(iter));
-                       if (!prop_is_valid) {
-                               ast_log(LOG_ERROR, "ARI ChannelDtmfReceived field type failed validation\n");
-                               res = 0;
-                       }
-               } else
-               if (strcmp("channel", ast_json_object_iter_key(iter)) == 0) {
+               if (strcmp("channel", ast_json_object_iter_key(iter)) == 0) {
                        int prop_is_valid;
                        has_channel = 1;
                        prop_is_valid = ari_validate_channel(
@@ -1666,13 +1666,13 @@ int ari_validate_channel_dtmf_received(struct ast_json *json)
                }
        }
 
-       if (!has_application) {
-               ast_log(LOG_ERROR, "ARI ChannelDtmfReceived missing required field application\n");
+       if (!has_type) {
+               ast_log(LOG_ERROR, "ARI ChannelDtmfReceived missing required field type\n");
                res = 0;
        }
 
-       if (!has_type) {
-               ast_log(LOG_ERROR, "ARI ChannelDtmfReceived missing required field type\n");
+       if (!has_application) {
+               ast_log(LOG_ERROR, "ARI ChannelDtmfReceived missing required field application\n");
                res = 0;
        }
 
@@ -1703,37 +1703,37 @@ int ari_validate_channel_entered_bridge(struct ast_json *json)
 {
        int res = 1;
        struct ast_json_iter *iter;
-       int has_application = 0;
        int has_type = 0;
+       int has_application = 0;
        int has_bridge = 0;
 
        for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
-               if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
+               if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
                        int prop_is_valid;
-                       has_application = 1;
+                       has_type = 1;
                        prop_is_valid = ari_validate_string(
                                ast_json_object_iter_value(iter));
                        if (!prop_is_valid) {
-                               ast_log(LOG_ERROR, "ARI ChannelEnteredBridge field application failed validation\n");
+                               ast_log(LOG_ERROR, "ARI ChannelEnteredBridge field type failed validation\n");
                                res = 0;
                        }
                } else
-               if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
+               if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
                        int prop_is_valid;
-                       prop_is_valid = ari_validate_date(
+                       has_application = 1;
+                       prop_is_valid = ari_validate_string(
                                ast_json_object_iter_value(iter));
                        if (!prop_is_valid) {
-                               ast_log(LOG_ERROR, "ARI ChannelEnteredBridge field timestamp failed validation\n");
+                               ast_log(LOG_ERROR, "ARI ChannelEnteredBridge field application failed validation\n");
                                res = 0;
                        }
                } else
-               if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
+               if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
                        int prop_is_valid;
-                       has_type = 1;
-                       prop_is_valid = ari_validate_string(
+                       prop_is_valid = ari_validate_date(
                                ast_json_object_iter_value(iter));
                        if (!prop_is_valid) {
-                               ast_log(LOG_ERROR, "ARI ChannelEnteredBridge field type failed validation\n");
+                               ast_log(LOG_ERROR, "ARI ChannelEnteredBridge field timestamp failed validation\n");
                                res = 0;
                        }
                } else
@@ -1764,13 +1764,13 @@ int ari_validate_channel_entered_bridge(struct ast_json *json)
                }
        }
 
-       if (!has_application) {
-               ast_log(LOG_ERROR, "ARI ChannelEnteredBridge missing required field application\n");
+       if (!has_type) {
+               ast_log(LOG_ERROR, "ARI ChannelEnteredBridge missing required field type\n");
                res = 0;
        }
 
-       if (!has_type) {
-               ast_log(LOG_ERROR, "ARI ChannelEnteredBridge missing required field type\n");
+       if (!has_application) {
+               ast_log(LOG_ERROR, "ARI ChannelEnteredBridge missing required field application\n");
                res = 0;
        }
 
@@ -1791,37 +1791,37 @@ int ari_validate_channel_hangup_request(struct ast_json *json)
 {
        int res = 1;
        struct ast_json_iter *iter;
-       int has_application = 0;
        int has_type = 0;
+       int has_application = 0;
        int has_channel = 0;
 
        for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
-               if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
+               if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
                        int prop_is_valid;
-                       has_application = 1;
+                       has_type = 1;
                        prop_is_valid = ari_validate_string(
                                ast_json_object_iter_value(iter));
                        if (!prop_is_valid) {
-                               ast_log(LOG_ERROR, "ARI ChannelHangupRequest field application failed validation\n");
+                               ast_log(LOG_ERROR, "ARI ChannelHangupRequest field type failed validation\n");
                                res = 0;
                        }
                } else
-               if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
+               if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
                        int prop_is_valid;
-                       prop_is_valid = ari_validate_date(
+                       has_application = 1;
+                       prop_is_valid = ari_validate_string(
                                ast_json_object_iter_value(iter));
                        if (!prop_is_valid) {
-                               ast_log(LOG_ERROR, "ARI ChannelHangupRequest field timestamp failed validation\n");
+                               ast_log(LOG_ERROR, "ARI ChannelHangupRequest field application failed validation\n");
                                res = 0;
                        }
                } else
-               if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
+               if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
                        int prop_is_valid;
-                       has_type = 1;
-                       prop_is_valid = ari_validate_string(
+                       prop_is_valid = ari_validate_date(
                                ast_json_object_iter_value(iter));
                        if (!prop_is_valid) {
-                               ast_log(LOG_ERROR, "ARI ChannelHangupRequest field type failed validation\n");
+                               ast_log(LOG_ERROR, "ARI ChannelHangupRequest field timestamp failed validation\n");
                                res = 0;
                        }
                } else
@@ -1861,13 +1861,13 @@ int ari_validate_channel_hangup_request(struct ast_json *json)
                }
        }
 
-       if (!has_application) {
-               ast_log(LOG_ERROR, "ARI ChannelHangupRequest missing required field application\n");
+       if (!has_type) {
+               ast_log(LOG_ERROR, "ARI ChannelHangupRequest missing required field type\n");
                res = 0;
        }
 
-       if (!has_type) {
-               ast_log(LOG_ERROR, "ARI ChannelHangupRequest missing required field type\n");
+       if (!has_application) {
+               ast_log(LOG_ERROR, "ARI ChannelHangupRequest missing required field application\n");
                res = 0;
        }
 
@@ -1888,38 +1888,38 @@ int ari_validate_channel_left_bridge(struct ast_json *json)
 {
        int res = 1;
        struct ast_json_iter *iter;
-       int has_application = 0;
        int has_type = 0;
+       int has_application = 0;
        int has_bridge = 0;
        int has_channel = 0;
 
        for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
-               if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
+               if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
                        int prop_is_valid;
-                       has_application = 1;
+                       has_type = 1;
                        prop_is_valid = ari_validate_string(
                                ast_json_object_iter_value(iter));
                        if (!prop_is_valid) {
-                               ast_log(LOG_ERROR, "ARI ChannelLeftBridge field application failed validation\n");
+                               ast_log(LOG_ERROR, "ARI ChannelLeftBridge field type failed validation\n");
                                res = 0;
                        }
                } else
-               if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
+               if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
                        int prop_is_valid;
-                       prop_is_valid = ari_validate_date(
+                       has_application = 1;
+                       prop_is_valid = ari_validate_string(
                                ast_json_object_iter_value(iter));
                        if (!prop_is_valid) {
-                               ast_log(LOG_ERROR, "ARI ChannelLeftBridge field timestamp failed validation\n");
+                               ast_log(LOG_ERROR, "ARI ChannelLeftBridge field application failed validation\n");
                                res = 0;
                        }
                } else
-               if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
+               if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
                        int prop_is_valid;
-                       has_type = 1;
-                       prop_is_valid = ari_validate_string(
+                       prop_is_valid = ari_validate_date(
                                ast_json_object_iter_value(iter));
                        if (!prop_is_valid) {
-                               ast_log(LOG_ERROR, "ARI ChannelLeftBridge field type failed validation\n");
+                               ast_log(LOG_ERROR, "ARI ChannelLeftBridge field timestamp failed validation\n");
                                res = 0;
                        }
                } else
@@ -1951,13 +1951,13 @@ int ari_validate_channel_left_bridge(struct ast_json *json)
                }
        }
 
-       if (!has_application) {
-               ast_log(LOG_ERROR, "ARI ChannelLeftBridge missing required field application\n");
+       if (!has_type) {
+               ast_log(LOG_ERROR, "ARI ChannelLeftBridge missing required field type\n");
                res = 0;
        }
 
-       if (!has_type) {
-               ast_log(LOG_ERROR, "ARI ChannelLeftBridge missing required field type\n");
+       if (!has_application) {
+               ast_log(LOG_ERROR, "ARI ChannelLeftBridge missing required field application\n");
                res = 0;
        }
 
@@ -1983,37 +1983,37 @@ int ari_validate_channel_state_change(struct ast_json *json)
 {
        int res = 1;
        struct ast_json_iter *iter;
-       int has_application = 0;
        int has_type = 0;
+       int has_application = 0;
        int has_channel = 0;
 
        for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
-               if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
+               if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
                        int prop_is_valid;
-                       has_application = 1;
+                       has_type = 1;
                        prop_is_valid = ari_validate_string(
                                ast_json_object_iter_value(iter));
                        if (!prop_is_valid) {
-                               ast_log(LOG_ERROR, "ARI ChannelStateChange field application failed validation\n");
+                               ast_log(LOG_ERROR, "ARI ChannelStateChange field type failed validation\n");
                                res = 0;
                        }
                } else
-               if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
+               if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
                        int prop_is_valid;
-                       prop_is_valid = ari_validate_date(
+                       has_application = 1;
+                       prop_is_valid = ari_validate_string(
                                ast_json_object_iter_value(iter));
                        if (!prop_is_valid) {
-                               ast_log(LOG_ERROR, "ARI ChannelStateChange field timestamp failed validation\n");
+                               ast_log(LOG_ERROR, "ARI ChannelStateChange field application failed validation\n");
                                res = 0;
                        }
                } else
-               if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
+               if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
                        int prop_is_valid;
-                       has_type = 1;
-                       prop_is_valid = ari_validate_string(
+                       prop_is_valid = ari_validate_date(
                                ast_json_object_iter_value(iter));
                        if (!prop_is_valid) {
-                               ast_log(LOG_ERROR, "ARI ChannelStateChange field type failed validation\n");
+                               ast_log(LOG_ERROR, "ARI ChannelStateChange field timestamp failed validation\n");
                                res = 0;
                        }
                } else
@@ -2035,13 +2035,13 @@ int ari_validate_channel_state_change(struct ast_json *json)
                }
        }
 
-       if (!has_application) {
-               ast_log(LOG_ERROR, "ARI ChannelStateChange missing required field application\n");
+       if (!has_type) {
+               ast_log(LOG_ERROR, "ARI ChannelStateChange missing required field type\n");
                res = 0;
        }
 
-       if (!has_type) {
-               ast_log(LOG_ERROR, "ARI ChannelStateChange missing required field type\n");
+       if (!has_application) {
+               ast_log(LOG_ERROR, "ARI ChannelStateChange missing required field application\n");
                res = 0;
        }
 
@@ -2062,38 +2062,38 @@ int ari_validate_channel_userevent(struct ast_json *json)
 {
        int res = 1;
        struct ast_json_iter *iter;
-       int has_application = 0;
        int has_type = 0;
+       int has_application = 0;
        int has_channel = 0;
        int has_eventname = 0;
 
        for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
-               if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
+               if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
                        int prop_is_valid;
-                       has_application = 1;
+                       has_type = 1;
                        prop_is_valid = ari_validate_string(
                                ast_json_object_iter_value(iter));
                        if (!prop_is_valid) {
-                               ast_log(LOG_ERROR, "ARI ChannelUserevent field application failed validation\n");
+                               ast_log(LOG_ERROR, "ARI ChannelUserevent field type failed validation\n");
                                res = 0;
                        }
                } else
-               if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
+               if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
                        int prop_is_valid;
-                       prop_is_valid = ari_validate_date(
+                       has_application = 1;
+                       prop_is_valid = ari_validate_string(
                                ast_json_object_iter_value(iter));
                        if (!prop_is_valid) {
-                               ast_log(LOG_ERROR, "ARI ChannelUserevent field timestamp failed validation\n");
+                               ast_log(LOG_ERROR, "ARI ChannelUserevent field application failed validation\n");
                                res = 0;
                        }
                } else
-               if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
+               if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
                        int prop_is_valid;
-                       has_type = 1;
-                       prop_is_valid = ari_validate_string(
+                       prop_is_valid = ari_validate_date(
                                ast_json_object_iter_value(iter));
                        if (!prop_is_valid) {
-                               ast_log(LOG_ERROR, "ARI ChannelUserevent field type failed validation\n");
+                               ast_log(LOG_ERROR, "ARI ChannelUserevent field timestamp failed validation\n");
                                res = 0;
                        }
                } else
@@ -2125,13 +2125,13 @@ int ari_validate_channel_userevent(struct ast_json *json)
                }
        }
 
-       if (!has_application) {
-               ast_log(LOG_ERROR, "ARI ChannelUserevent missing required field application\n");
+       if (!has_type) {
+               ast_log(LOG_ERROR, "ARI ChannelUserevent missing required field type\n");
                res = 0;
        }
 
-       if (!has_type) {
-               ast_log(LOG_ERROR, "ARI ChannelUserevent missing required field type\n");
+       if (!has_application) {
+               ast_log(LOG_ERROR, "ARI ChannelUserevent missing required field application\n");
                res = 0;
        }
 
@@ -2157,38 +2157,38 @@ int ari_validate_channel_varset(struct ast_json *json)
 {
        int res = 1;
        struct ast_json_iter *iter;
-       int has_application = 0;
        int has_type = 0;
+       int has_application = 0;
        int has_value = 0;
        int has_variable = 0;
 
        for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
-               if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
+               if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
                        int prop_is_valid;
-                       has_application = 1;
+                       has_type = 1;
                        prop_is_valid = ari_validate_string(
                                ast_json_object_iter_value(iter));
                        if (!prop_is_valid) {
-                               ast_log(LOG_ERROR, "ARI ChannelVarset field application failed validation\n");
+                               ast_log(LOG_ERROR, "ARI ChannelVarset field type failed validation\n");
                                res = 0;
                        }
                } else
-               if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
+               if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
                        int prop_is_valid;
-                       prop_is_valid = ari_validate_date(
+                       has_application = 1;
+                       prop_is_valid = ari_validate_string(
                                ast_json_object_iter_value(iter));
                        if (!prop_is_valid) {
-                               ast_log(LOG_ERROR, "ARI ChannelVarset field timestamp failed validation\n");
+                               ast_log(LOG_ERROR, "ARI ChannelVarset field application failed validation\n");
                                res = 0;
                        }
                } else
-               if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
+               if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
                        int prop_is_valid;
-                       has_type = 1;
-                       prop_is_valid = ari_validate_string(
+                       prop_is_valid = ari_validate_date(
                                ast_json_object_iter_value(iter));
                        if (!prop_is_valid) {
-                               ast_log(LOG_ERROR, "ARI ChannelVarset field type failed validation\n");
+                               ast_log(LOG_ERROR, "ARI ChannelVarset field timestamp failed validation\n");
                                res = 0;
                        }
                } else
@@ -2229,13 +2229,13 @@ int ari_validate_channel_varset(struct ast_json *json)
                }
        }
 
-       if (!has_application) {
-               ast_log(LOG_ERROR, "ARI ChannelVarset missing required field application\n");
+       if (!has_type) {
+               ast_log(LOG_ERROR, "ARI ChannelVarset missing required field type\n");
                res = 0;
        }
 
-       if (!has_type) {
-               ast_log(LOG_ERROR, "ARI ChannelVarset missing required field type\n");
+       if (!has_application) {
+               ast_log(LOG_ERROR, "ARI ChannelVarset missing required field application\n");
                res = 0;
        }
 
@@ -2261,8 +2261,8 @@ int ari_validate_event(struct ast_json *json)
 {
        int res = 1;
        struct ast_json_iter *iter;
-       int has_application = 0;
        int has_type = 0;
+       int has_application = 0;
        const char *discriminator;
 
        discriminator = ast_json_string_get(ast_json_object_get(json, "type"));
@@ -2338,6 +2338,16 @@ int ari_validate_event(struct ast_json *json)
        }
 
        for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
+               if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
+                       int prop_is_valid;
+                       has_type = 1;
+                       prop_is_valid = ari_validate_string(
+                               ast_json_object_iter_value(iter));
+                       if (!prop_is_valid) {
+                               ast_log(LOG_ERROR, "ARI Event field type failed validation\n");
+                               res = 0;
+                       }
+               } else
                if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
                        int prop_is_valid;
                        has_application = 1;
@@ -2357,77 +2367,239 @@ int ari_validate_event(struct ast_json *json)
                                res = 0;
                        }
                } else
+               {
+                       ast_log(LOG_ERROR,
+                               "ARI Event has undocumented field %s\n",
+                               ast_json_object_iter_key(iter));
+                       res = 0;
+               }
+       }
+
+       if (!has_type) {
+               ast_log(LOG_ERROR, "ARI Event missing required field type\n");
+               res = 0;
+       }
+
+       if (!has_application) {
+               ast_log(LOG_ERROR, "ARI Event missing required field application\n");
+               res = 0;
+       }
+
+       return res;
+}
+
+ari_validator ari_validate_event_fn(void)
+{
+       return ari_validate_event;
+}
+
+int ari_validate_message(struct ast_json *json)
+{
+       int res = 1;
+       struct ast_json_iter *iter;
+       int has_type = 0;
+       const char *discriminator;
+
+       discriminator = ast_json_string_get(ast_json_object_get(json, "type"));
+       if (!discriminator) {
+               ast_log(LOG_ERROR, "ARI Message missing required field type");
+               return 0;
+       }
+
+       if (strcmp("Message", discriminator) == 0) {
+               /* Self type; fall through */
+       } else
+       if (strcmp("ApplicationReplaced", discriminator) == 0) {
+               return ari_validate_application_replaced(json);
+       } else
+       if (strcmp("BridgeCreated", discriminator) == 0) {
+               return ari_validate_bridge_created(json);
+       } else
+       if (strcmp("BridgeDestroyed", discriminator) == 0) {
+               return ari_validate_bridge_destroyed(json);
+       } else
+       if (strcmp("BridgeMerged", discriminator) == 0) {
+               return ari_validate_bridge_merged(json);
+       } else
+       if (strcmp("ChannelCallerId", discriminator) == 0) {
+               return ari_validate_channel_caller_id(json);
+       } else
+       if (strcmp("ChannelCreated", discriminator) == 0) {
+               return ari_validate_channel_created(json);
+       } else
+       if (strcmp("ChannelDestroyed", discriminator) == 0) {
+               return ari_validate_channel_destroyed(json);
+       } else
+       if (strcmp("ChannelDialplan", discriminator) == 0) {
+               return ari_validate_channel_dialplan(json);
+       } else
+       if (strcmp("ChannelDtmfReceived", discriminator) == 0) {
+               return ari_validate_channel_dtmf_received(json);
+       } else
+       if (strcmp("ChannelEnteredBridge", discriminator) == 0) {
+               return ari_validate_channel_entered_bridge(json);
+       } else
+       if (strcmp("ChannelHangupRequest", discriminator) == 0) {
+               return ari_validate_channel_hangup_request(json);
+       } else
+       if (strcmp("ChannelLeftBridge", discriminator) == 0) {
+               return ari_validate_channel_left_bridge(json);
+       } else
+       if (strcmp("ChannelStateChange", discriminator) == 0) {
+               return ari_validate_channel_state_change(json);
+       } else
+       if (strcmp("ChannelUserevent", discriminator) == 0) {
+               return ari_validate_channel_userevent(json);
+       } else
+       if (strcmp("ChannelVarset", discriminator) == 0) {
+               return ari_validate_channel_varset(json);
+       } else
+       if (strcmp("Event", discriminator) == 0) {
+               return ari_validate_event(json);
+       } else
+       if (strcmp("MissingParams", discriminator) == 0) {
+               return ari_validate_missing_params(json);
+       } else
+       if (strcmp("PlaybackFinished", discriminator) == 0) {
+               return ari_validate_playback_finished(json);
+       } else
+       if (strcmp("PlaybackStarted", discriminator) == 0) {
+               return ari_validate_playback_started(json);
+       } else
+       if (strcmp("StasisEnd", discriminator) == 0) {
+               return ari_validate_stasis_end(json);
+       } else
+       if (strcmp("StasisStart", discriminator) == 0) {
+               return ari_validate_stasis_start(json);
+       } else
+       {
+               ast_log(LOG_ERROR, "ARI Message has undocumented subtype %s\n",
+                       discriminator);
+               res = 0;
+       }
+
+       for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
                if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
                        int prop_is_valid;
                        has_type = 1;
                        prop_is_valid = ari_validate_string(
                                ast_json_object_iter_value(iter));
                        if (!prop_is_valid) {
-                               ast_log(LOG_ERROR, "ARI Event field type failed validation\n");
+                               ast_log(LOG_ERROR, "ARI Message field type failed validation\n");
                                res = 0;
                        }
                } else
                {
                        ast_log(LOG_ERROR,
-                               "ARI Event has undocumented field %s\n",
+                               "ARI Message has undocumented field %s\n",
                                ast_json_object_iter_key(iter));
                        res = 0;
                }
        }
 
-       if (!has_application) {
-               ast_log(LOG_ERROR, "ARI Event missing required field application\n");
+       if (!has_type) {
+               ast_log(LOG_ERROR, "ARI Message missing required field type\n");
                res = 0;
        }
 
+       return res;
+}
+
+ari_validator ari_validate_message_fn(void)
+{
+       return ari_validate_message;
+}
+
+int ari_validate_missing_params(struct ast_json *json)
+{
+       int res = 1;
+       struct ast_json_iter *iter;
+       int has_type = 0;
+       int has_params = 0;
+
+       for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
+               if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
+                       int prop_is_valid;
+                       has_type = 1;
+                       prop_is_valid = ari_validate_string(
+                               ast_json_object_iter_value(iter));
+                       if (!prop_is_valid) {
+                               ast_log(LOG_ERROR, "ARI MissingParams field type failed validation\n");
+                               res = 0;
+                       }
+               } else
+               if (strcmp("params", ast_json_object_iter_key(iter)) == 0) {
+                       int prop_is_valid;
+                       has_params = 1;
+                       prop_is_valid = ari_validate_list(
+                               ast_json_object_iter_value(iter),
+                               ari_validate_string);
+                       if (!prop_is_valid) {
+                               ast_log(LOG_ERROR, "ARI MissingParams field params failed validation\n");
+                               res = 0;
+                       }
+               } else
+               {
+                       ast_log(LOG_ERROR,
+                               "ARI MissingParams has undocumented field %s\n",
+                               ast_json_object_iter_key(iter));
+                       res = 0;
+               }
+       }
+
        if (!has_type) {
-               ast_log(LOG_ERROR, "ARI Event missing required field type\n");
+               ast_log(LOG_ERROR, "ARI MissingParams missing required field type\n");
+               res = 0;
+       }
+
+       if (!has_params) {
+               ast_log(LOG_ERROR, "ARI MissingParams missing required field params\n");
                res = 0;
        }
 
        return res;
 }
 
-ari_validator ari_validate_event_fn(void)
+ari_validator ari_validate_missing_params_fn(void)
 {
-       return ari_validate_event;
+       return ari_validate_missing_params;
 }
 
 int ari_validate_playback_finished(struct ast_json *json)
 {
        int res = 1;
        struct ast_json_iter *iter;
-       int has_application = 0;
        int has_type = 0;
+       int has_application = 0;
        int has_playback = 0;
 
        for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
-               if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
+               if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
                        int prop_is_valid;
-                       has_application = 1;
+                       has_type = 1;
                        prop_is_valid = ari_validate_string(
                                ast_json_object_iter_value(iter));
                        if (!prop_is_valid) {
-                               ast_log(LOG_ERROR, "ARI PlaybackFinished field application failed validation\n");
+                               ast_log(LOG_ERROR, "ARI PlaybackFinished field type failed validation\n");
                                res = 0;
                        }
                } else
-               if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
+               if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
                        int prop_is_valid;
-                       prop_is_valid = ari_validate_date(
+                       has_application = 1;
+                       prop_is_valid = ari_validate_string(
                                ast_json_object_iter_value(iter));
                        if (!prop_is_valid) {
-                               ast_log(LOG_ERROR, "ARI PlaybackFinished field timestamp failed validation\n");
+                               ast_log(LOG_ERROR, "ARI PlaybackFinished field application failed validation\n");
                                res = 0;
                        }
                } else
-               if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
+               if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
                        int prop_is_valid;
-                       has_type = 1;
-                       prop_is_valid = ari_validate_string(
+                       prop_is_valid = ari_validate_date(
                                ast_json_object_iter_value(iter));
                        if (!prop_is_valid) {
-                               ast_log(LOG_ERROR, "ARI PlaybackFinished field type failed validation\n");
+                               ast_log(LOG_ERROR, "ARI PlaybackFinished field timestamp failed validation\n");
                                res = 0;
                        }
                } else
@@ -2449,13 +2621,13 @@ int ari_validate_playback_finished(struct ast_json *json)
                }
        }
 
-       if (!has_application) {
-               ast_log(LOG_ERROR, "ARI PlaybackFinished missing required field application\n");
+       if (!has_type) {
+               ast_log(LOG_ERROR, "ARI PlaybackFinished missing required field type\n");
                res = 0;
        }
 
-       if (!has_type) {
-               ast_log(LOG_ERROR, "ARI PlaybackFinished missing required field type\n");
+       if (!has_application) {
+               ast_log(LOG_ERROR, "ARI PlaybackFinished missing required field application\n");
                res = 0;
        }
 
@@ -2476,37 +2648,37 @@ int ari_validate_playback_started(struct ast_json *json)
 {
        int res = 1;
        struct ast_json_iter *iter;
-       int has_application = 0;
        int has_type = 0;
+       int has_application = 0;
        int has_playback = 0;
 
        for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
-               if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
+               if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
                        int prop_is_valid;
-                       has_application = 1;
+                       has_type = 1;
                        prop_is_valid = ari_validate_string(
                                ast_json_object_iter_value(iter));
                        if (!prop_is_valid) {
-                               ast_log(LOG_ERROR, "ARI PlaybackStarted field application failed validation\n");
+                               ast_log(LOG_ERROR, "ARI PlaybackStarted field type failed validation\n");
                                res = 0;
                        }
                } else
-               if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
+               if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
                        int prop_is_valid;
-                       prop_is_valid = ari_validate_date(
+                       has_application = 1;
+                       prop_is_valid = ari_validate_string(
                                ast_json_object_iter_value(iter));
                        if (!prop_is_valid) {
-                               ast_log(LOG_ERROR, "ARI PlaybackStarted field timestamp failed validation\n");
+                               ast_log(LOG_ERROR, "ARI PlaybackStarted field application failed validation\n");
                                res = 0;
                        }
                } else
-               if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
+               if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
                        int prop_is_valid;
-                       has_type = 1;
-                       prop_is_valid = ari_validate_string(
+                       prop_is_valid = ari_validate_date(
                                ast_json_object_iter_value(iter));
                        if (!prop_is_valid) {
-                               ast_log(LOG_ERROR, "ARI PlaybackStarted field type failed validation\n");
+                               ast_log(LOG_ERROR, "ARI PlaybackStarted field timestamp failed validation\n");
                                res = 0;
                        }
                } else
@@ -2528,13 +2700,13 @@ int ari_validate_playback_started(struct ast_json *json)
                }
        }
 
-       if (!has_application) {
-               ast_log(LOG_ERROR, "ARI PlaybackStarted missing required field application\n");
+       if (!has_type) {
+               ast_log(LOG_ERROR, "ARI PlaybackStarted missing required field type\n");
                res = 0;
        }
 
-       if (!has_type) {
-               ast_log(LOG_ERROR, "ARI PlaybackStarted missing required field type\n");
+       if (!has_application) {
+               ast_log(LOG_ERROR, "ARI PlaybackStarted missing required field application\n");
                res = 0;
        }
 
@@ -2555,37 +2727,37 @@ int ari_validate_stasis_end(struct ast_json *json)
 {
        int res = 1;
        struct ast_json_iter *iter;
-       int has_application = 0;
        int has_type = 0;
+       int has_application = 0;
        int has_channel = 0;
 
        for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
-               if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
+               if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
                        int prop_is_valid;
-                       has_application = 1;
+                       has_type = 1;
                        prop_is_valid = ari_validate_string(
                                ast_json_object_iter_value(iter));
                        if (!prop_is_valid) {
-                               ast_log(LOG_ERROR, "ARI StasisEnd field application failed validation\n");
+                               ast_log(LOG_ERROR, "ARI StasisEnd field type failed validation\n");
                                res = 0;
                        }
                } else
-               if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
+               if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
                        int prop_is_valid;
-                       prop_is_valid = ari_validate_date(
+                       has_application = 1;
+                       prop_is_valid = ari_validate_string(
                                ast_json_object_iter_value(iter));
                        if (!prop_is_valid) {
-                               ast_log(LOG_ERROR, "ARI StasisEnd field timestamp failed validation\n");
+                               ast_log(LOG_ERROR, "ARI StasisEnd field application failed validation\n");
                                res = 0;
                        }
                } else
-               if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
+               if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
                        int prop_is_valid;
-                       has_type = 1;
-                       prop_is_valid = ari_validate_string(
+                       prop_is_valid = ari_validate_date(
                                ast_json_object_iter_value(iter));
                        if (!prop_is_valid) {
-                               ast_log(LOG_ERROR, "ARI StasisEnd field type failed validation\n");
+                               ast_log(LOG_ERROR, "ARI StasisEnd field timestamp failed validation\n");
                                res = 0;
                        }
                } else
@@ -2607,13 +2779,13 @@ int ari_validate_stasis_end(struct ast_json *json)
                }
        }
 
-       if (!has_application) {
-               ast_log(LOG_ERROR, "ARI StasisEnd missing required field application\n");
+       if (!has_type) {
+               ast_log(LOG_ERROR, "ARI StasisEnd missing required field type\n");
                res = 0;
        }
 
-       if (!has_type) {
-               ast_log(LOG_ERROR, "ARI StasisEnd missing required field type\n");
+       if (!has_application) {
+               ast_log(LOG_ERROR, "ARI StasisEnd missing required field application\n");
                res = 0;
        }
 
@@ -2634,38 +2806,38 @@ int ari_validate_stasis_start(struct ast_json *json)
 {
        int res = 1;
        struct ast_json_iter *iter;
-       int has_application = 0;
        int has_type = 0;
+       int has_application = 0;
        int has_args = 0;
        int has_channel = 0;
 
        for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
-               if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
+               if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
                        int prop_is_valid;
-                       has_application = 1;
+                       has_type = 1;
                        prop_is_valid = ari_validate_string(
                                ast_json_object_iter_value(iter));
                        if (!prop_is_valid) {
-                               ast_log(LOG_ERROR, "ARI StasisStart field application failed validation\n");
+                               ast_log(LOG_ERROR, "ARI StasisStart field type failed validation\n");
                                res = 0;
                        }
                } else
-               if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
+               if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
                        int prop_is_valid;
-                       prop_is_valid = ari_validate_date(
+                       has_application = 1;
+                       prop_is_valid = ari_validate_string(
                                ast_json_object_iter_value(iter));
                        if (!prop_is_valid) {
-                               ast_log(LOG_ERROR, "ARI StasisStart field timestamp failed validation\n");
+                               ast_log(LOG_ERROR, "ARI StasisStart field application failed validation\n");
                                res = 0;
                        }
                } else
-               if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
+               if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
                        int prop_is_valid;
-                       has_type = 1;
-                       prop_is_valid = ari_validate_string(
+                       prop_is_valid = ari_validate_date(
                                ast_json_object_iter_value(iter));
                        if (!prop_is_valid) {
-                               ast_log(LOG_ERROR, "ARI StasisStart field type failed validation\n");
+                               ast_log(LOG_ERROR, "ARI StasisStart field timestamp failed validation\n");
                                res = 0;
                        }
                } else
@@ -2698,13 +2870,13 @@ int ari_validate_stasis_start(struct ast_json *json)
                }
        }
 
-       if (!has_application) {
-               ast_log(LOG_ERROR, "ARI StasisStart missing required field application\n");
+       if (!has_type) {
+               ast_log(LOG_ERROR, "ARI StasisStart missing required field type\n");
                res = 0;
        }
 
-       if (!has_type) {
-               ast_log(LOG_ERROR, "ARI StasisStart missing required field type\n");
+       if (!has_application) {
+               ast_log(LOG_ERROR, "ARI StasisStart missing required field application\n");
                res = 0;
        }