From f6de504c3f6e3451469c19b5eea2012176596fc6 Mon Sep 17 00:00:00 2001 From: Spencer Alger Date: Thu, 9 Jan 2014 16:17:19 -0700 Subject: [PATCH] added a check to the js_api generator that will ensure that each url has a unique variable signature. --- scripts/generate/js_api.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scripts/generate/js_api.js b/scripts/generate/js_api.js index ed6926643..46cb6ffa7 100644 --- a/scripts/generate/js_api.js +++ b/scripts/generate/js_api.js @@ -151,6 +151,7 @@ module.exports = function (done) { } var urls = _.difference(def.url.paths, aliases[name]); + var urlSignatures = []; urls = _.map(urls, function (url) { var optionalVars = {}; var requiredVars = {}; @@ -170,6 +171,8 @@ module.exports = function (done) { target[name] = _.omit(param, 'required', 'description', 'name'); } + urlSignatures.push(_.union(_.keys(optionalVars), _.keys(requiredVars)).sort().join(':')); + return _.omit({ fmt: url.replace(urlParamRE, function (full, match) { return '<%=' + _.camelCase(match) + '%>'; @@ -182,6 +185,10 @@ module.exports = function (done) { }); }); + if (urlSignatures.length !== _.unique(urlSignatures).length) { + throw new Error('Multiple URLS with the same signature detected for ' + spec.name); + } + if (urls.length > 1) { spec.urls = _.map(_.sortBy(urls, 'sortOrder'), function (url) { return _.omit(url, 'sortOrder');