Document MissingParams error message for /ari/events
authorDavid M. Lee <dlee@digium.com>
Fri, 5 Jul 2013 19:15:27 +0000 (19:15 +0000)
committerDavid M. Lee <dlee@digium.com>
Fri, 5 Jul 2013 19:15:27 +0000 (19:15 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@393749 65c4cc65-6c06-0410-ace0-fbb531ad65f3

res/res_stasis_http_events.c
res/stasis_http/ari_model_validators.c
res/stasis_http/ari_model_validators.h
res/stasis_http/resource_events.c
rest-api/api-docs/events.json

index 7172e27..00e69db 100644 (file)
@@ -64,7 +64,7 @@ static void stasis_http_event_websocket_ws_cb(struct ast_websocket *ws_session,
        }
 #if defined(AST_DEVMODE)
        session = ari_websocket_session_create(ws_session,
-               ari_validate_event_fn());
+               ari_validate_message_fn());
 #else
        session = ari_websocket_session_create(ws_session, NULL);
 #endif
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;
        }
 
index 5375796..ee3d093 100644 (file)
@@ -656,6 +656,42 @@ int ari_validate_event(struct ast_json *json);
 ari_validator ari_validate_event_fn(void);
 
 /*!
+ * \brief Validator for Message.
+ *
+ * Base type for errors and events
+ *
+ * \param json JSON object to validate.
+ * \returns True (non-zero) if valid.
+ * \returns False (zero) if invalid.
+ */
+int ari_validate_message(struct ast_json *json);
+
+/*!
+ * \brief Function pointer to ari_validate_message().
+ *
+ * See \ref ari_model_validators.h for more details.
+ */
+ari_validator ari_validate_message_fn(void);
+
+/*!
+ * \brief Validator for MissingParams.
+ *
+ * Error event sent when required params are missing.
+ *
+ * \param json JSON object to validate.
+ * \returns True (non-zero) if valid.
+ * \returns False (zero) if invalid.
+ */
+int ari_validate_missing_params(struct ast_json *json);
+
+/*!
+ * \brief Function pointer to ari_validate_missing_params().
+ *
+ * See \ref ari_model_validators.h for more details.
+ */
+ari_validator ari_validate_missing_params_fn(void);
+
+/*!
  * \brief Validator for PlaybackFinished.
  *
  * Event showing the completion of a media playback operation.
@@ -780,118 +816,123 @@ ari_validator ari_validate_stasis_start_fn(void);
  * - state: string (required)
  * - target_uri: string (required)
  * ApplicationReplaced
+ * - type: string (required)
  * - application: string (required)
  * - timestamp: Date
- * - type: string (required)
  * BridgeCreated
+ * - type: string (required)
  * - application: string (required)
  * - timestamp: Date
- * - type: string (required)
  * - bridge: Bridge (required)
  * BridgeDestroyed
+ * - type: string (required)
  * - application: string (required)
  * - timestamp: Date
- * - type: string (required)
  * - bridge: Bridge (required)
  * BridgeMerged
+ * - type: string (required)
  * - application: string (required)
  * - timestamp: Date
- * - type: string (required)
  * - bridge: Bridge (required)
  * - bridge_from: Bridge (required)
  * ChannelCallerId
+ * - type: string (required)
  * - application: string (required)
  * - timestamp: Date
- * - type: string (required)
  * - caller_presentation: int (required)
  * - caller_presentation_txt: string (required)
  * - channel: Channel (required)
  * ChannelCreated
+ * - type: string (required)
  * - application: string (required)
  * - timestamp: Date
- * - type: string (required)
  * - channel: Channel (required)
  * ChannelDestroyed
+ * - type: string (required)
  * - application: string (required)
  * - timestamp: Date
- * - type: string (required)
  * - cause: int (required)
  * - cause_txt: string (required)
  * - channel: Channel (required)
  * ChannelDialplan
+ * - type: string (required)
  * - application: string (required)
  * - timestamp: Date
- * - type: string (required)
  * - channel: Channel (required)
  * - dialplan_app: string (required)
  * - dialplan_app_data: string (required)
  * ChannelDtmfReceived
+ * - type: string (required)
  * - application: string (required)
  * - timestamp: Date
- * - type: string (required)
  * - channel: Channel (required)
  * - digit: string (required)
  * - duration_ms: int (required)
  * ChannelEnteredBridge
+ * - type: string (required)
  * - application: string (required)
  * - timestamp: Date
- * - type: string (required)
  * - bridge: Bridge (required)
  * - channel: Channel
  * ChannelHangupRequest
+ * - type: string (required)
  * - application: string (required)
  * - timestamp: Date
- * - type: string (required)
  * - cause: int
  * - channel: Channel (required)
  * - soft: boolean
  * ChannelLeftBridge
+ * - type: string (required)
  * - application: string (required)
  * - timestamp: Date
- * - type: string (required)
  * - bridge: Bridge (required)
  * - channel: Channel (required)
  * ChannelStateChange
+ * - type: string (required)
  * - application: string (required)
  * - timestamp: Date
- * - type: string (required)
  * - channel: Channel (required)
  * ChannelUserevent
+ * - type: string (required)
  * - application: string (required)
  * - timestamp: Date
- * - type: string (required)
  * - channel: Channel (required)
  * - eventname: string (required)
  * ChannelVarset
+ * - type: string (required)
  * - application: string (required)
  * - timestamp: Date
- * - type: string (required)
  * - channel: Channel
  * - value: string (required)
  * - variable: string (required)
  * Event
+ * - type: string (required)
  * - application: string (required)
  * - timestamp: Date
+ * Message
+ * - type: string (required)
+ * MissingParams
  * - type: string (required)
+ * - params: List[string] (required)
  * PlaybackFinished
+ * - type: string (required)
  * - application: string (required)
  * - timestamp: Date
- * - type: string (required)
  * - playback: Playback (required)
  * PlaybackStarted
+ * - type: string (required)
  * - application: string (required)
  * - timestamp: Date
- * - type: string (required)
  * - playback: Playback (required)
  * StasisEnd
+ * - type: string (required)
  * - application: string (required)
  * - timestamp: Date
- * - type: string (required)
  * - channel: Channel (required)
  * StasisStart
+ * - type: string (required)
  * - application: string (required)
  * - timestamp: Date
- * - type: string (required)
  * - args: List[string] (required)
  * - channel: Channel (required)
  */
