[asterisk-commits] dlee: branch dlee/ASTERISK-22451-ari-subscribe r398819 - in /team/dlee/ASTERI...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Sep 11 12:55:14 CDT 2013


Author: dlee
Date: Wed Sep 11 12:55:12 2013
New Revision: 398819

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=398819
Log:
Fix UserEvent validations

Modified:
    team/dlee/ASTERISK-22451-ari-subscribe/res/ari/ari_model_validators.c
    team/dlee/ASTERISK-22451-ari-subscribe/res/ari/ari_model_validators.h
    team/dlee/ASTERISK-22451-ari-subscribe/res/res_ari_model.c
    team/dlee/ASTERISK-22451-ari-subscribe/rest-api-templates/ari_model_validators.h.mustache
    team/dlee/ASTERISK-22451-ari-subscribe/rest-api/api-docs/events.json

Modified: team/dlee/ASTERISK-22451-ari-subscribe/res/ari/ari_model_validators.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ASTERISK-22451-ari-subscribe/res/ari/ari_model_validators.c?view=diff&rev=398819&r1=398818&r2=398819
==============================================================================
--- team/dlee/ASTERISK-22451-ari-subscribe/res/ari/ari_model_validators.c (original)
+++ team/dlee/ASTERISK-22451-ari-subscribe/res/ari/ari_model_validators.c Wed Sep 11 12:55:12 2013
@@ -2530,6 +2530,7 @@
 	int has_application = 0;
 	int has_channel = 0;
 	int has_eventname = 0;
+	int has_userevent = 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) {
@@ -2581,6 +2582,16 @@
 				res = 0;
 			}
 		} else
+		if (strcmp("userevent", ast_json_object_iter_key(iter)) == 0) {
+			int prop_is_valid;
+			has_userevent = 1;
+			prop_is_valid = ast_ari_validate_object(
+				ast_json_object_iter_value(iter));
+			if (!prop_is_valid) {
+				ast_log(LOG_ERROR, "ARI ChannelUserevent field userevent failed validation\n");
+				res = 0;
+			}
+		} else
 		{
 			ast_log(LOG_ERROR,
 				"ARI ChannelUserevent has undocumented field %s\n",
@@ -2606,6 +2617,11 @@
 
 	if (!has_eventname) {
 		ast_log(LOG_ERROR, "ARI ChannelUserevent missing required field eventname\n");
+		res = 0;
+	}
+
+	if (!has_userevent) {
+		ast_log(LOG_ERROR, "ARI ChannelUserevent missing required field userevent\n");
 		res = 0;
 	}
 

Modified: team/dlee/ASTERISK-22451-ari-subscribe/res/ari/ari_model_validators.h
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ASTERISK-22451-ari-subscribe/res/ari/ari_model_validators.h?view=diff&rev=398819&r1=398818&r2=398819
==============================================================================
--- team/dlee/ASTERISK-22451-ari-subscribe/res/ari/ari_model_validators.h (original)
+++ team/dlee/ASTERISK-22451-ari-subscribe/res/ari/ari_model_validators.h Wed Sep 11 12:55:12 2013
@@ -53,6 +53,15 @@
  * \returns False (zero) if invalid.
  */
 int ast_ari_validate_void(struct ast_json *json);
+
+/*!
+ * \brief Validator for native Swagger object.
+ *
+ * \param json JSON object to validate.
+ * \returns True (non-zero) if valid.
+ * \returns False (zero) if invalid.
+ */
+int ast_ari_validate_object(struct ast_json *json);
 
 /*!
  * \brief Validator for native Swagger byte.
@@ -1053,6 +1062,7 @@
  * - timestamp: Date
  * - channel: Channel (required)
  * - eventname: string (required)
+ * - userevent: object (required)
  * ChannelVarset
  * - type: string (required)
  * - application: string (required)

Modified: team/dlee/ASTERISK-22451-ari-subscribe/res/res_ari_model.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ASTERISK-22451-ari-subscribe/res/res_ari_model.c?view=diff&rev=398819&r1=398818&r2=398819
==============================================================================
--- team/dlee/ASTERISK-22451-ari-subscribe/res/res_ari_model.c (original)
+++ team/dlee/ASTERISK-22451-ari-subscribe/res/res_ari_model.c Wed Sep 11 12:55:12 2013
@@ -93,6 +93,11 @@
 int ast_ari_validate_void(struct ast_json *json)
 {
 	return check_type(json, AST_JSON_NULL);
+}
+
+int ast_ari_validate_object(struct ast_json *json)
+{
+	return check_type(json, AST_JSON_OBJECT);
 }
 
 int ast_ari_validate_byte(struct ast_json *json)

Modified: team/dlee/ASTERISK-22451-ari-subscribe/rest-api-templates/ari_model_validators.h.mustache
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ASTERISK-22451-ari-subscribe/rest-api-templates/ari_model_validators.h.mustache?view=diff&rev=398819&r1=398818&r2=398819
==============================================================================
--- team/dlee/ASTERISK-22451-ari-subscribe/rest-api-templates/ari_model_validators.h.mustache (original)
+++ team/dlee/ASTERISK-22451-ari-subscribe/rest-api-templates/ari_model_validators.h.mustache Wed Sep 11 12:55:12 2013
@@ -51,6 +51,15 @@
  * \returns False (zero) if invalid.
  */
 int ast_ari_validate_void(struct ast_json *json);
+
+/*!
+ * \brief Validator for native Swagger object.
+ *
+ * \param json JSON object to validate.
+ * \returns True (non-zero) if valid.
+ * \returns False (zero) if invalid.
+ */
+int ast_ari_validate_object(struct ast_json *json);
 
 /*!
  * \brief Validator for native Swagger byte.

Modified: team/dlee/ASTERISK-22451-ari-subscribe/rest-api/api-docs/events.json
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ASTERISK-22451-ari-subscribe/rest-api/api-docs/events.json?view=diff&rev=398819&r1=398818&r2=398819
==============================================================================
--- team/dlee/ASTERISK-22451-ari-subscribe/rest-api/api-docs/events.json (original)
+++ team/dlee/ASTERISK-22451-ari-subscribe/rest-api/api-docs/events.json Wed Sep 11 12:55:12 2013
@@ -293,6 +293,11 @@
 					"required": true,
 					"type": "Channel",
 					"description": "The channel that signaled the user event."
+				},
+				"userevent": {
+					"required": true,
+					"type": "object",
+					"description": "Custom Userevent data"
 				}
 			}
 		},




More information about the asterisk-commits mailing list