index 0412fd7..9e9bfab 100644 (file)
@@ -182,8 +182,8 @@ void ari_websocket_event_websocket(struct ari_websocket_session *ws_session,
                RAII_VAR(struct ast_json *, msg, NULL, ast_json_unref);
 
                msg = ast_json_pack("{s: s, s: [s]}",
-                                   "error", "MissingParams",
-                                   "params", "app");
+                       "type", "MissingParams",
+                       "params", "app");
                if (!msg) {
                        msg = ast_json_ref(ari_oom_json());
                }
index 79908ef..519bb7a 100644 (file)
@@ -17,7 +17,7 @@
                                        "websocketProtocol": "ari",
                                        "summary": "WebSocket connection for events.",
                                        "nickname": "eventWebsocket",
-                                       "responseClass": "Event",
+                                       "responseClass": "Message",
                                        "parameters": [
                                                {
                                                        "name": "app",
                }
        ],
        "models": {
-               "Event": {
-                       "id": "Event",
-                       "description": "Base type for asynchronous events from Asterisk.",
+               "Message": {
+                       "id": "Message",
+                       "description": "Base type for errors and events",
                        "discriminator": "type",
                        "properties": {
                                "type": {
                                        "type": "string",
                                        "required": true,
-                                       "description": "Indicates the type of this event."
-                               },
+                                       "description": "Indicates the type of this message."
+                               }
+                       }
+               },
+               "MissingParams": {
+                       "id": "MissingParams",
+                       "extends": "Message",
+                       "description": "Error event sent when required params are missing.",
+                       "properties": {
+                               "params": {
+                                       "required": true,
+                                       "type": "List[string]",
+                                       "description": "A list of the missing parameters"
+                               }
+                       }
+               },
+               "Event": {
+                       "id": "Event",
+                       "extends": "Message",
+                       "description": "Base type for asynchronous events from Asterisk.",
+                       "properties": {
                                "application": {
                                        "type": "string",
                                        "description": "Name of the application receiving the event.",