Add swagger UI
[vfc/nfvo/wfengine.git] / wfenginemgrservice / src / main / resources / api-doc / lib / swagger-client.js
diff --git a/wfenginemgrservice/src/main/resources/api-doc/lib/swagger-client.js b/wfenginemgrservice/src/main/resources/api-doc/lib/swagger-client.js
new file mode 100644 (file)
index 0000000..510464c
--- /dev/null
@@ -0,0 +1,3309 @@
+/*\r
+ * Copyright 2016 ZTE Corporation.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+/**\r
+ * swagger-client - swagger.js is a javascript client for use with swaggering APIs.\r
+ * @version v2.1.9-M1\r
+ * @link http://swagger.io\r
+ * @license apache 2.0\r
+ */\r
+(function(){\r
+var ArrayModel = function(definition) {\r
+  this.name = "arrayModel";\r
+  this.definition = definition || {};\r
+  this.properties = [];\r
+  \r
+  var requiredFields = definition.enum || [];\r
+  var innerType = definition.items;\r
+  if(innerType) {\r
+    if(innerType.type) {\r
+      this.type = typeFromJsonSchema(innerType.type, innerType.format);\r
+    }\r
+    else {\r
+      this.ref = innerType.$ref;\r
+    }\r
+  }\r
+  return this;\r
+};\r
+\r
+ArrayModel.prototype.createJSONSample = function(modelsToIgnore) {\r
+  var result;\r
+  modelsToIgnore = (modelsToIgnore||{});\r
+  if(this.type) {\r
+    result = this.type;\r
+  }\r
+  else if (this.ref) {\r
+    var name = simpleRef(this.ref);\r
+    if(typeof modelsToIgnore[name] === 'undefined') {\r
+      modelsToIgnore[name] = this;\r
+      result = models[name].createJSONSample(modelsToIgnore);\r
+    }\r
+    else {\r
+      return name;\r
+    }\r
+  }\r
+  return [ result ];\r
+};\r
+\r
+ArrayModel.prototype.getSampleValue = function(modelsToIgnore) {\r
+  var result;\r
+  modelsToIgnore = (modelsToIgnore || {});\r
+  if(this.type) {\r
+    result = type;\r
+  }\r
+  else if (this.ref) {\r
+    var name = simpleRef(this.ref);\r
+    result = models[name].getSampleValue(modelsToIgnore);\r
+  }\r
+  return [ result ];\r
+};\r
+\r
+ArrayModel.prototype.getMockSignature = function(modelsToIgnore) {\r
+  var propertiesStr = [];\r
+  var i, prop;\r
+  for (i = 0; i < this.properties.length; i++) {\r
+    prop = this.properties[i];\r
+    propertiesStr.push(prop.toString());\r
+  }\r
+\r
+  var strong = '<span class="strong">';\r
+  var stronger = '<span class="stronger">';\r
+  var strongClose = '</span>';\r
+  var classOpen = strong + 'array' + ' {' + strongClose;\r
+  var classClose = strong + '}' + strongClose;\r
+  var returnVal = classOpen + '<div>' + propertiesStr.join(',</div><div>') + '</div>' + classClose;\r
+\r
+  if (!modelsToIgnore)\r
+    modelsToIgnore = {};\r
+  modelsToIgnore[this.name] = this;\r
+  for (i = 0; i < this.properties.length; i++) {\r
+    prop = this.properties[i];\r
+    var ref = prop.$ref;\r
+    var model = models[ref];\r
+    if (model && typeof modelsToIgnore[ref] === 'undefined') {\r
+      returnVal = returnVal + ('<br>' + model.getMockSignature(modelsToIgnore));\r
+    }\r
+  }\r
+  return returnVal;\r
+};\r
+\r
+\r
+/**\r
+ * SwaggerAuthorizations applys the correct authorization to an operation being executed\r
+ */\r
+var SwaggerAuthorizations = function() {\r
+  this.authz = {};\r
+};\r
+\r
+SwaggerAuthorizations.prototype.add = function(name, auth) {\r
+  this.authz[name] = auth;\r
+  return auth;\r
+};\r
+\r
+SwaggerAuthorizations.prototype.remove = function(name) {\r
+  return delete this.authz[name];\r
+};\r
+\r
+SwaggerAuthorizations.prototype.apply = function (obj, authorizations) {\r
+  var status = null;\r
+  var key, name, value, result;\r
+\r
+  // if the "authorizations" key is undefined, or has an empty array, add all keys\r
+  if (typeof authorizations === 'undefined' || Object.keys(authorizations).length === 0) {\r
+    for (key in this.authz) {\r
+      value = this.authz[key];\r
+      result = value.apply(obj, authorizations);\r
+      if (result === true)\r
+        status = true;\r
+    }\r
+  }\r
+  else {\r
+    // 2.0 support\r
+    if (Array.isArray(authorizations)) {\r
+\r
+      for (var i = 0; i < authorizations.length; i++) {\r
+        var auth = authorizations[i];\r
+        for (name in auth) {\r
+          for (key in this.authz) {\r
+            if (key == name) {\r
+              value = this.authz[key];\r
+              result = value.apply(obj, authorizations);\r
+              if (result === true)\r
+                status = true;\r
+            }\r
+          }\r
+        }\r
+      }\r
+    }\r
+    else {\r
+      // 1.2 support\r
+      for (name in authorizations) {\r
+        for (key in this.authz) {\r
+          if (key == name) {\r
+            value = this.authz[key];\r
+            result = value.apply(obj, authorizations);\r
+            if (result === true)\r
+              status = true;\r
+          }\r
+        }\r
+      }\r
+    }\r
+  }\r
+\r
+  return status;\r
+};\r
+\r
+/**\r
+ * ApiKeyAuthorization allows a query param or header to be injected\r
+ */\r
+var ApiKeyAuthorization = function(name, value, type) {\r
+  this.name = name;\r
+  this.value = value;\r
+  this.type = type;\r
+};\r
+\r
+ApiKeyAuthorization.prototype.apply = function(obj, authorizations) {\r
+  if (this.type === "query") {\r
+    if (obj.url.indexOf('?') > 0)\r
+      obj.url = obj.url + "&" + this.name + "=" + this.value;\r
+    else\r
+      obj.url = obj.url + "?" + this.name + "=" + this.value;\r
+    return true;\r
+  } else if (this.type === "header") {\r
+    obj.headers[this.name] = this.value;\r
+    return true;\r
+  }\r
+};\r
+\r
+var CookieAuthorization = function(cookie) {\r
+  this.cookie = cookie;\r
+};\r
+\r
+CookieAuthorization.prototype.apply = function(obj, authorizations) {\r
+  obj.cookieJar = obj.cookieJar || CookieJar();\r
+  obj.cookieJar.setCookie(this.cookie);\r
+  return true;\r
+};\r
+\r
+/**\r
+ * Password Authorization is a basic auth implementation\r
+ */\r
+var PasswordAuthorization = function(name, username, password) {\r
+  this.name = name;\r
+  this.username = username;\r
+  this.password = password;\r
+  this._btoa = null;\r
+  if (typeof window !== 'undefined')\r
+    this._btoa = btoa;\r
+  else\r
+    this._btoa = require("btoa");\r
+};\r
+\r
+PasswordAuthorization.prototype.apply = function(obj, authorizations) {\r
+  var base64encoder = this._btoa;\r
+  obj.headers.Authorization = "Basic " + base64encoder(this.username + ":" + this.password);\r
+  return true;\r
+};\r
+var __bind = function(fn, me){\r
+  return function(){\r
+    return fn.apply(me, arguments);\r
+  };\r
+};\r
+\r
+fail = function(message) {\r
+  log(message);\r
+};\r
+\r
+log = function(){\r
+  log.history = log.history || [];\r
+  log.history.push(arguments);\r
+  if(this.console){\r
+    console.log( Array.prototype.slice.call(arguments)[0] );\r
+  }\r
+};\r
+\r
+if (!Array.prototype.indexOf) {\r
+  Array.prototype.indexOf = function(obj, start) {\r
+    for (var i = (start || 0), j = this.length; i < j; i++) {\r
+      if (this[i] === obj) { return i; }\r
+    }\r
+    return -1;\r
+  };\r
+}\r
+\r
+/**\r
+ * allows override of the default value based on the parameter being\r
+ * supplied\r
+ **/\r
+var applyParameterMacro = function (operation, parameter) {\r
+  var e = (typeof window !== 'undefined' ? window : exports);\r
+  if(e.parameterMacro)\r
+    return e.parameterMacro(operation, parameter);\r
+  else\r
+    return parameter.defaultValue;\r
+};\r
+\r
+/**\r
+ * allows overriding the default value of an model property\r
+ **/\r
+var applyModelPropertyMacro = function (model, property) {\r
+  var e = (typeof window !== 'undefined' ? window : exports);\r
+  if(e.modelPropertyMacro)\r
+    return e.modelPropertyMacro(model, property);\r
+  else\r
+    return property.defaultValue;\r
+};\r
+\r
+/**\r
+ * PrimitiveModel\r
+ **/\r
+var PrimitiveModel = function(definition) {\r
+  this.name = "name";\r
+  this.definition = definition || {};\r
+  this.properties = [];\r
+\r
+  var requiredFields = definition.enum || [];\r
+  this.type = typeFromJsonSchema(definition.type, definition.format);\r
+};\r
+\r
+PrimitiveModel.prototype.createJSONSample = function(modelsToIgnore) {\r
+  var result = this.type;\r
+  return result;\r
+};\r
+\r
+PrimitiveModel.prototype.getSampleValue = function() {\r
+  var result = this.type;\r
+  return null;\r
+};\r
+\r
+PrimitiveModel.prototype.getMockSignature = function(modelsToIgnore) {\r
+  var propertiesStr = [];\r
+  var i, prop;\r
+  for (i = 0; i < this.properties.length; i++) {\r
+    prop = this.properties[i];\r
+    propertiesStr.push(prop.toString());\r
+  }\r
+\r
+  var strong = '<span class="strong">';\r
+  var stronger = '<span class="stronger">';\r
+  var strongClose = '</span>';\r
+  var classOpen = strong + this.name + ' {' + strongClose;\r
+  var classClose = strong + '}' + strongClose;\r
+  var returnVal = classOpen + '<div>' + propertiesStr.join(',</div><div>') + '</div>' + classClose;\r
+\r
+  if (!modelsToIgnore)\r
+    modelsToIgnore = {};\r
+  modelsToIgnore[this.name] = this;\r
+  for (i = 0; i < this.properties.length; i++) {\r
+    prop = this.properties[i];\r
+    var ref = prop.$ref;\r
+    var model = models[ref];\r
+    if (model && typeof modelsToIgnore[ref] === 'undefined') {\r
+      returnVal = returnVal + ('<br>' + model.getMockSignature(modelsToIgnore));\r
+    }\r
+  }\r
+  return returnVal;\r
+};\r
+/** \r
+ * Resolves a spec's remote references\r
+ */\r
+var Resolver = function (){};\r
+\r
+Resolver.prototype.resolve = function(spec, callback, scope) {\r
+  this.scope = (scope || this);\r
+  var host, name, path, property, propertyName, type;\r
+  var processedCalls = 0, resolvedRefs = {}, unresolvedRefs = {};\r
+\r
+  // store objects for dereferencing\r
+  var resolutionTable = {};\r
+\r
+  // models\r
+  for(name in spec.definitions) {\r
+    var model = spec.definitions[name];\r
+    for(propertyName in model.properties) {\r
+      property = model.properties[propertyName];\r
+      this.resolveTo(property, resolutionTable);\r
+    }\r
+  }\r
+  // operations\r
+  for(name in spec.paths) {\r
+    var method, operation, responseCode;\r
+    path = spec.paths[name];\r
+    for(method in path) {\r
+      operation = path[method];\r
+      var i, parameters = operation.parameters;\r
+      for(i in parameters) {\r
+        var parameter = parameters[i];\r
+        if(parameter.in === 'body' && parameter.schema) {\r
+          this.resolveTo(parameter.schema, resolutionTable);\r
+        }\r
+        if(parameter.$ref) {\r
+          this.resolveInline(spec, parameter, resolutionTable, unresolvedRefs);\r
+        }\r
+      }\r
+      for(responseCode in operation.responses) {\r
+        var response = operation.responses[responseCode];\r
+        if(response.schema) {\r
+          this.resolveTo(response.schema, resolutionTable);\r
+        }\r
+      }\r
+    }\r
+  }\r
+  // get hosts\r
+  var opts = {}, expectedCalls = 0;\r
+  for(name in resolutionTable) {\r
+    var parts = name.split('#');\r
+    if(parts.length == 2) {\r
+      host = parts[0]; path = parts[1];\r
+      if(!Array.isArray(opts[host])) {\r
+        opts[host] = [];\r
+        expectedCalls += 1;\r
+      }\r
+      opts[host].push(path);\r
+    }\r
+  }\r
+\r
+  for(name in opts) {\r
+    var self = this, opt = opts[name];\r
+    host = name;\r
+\r
+    var obj = {\r
+      useJQuery: false,  // TODO\r
+      url: host,\r
+      method: "get",\r
+      headers: {\r
+        accept: this.scope.swaggerRequestHeaders || 'application/json'\r
+      },\r
+      on: {\r
+        error: function(response) {\r
+          processedCalls += 1;\r
+          var i;\r
+          for(i = 0; i < opt.length; i++) {\r
+            // fail all of these\r
+            var resolved = host + '#' + opt[i];\r
+            unresolvedRefs[resolved] = null;\r
+          }\r
+          if(processedCalls === expectedCalls)\r
+            self.finish(spec, resolutionTable, resolvedRefs, unresolvedRefs, callback);\r
+        },\r
+        response: function(response) {\r
+          var i, j, swagger = response.obj;\r
+          processedCalls += 1;\r
+          for(i = 0; i < opt.length; i++) {\r
+            var location = swagger, path = opt[i], parts = path.split('/');\r
+            for(j = 0; j < parts.length; j++) {\r
+              var segment = parts[j];\r
+              if(typeof location === 'undefined')\r
+                break;\r
+              if(segment.length > 0)\r
+                location = location[segment];\r
+            }\r
+            var resolved = host + '#' + path, resolvedName = parts[j-1];\r
+            if(typeof location !== 'undefined') {\r
+              resolvedRefs[resolved] = {\r
+                name: resolvedName,\r
+                obj: location\r
+              };\r
+            }\r
+            else unresolvedRefs[resolved] = null;\r
+          }\r
+          if(processedCalls === expectedCalls)\r
+            self.finish(spec, resolutionTable, resolvedRefs, unresolvedRefs, callback);\r
+        }\r
+      }\r
+    };\r
+    authorizations.apply(obj);\r
+    new SwaggerHttp().execute(obj);\r
+  }\r
+  if(Object.keys(opts).length === 0)\r
+    callback.call(this.scope, spec, unresolvedRefs);\r
+};\r
+\r
+Resolver.prototype.finish = function(spec, resolutionTable, resolvedRefs, unresolvedRefs, callback) {\r
+  // walk resolution table and replace with resolved refs\r
+  var ref;\r
+  for(ref in resolutionTable) {\r
+    var i, locations = resolutionTable[ref];\r
+    for(i = 0; i < locations.length; i++) {\r
+      var resolvedTo = resolvedRefs[locations[i].obj.$ref];\r
+      if(resolvedTo) {\r
+        if(!spec.definitions)\r
+          spec.definitions = {};\r
+        if(locations[i].resolveAs === '$ref') {\r
+          spec.definitions[resolvedTo.name] = resolvedTo.obj;\r
+          locations[i].obj.$ref = '#/definitions/' + resolvedTo.name;\r
+        }\r
+        else if (locations[i].resolveAs === 'inline') {\r
+          var key;\r
+          var targetObj = locations[i].obj;\r
+          delete targetObj.$ref;\r
+          for(key in resolvedTo.obj) {\r
+            targetObj[key] = resolvedTo.obj[key];\r
+          }\r
+        }\r
+      }\r
+    }\r
+  }\r
+  callback.call(this.scope, spec, unresolvedRefs);\r
+};\r
+\r
+/**\r
+ * immediately in-lines local refs, queues remote refs\r
+ * for inline resolution\r
+ */\r
+Resolver.prototype.resolveInline = function (spec, property, objs, unresolvedRefs) {\r
+  var ref = property.$ref;\r
+  if(ref) {\r
+    if(ref.indexOf('http') === 0) {\r
+      if(Array.isArray(objs[ref])) {\r
+        objs[ref].push({obj: property, resolveAs: 'inline'});\r
+      }\r
+      else {\r
+        objs[ref] = [{obj: property, resolveAs: 'inline'}];\r
+      }\r
+    }\r
+    else if (ref.indexOf('#') === 0) {\r
+      // local resolve\r
+      var shortenedRef = ref.substring(1);\r
+      var i, parts = shortenedRef.split('/'), location = spec;\r
+      for(i = 0; i < parts.length; i++) {\r
+        var part = parts[i];\r
+        if(part.length > 0) {\r
+          location = location[part];\r
+        }\r
+      }\r
+      if(location) {\r
+        delete property.$ref;\r
+        var key;\r
+        for(key in location) {\r
+          property[key] = location[key];\r
+        }\r
+      }\r
+      else unresolvedRefs[ref] = null;\r
+    }\r
+  }\r
+  else if(property.type === 'array') {\r
+    this.resolveTo(property.items, objs);\r
+  }\r
+};\r
+\r
+Resolver.prototype.resolveTo = function (property, objs) {\r
+  var ref = property.$ref;\r
+  if(ref) {\r
+    if(ref.indexOf('http') === 0) {\r
+      if(Array.isArray(objs[ref])) {\r
+        objs[ref].push({obj: property, resolveAs: '$ref'});\r
+      }\r
+      else {\r
+        objs[ref] = [{obj: property, resolveAs: '$ref'}];\r
+      }\r
+    }\r
+  }\r
+  else if(property.type === 'array') {\r
+    var items = property.items;\r
+    this.resolveTo(items, objs);\r
+  }\r
+};\r
+var addModel = function(name, model) {\r
+  models[name] = model;\r
+};\r
+\r
+var SwaggerClient = function(url, options) {\r
+  this.isBuilt = false;\r
+  this.url = null;\r
+  this.debug = false;\r
+  this.basePath = null;\r
+  this.modelsArray = [];\r
+  this.authorizations = null;\r
+  this.authorizationScheme = null;\r
+  this.isValid = false;\r
+  this.info = null;\r
+  this.useJQuery = false;\r
+  this.resourceCount = 0;\r
+\r
+  if(typeof url !== 'undefined')\r
+    return this.initialize(url, options);\r
+};\r
+\r
+SwaggerClient.prototype.initialize = function (url, options) {\r
+  this.models = models = {};\r
+\r
+  options = (options||{});\r
+\r
+  if(typeof url === 'string')\r
+    this.url = url;\r
+  else if(typeof url === 'object') {\r
+    options = url;\r
+    this.url = options.url;\r
+  }\r
+  this.swaggerRequstHeaders = options.swaggerRequstHeaders || 'application/json;charset=utf-8,*/*';\r
+  this.defaultSuccessCallback = options.defaultSuccessCallback || null;\r
+  this.defaultErrorCallback = options.defaultErrorCallback || null;\r
+\r
+  if (typeof options.success === 'function')\r
+    this.success = options.success;\r
+\r
+  if (options.useJQuery)\r
+    this.useJQuery = options.useJQuery;\r
+\r
+  if (options.authorizations) {\r
+    this.clientAuthorizations = options.authorizations;\r
+  } else {\r
+    this.clientAuthorizations = authorizations;\r
+  }\r
+\r
+  this.supportedSubmitMethods = options.supportedSubmitMethods || [];\r
+  this.failure = options.failure || function() {};\r
+  this.progress = options.progress || function() {};\r
+  this.spec = options.spec;\r
+  this.options = options;\r
+\r
+  if (typeof options.success === 'function') {\r
+    this.ready = true;\r
+    this.build();\r
+  }\r
+};\r
+\r
+SwaggerClient.prototype.build = function(mock) {\r
+  if (this.isBuilt) return this;\r
+  var self = this;\r
+  this.progress('fetching resource list: ' + this.url);\r
+  var obj = {\r
+    useJQuery: this.useJQuery,\r
+    url: this.url,\r
+    method: "get",\r
+    headers: {\r
+      accept: this.swaggerRequstHeaders\r
+    },\r
+    on: {\r
+      error: function(response) {\r
+        if (self.url.substring(0, 4) !== 'http')\r
+          return self.fail('Please specify the protocol for ' + self.url);\r
+        else if (response.status === 0)\r
+          return self.fail('Can\'t read from server.  It may not have the appropriate access-control-origin settings.');\r
+        else if (response.status === 404)\r
+          return self.fail('Can\'t read swagger JSON from ' + self.url);\r
+        else\r
+          return self.fail(response.status + ' : ' + response.statusText + ' ' + self.url);\r
+      },\r
+      response: function(resp) {\r
+        var responseObj = resp.obj || JSON.parse(resp.data);\r
+        self.swaggerVersion = responseObj.swaggerVersion;\r
+\r
+        if(responseObj.swagger && parseInt(responseObj.swagger) === 2) {\r
+          self.swaggerVersion = responseObj.swagger;\r
+          new Resolver().resolve(responseObj, self.buildFromSpec, self);\r
+          self.isValid = true;\r
+        }\r
+        else {\r
+          if (self.swaggerVersion === '1.2') {\r
+            return self.buildFrom1_2Spec(responseObj);\r
+          } else {\r
+            return self.buildFrom1_1Spec(responseObj);\r
+          }\r
+        }\r
+      }\r
+    }\r
+  };\r
+  if(this.spec) {\r
+    setTimeout(function() {\r
+      new Resolver().resolve(self.spec, self.buildFromSpec, self);\r
+   }, 10);\r
+  }\r
+  else {\r
+    authorizations.apply(obj);\r
+    if(mock)\r
+      return obj;\r
+    new SwaggerHttp().execute(obj);\r
+  }\r
+  return this;\r
+};\r
+\r
+SwaggerClient.prototype.buildFromSpec = function(response) {\r
+  if(this.isBuilt) return this;\r
+\r
+  this.info = response.info || {};\r
+  this.title = response.title || '';\r
+  this.host = response.host || '';\r
+  this.schemes = response.schemes || [];\r
+  this.basePath = response.basePath || '';\r
+  this.apis = {};\r
+  this.apisArray = [];\r
+  this.consumes = response.consumes;\r
+  this.produces = response.produces;\r
+  this.securityDefinitions = response.securityDefinitions;\r
+\r
+  // legacy support\r
+  this.authSchemes = response.securityDefinitions;\r
+\r
+  var definedTags = {};\r
+  if(Array.isArray(response.tags)) {\r
+    definedTags = {};\r
+    for(k = 0; k < response.tags.length; k++) {\r
+      var t = response.tags[k];\r
+      definedTags[t.name] = t;\r
+    }\r
+  }\r
+\r
+  var location;\r
+  if(typeof this.url === 'string') {\r
+    location = this.parseUri(this.url);\r
+  }\r
+\r
+  if(typeof this.schemes === 'undefined' || this.schemes.length === 0) {\r
+    this.scheme = location.scheme || 'http';\r
+  }\r
+  else {\r
+    this.scheme = this.schemes[0];\r
+  }\r
+\r
+  if(typeof this.host === 'undefined' || this.host === '') {\r
+    this.host = location.host;\r
+    if (location.port) {\r
+      this.host = this.host + ':' + location.port;\r
+    }\r
+  }\r
+\r
+  this.definitions = response.definitions;\r
+  var key;\r
+  for(key in this.definitions) {\r
+    var model = new Model(key, this.definitions[key]);\r
+    if(model) {\r
+      models[key] = model;\r
+    }\r
+  }\r
+\r
+  // get paths, create functions for each operationId\r
+  var path;\r
+  var operations = [];\r
+  for(path in response.paths) {\r
+    if(typeof response.paths[path] === 'object') {\r
+      var httpMethod;\r
+      for(httpMethod in response.paths[path]) {\r
+        if(['delete', 'get', 'head', 'options', 'patch', 'post', 'put'].indexOf(httpMethod) === -1) {\r
+          continue;\r
+        }\r
+        var operation = response.paths[path][httpMethod];\r
+        var tags = operation.tags;\r
+        if(typeof tags === 'undefined') {\r
+          operation.tags = [ 'default' ];\r
+          tags = operation.tags;\r
+        }\r
+        var operationId = this.idFromOp(path, httpMethod, operation);\r
+        var operationObject = new Operation (\r
+          this,\r
+          operation.scheme,\r
+          operationId,\r
+          httpMethod,\r
+          path,\r
+          operation,\r
+          this.definitions\r
+        );\r
+        // bind this operation's execute command to the api\r
+        if(tags.length > 0) {\r
+          var i;\r
+          for(i = 0; i < tags.length; i++) {\r
+            var tag = this.tagFromLabel(tags[i]);\r
+            var operationGroup = this[tag];\r
+            if(typeof this.apis[tag] === 'undefined')\r
+              this.apis[tag] = {};\r
+            if(typeof operationGroup === 'undefined') {\r
+              this[tag] = [];\r
+              operationGroup = this[tag];\r
+              operationGroup.operations = {};\r
+              operationGroup.label = tag;\r
+              operationGroup.apis = [];\r
+              var tagObject = definedTags[tag];\r
+              if(typeof tagObject === 'object') {\r
+                operationGroup.description = tagObject.description;\r
+                operationGroup.externalDocs = tagObject.externalDocs;\r
+              }\r
+              this[tag].help = this.help.bind(operationGroup);\r
+              this.apisArray.push(new OperationGroup(tag, operationGroup.description, operationGroup.externalDocs, operationObject));\r
+            }\r
+            if(typeof this.apis[tag].help !== 'function')\r
+              this.apis[tag].help = this.help.bind(operationGroup);\r
+            // bind to the apis object\r
+            this.apis[tag][operationId] = operationObject.execute.bind(operationObject);\r
+            this.apis[tag][operationId].help = operationObject.help.bind(operationObject);\r
+            this.apis[tag][operationId].asCurl = operationObject.asCurl.bind(operationObject);\r
+            operationGroup[operationId] = operationObject.execute.bind(operationObject);\r
+            operationGroup[operationId].help = operationObject.help.bind(operationObject);\r
+            operationGroup[operationId].asCurl = operationObject.asCurl.bind(operationObject);\r
+\r
+            operationGroup.apis.push(operationObject);\r
+            operationGroup.operations[operationId] = operationObject;\r
+\r
+            // legacy UI feature\r
+            var j;\r
+            var api;\r
+            for(j = 0; j < this.apisArray.length; j++) {\r
+              if(this.apisArray[j].tag === tag) {\r
+                api = this.apisArray[j];\r
+              }\r
+            }\r
+            if(api) {\r
+              api.operationsArray.push(operationObject);\r
+            }\r
+          }\r
+        }\r
+        else {\r
+          log('no group to bind to');\r
+        }\r
+      }\r
+    }\r
+  }\r
+  this.isBuilt = true;\r
+  if (this.success) {\r
+    this.isValid = true;\r
+    this.isBuilt = true;\r
+    this.success();\r
+  }\r
+  return this;\r
+};\r
+\r
+SwaggerClient.prototype.parseUri = function(uri) {\r
+  var urlParseRE = /^(((([^:\/#\?]+:)?(?:(\/\/)((?:(([^:@\/#\?]+)(?:\:([^:@\/#\?]+))?)@)?(([^:\/#\?\]\[]+|\[[^\/\]@#?]+\])(?:\:([0-9]+))?))?)?)?((\/?(?:[^\/\?#]+\/+)*)([^\?#]*)))?(\?[^#]+)?)(#.*)?/;\r
+  var parts = urlParseRE.exec(uri);\r
+  return {\r
+    scheme: parts[4].replace(':',''),\r
+    host: parts[11],\r
+    port: parts[12],\r
+    path: parts[15]\r
+  };\r
+};\r
+\r
+SwaggerClient.prototype.help = function(dontPrint) {\r
+  var i;\r
+  var output = 'operations for the "' + this.label + '" tag';\r
+  for(i = 0; i < this.apis.length; i++) {\r
+    var api = this.apis[i];\r
+    output += '\n  * ' + api.nickname + ': ' + api.operation.summary;\r
+  }\r
+  if(dontPrint)\r
+    return output;\r
+  else {\r
+    log(output);\r
+    return output;\r
+  }\r
+};\r
+\r
+SwaggerClient.prototype.tagFromLabel = function(label) {\r
+  return label;\r
+};\r
+\r
+SwaggerClient.prototype.idFromOp = function(path, httpMethod, op) {\r
+  var opId = op.operationId || (path.substring(1) + '_' + httpMethod);\r
+  return opId.replace(/[\.,-\/#!$%\^&\*;:{}=\-_`~()\+\s]/g,'_');\r
+};\r
+\r
+SwaggerClient.prototype.fail = function(message) {\r
+  this.failure(message);\r
+  throw message;\r
+};\r
+\r
+var OperationGroup = function(tag, description, externalDocs, operation) {\r
+  this.tag = tag;\r
+  this.path = tag;\r
+  this.description = description;\r
+  this.externalDocs = externalDocs;\r
+  this.name = tag;\r
+  this.operation = operation;\r
+  this.operationsArray = [];\r
+};\r
+\r
+var Operation = function(parent, scheme, operationId, httpMethod, path, args, definitions) {\r
+  var errors = [];\r
+  parent = parent||{};\r
+  args = args||{};\r
+\r
+  this.operations = {};\r
+  this.operation = args;\r
+  this.deprecated = args.deprecated;\r
+  this.consumes = args.consumes;\r
+  this.produces = args.produces;\r
+  this.parent = parent;\r
+  this.host = parent.host || 'localhost';\r
+  this.schemes = parent.schemes;\r
+  this.scheme = scheme || parent.scheme || 'http';\r
+  this.basePath = parent.basePath || '/';\r
+  this.nickname = (operationId||errors.push('Operations must have a nickname.'));\r
+  this.method = (httpMethod||errors.push('Operation ' + operationId + ' is missing method.'));\r
+  this.path = (path||errors.push('Operation ' + this.nickname + ' is missing path.'));\r
+  this.parameters = args !== null ? (args.parameters||[]) : {};\r
+  this.summary = args.summary || '';\r
+  this.responses = (args.responses||{});\r
+  this.type = null;\r
+  this.security = args.security;\r
+  this.authorizations = args.security;\r
+  this.description = args.description;\r
+  this.useJQuery = parent.useJQuery;\r
+\r
+  if(typeof this.deprecated === 'string') {\r
+    switch(this.deprecated.toLowerCase()) {\r
+      case 'true': case 'yes': case '1': {\r
+        this.deprecated = true;\r
+        break;\r
+      }\r
+      case 'false': case 'no': case '0': case null: {\r
+        this.deprecated = false;\r
+        break;\r
+      }\r
+      default: this.deprecated = Boolean(this.deprecated);\r
+    }\r
+  }\r
+\r
+  var i, model;\r
+\r
+  if(definitions) {\r
+    // add to global models\r
+    var key;\r
+    for(key in this.definitions) {\r
+      model = new Model(key, definitions[key]);\r
+      if(model) {\r
+        models[key] = model;\r
+      }\r
+    }\r
+  }\r
+  for(i = 0; i < this.parameters.length; i++) {\r
+    var param = this.parameters[i];\r
+    if(param.type === 'array') {\r
+      param.isList = true;\r
+      param.allowMultiple = true;\r
+    }\r
+    var innerType = this.getType(param);\r
+    if(innerType && innerType.toString().toLowerCase() === 'boolean') {\r
+      param.allowableValues = {};\r
+      param.isList = true;\r
+      param['enum'] = ["true", "false"];\r
+    }\r
+    if(typeof param['enum'] !== 'undefined') {\r
+      var id;\r
+      param.allowableValues = {};\r
+      param.allowableValues.values = [];\r
+      param.allowableValues.descriptiveValues = [];\r
+      for(id = 0; id < param['enum'].length; id++) {\r
+        var value = param['enum'][id];\r
+        var isDefault = (value === param.default) ? true : false;\r
+        param.allowableValues.values.push(value);\r
+        param.allowableValues.descriptiveValues.push({value : value, isDefault: isDefault});\r
+      }\r
+    }\r
+    if(param.type === 'array') {\r
+      innerType = [innerType];\r
+      if(typeof param.allowableValues === 'undefined') {\r
+        // can't show as a list if no values to select from\r
+        delete param.isList;\r
+        delete param.allowMultiple;\r
+      }\r
+    }\r
+    param.signature = this.getModelSignature(innerType, models).toString();\r
+    param.sampleJSON = this.getModelSampleJSON(innerType, models);\r
+    param.responseClassSignature = param.signature;\r
+  }\r
+\r
+  var defaultResponseCode, response, responses = this.responses;\r
+\r
+  if(responses['200']) {\r
+    response = responses['200'];\r
+    defaultResponseCode = '200';\r
+  }\r
+  else if(responses['201']) {\r
+    response = responses['201'];\r
+    defaultResponseCode = '201';\r
+  }\r
+  else if(responses['202']) {\r
+    response = responses['202'];\r
+    defaultResponseCode = '202';\r
+  }\r
+  else if(responses['203']) {\r
+    response = responses['203'];\r
+    defaultResponseCode = '203';\r
+  }\r
+  else if(responses['204']) {\r
+    response = responses['204'];\r
+    defaultResponseCode = '204';\r
+  }\r
+  else if(responses['205']) {\r
+    response = responses['205'];\r
+    defaultResponseCode = '205';\r
+  }\r
+  else if(responses['206']) {\r
+    response = responses['206'];\r
+    defaultResponseCode = '206';\r
+  }\r
+  else if(responses['default']) {\r
+    response = responses['default'];\r
+    defaultResponseCode = 'default';\r
+  }\r
+\r
+  if(response && response.schema) {\r
+    var resolvedModel = this.resolveModel(response.schema, definitions);\r
+    delete responses[defaultResponseCode];\r
+    if(resolvedModel) {\r
+      this.successResponse = {};\r
+      this.successResponse[defaultResponseCode] = resolvedModel;\r
+    }\r
+    else {\r
+      this.successResponse = {};\r
+      this.successResponse[defaultResponseCode] = response.schema.type;\r
+    }\r
+    this.type = response;\r
+  }\r
+\r
+  if (errors.length > 0) {\r
+    if(this.resource && this.resource.api && this.resource.api.fail)\r
+      this.resource.api.fail(errors);\r
+  }\r
+\r
+  return this;\r
+};\r
+\r
+OperationGroup.prototype.sort = function(sorter) {\r
+\r
+};\r
+\r
+Operation.prototype.getType = function (param) {\r
+  var type = param.type;\r
+  var format = param.format;\r
+  var isArray = false;\r
+  var str;\r
+  if(type === 'integer' && format === 'int32')\r
+    str = 'integer';\r
+  else if(type === 'integer' && format === 'int64')\r
+    str = 'long';\r
+  else if(type === 'integer')\r
+    str = 'integer';\r
+  else if(type === 'string') {\r
+    if(format === 'date-time')\r
+      str = 'date-time';\r
+    else if(format === 'date')\r
+      str = 'date';\r
+    else\r
+      str = 'string';\r
+  }\r
+  else if(type === 'number' && format === 'float')\r
+    str = 'float';\r
+  else if(type === 'number' && format === 'double')\r
+    str = 'double';\r
+  else if(type === 'number')\r
+    str = 'double';\r
+  else if(type === 'boolean')\r
+    str = 'boolean';\r
+  else if(type === 'array') {\r
+    isArray = true;\r
+    if(param.items)\r
+      str = this.getType(param.items);\r
+  }\r
+  if(param.$ref)\r
+    str = param.$ref;\r
+\r
+  var schema = param.schema;\r
+  if(schema) {\r
+    var ref = schema.$ref;\r
+    if(ref) {\r
+      ref = simpleRef(ref);\r
+      if(isArray)\r
+        return [ ref ];\r
+      else\r
+        return ref;\r
+    }\r
+    else\r
+      return this.getType(schema);\r
+  }\r
+  if(isArray)\r
+    return [ str ];\r
+  else\r
+    return str;\r
+};\r
+\r
+Operation.prototype.resolveModel = function (schema, definitions) {\r
+  if(typeof schema.$ref !== 'undefined') {\r
+    var ref = schema.$ref;\r
+    if(ref.indexOf('#/definitions/') === 0)\r
+      ref = ref.substring('#/definitions/'.length);\r
+    if(definitions[ref]) {\r
+      return new Model(ref, definitions[ref]);\r
+    }\r
+  }\r
+  if(schema.type === 'array')\r
+    return new ArrayModel(schema);\r
+  else\r
+    return null;\r
+};\r
+\r
+Operation.prototype.help = function(dontPrint) {\r
+  var out = this.nickname + ': ' + this.summary + '\n';\r
+  for(var i = 0; i < this.parameters.length; i++) {\r
+    var param = this.parameters[i];\r
+    var typeInfo = param.signature;\r
+    out += '\n  * ' + param.name + ' (' + typeInfo + '): ' + param.description;\r
+  }\r
+  if(typeof dontPrint === 'undefined')\r
+    log(out);\r
+  return out;\r
+};\r
+\r
+Operation.prototype.getModelSignature = function(type, definitions) {\r
+  var isPrimitive, listType;\r
+\r
+  if(type instanceof Array) {\r
+    listType = true;\r
+    type = type[0];\r
+  }\r
+  else if(typeof type === 'undefined')\r
+    type = 'undefined';\r
+\r
+  if(type === 'string')\r
+    isPrimitive = true;\r
+  else\r
+    isPrimitive = (listType && definitions[listType]) || (definitions[type]) ? false : true;\r
+  if (isPrimitive) {\r
+    if(listType)\r
+      return 'Array[' + type + ']';\r
+    else\r
+      return type.toString();\r
+  } else {\r
+    if (listType)\r
+      return 'Array[' + definitions[type].getMockSignature() + ']';\r
+    else\r
+      return definitions[type].getMockSignature();\r
+  }\r
+};\r
+\r
+Operation.prototype.supportHeaderParams = function () {\r
+  return true;\r
+};\r
+\r
+Operation.prototype.supportedSubmitMethods = function () {\r
+  return this.parent.supportedSubmitMethods;\r
+};\r
+\r
+Operation.prototype.getHeaderParams = function (args) {\r
+  var headers = this.setContentTypes(args, {});\r
+  for(var i = 0; i < this.parameters.length; i++) {\r
+    var param = this.parameters[i];\r
+    if(typeof args[param.name] !== 'undefined') {\r
+      if (param.in === 'header') {\r
+        var value = args[param.name];\r
+        if(Array.isArray(value))\r
+          value = value.toString();\r
+        headers[param.name] = value;\r
+      }\r
+    }\r
+  }\r
+  return headers;\r
+};\r
+\r
+Operation.prototype.urlify = function (args) {\r
+  var formParams = {};\r
+  var requestUrl = this.path;\r
+\r
+  // grab params from the args, build the querystring along the way\r
+  var querystring = '';\r
+  for(var i = 0; i < this.parameters.length; i++) {\r
+    var param = this.parameters[i];\r
+    if(typeof args[param.name] !== 'undefined') {\r
+      if(param.in === 'path') {\r
+        var reg = new RegExp('\{' + param.name + '\}', 'gi');\r
+        var value = args[param.name];\r
+        if(Array.isArray(value))\r
+          value = this.encodePathCollection(param.collectionFormat, param.name, value);\r
+        else\r
+          value = this.encodePathParam(value);\r
+        requestUrl = requestUrl.replace(reg, value);\r
+      }\r
+      else if (param.in === 'query' && typeof args[param.name] !== 'undefined') {\r
+        if(querystring === '')\r
+          querystring += '?';\r
+        else\r
+          querystring += '&';\r
+        if(typeof param.collectionFormat !== 'undefined') {\r
+          var qp = args[param.name];\r
+          if(Array.isArray(qp))\r
+            querystring += this.encodeQueryCollection(param.collectionFormat, param.name, qp);\r
+          else\r
+            querystring += this.encodeQueryParam(param.name) + '=' + this.encodeQueryParam(args[param.name]);\r
+        }\r
+        else\r
+          querystring += this.encodeQueryParam(param.name) + '=' + this.encodeQueryParam(args[param.name]);\r
+      }\r
+      else if (param.in === 'formData')\r
+        formParams[param.name] = args[param.name];\r
+    }\r
+  }\r
+  var url = this.scheme + '://' + this.host;\r
+\r
+  if(this.basePath !== '/')\r
+    url += this.basePath;\r
+\r
+  return url + requestUrl + querystring;\r
+};\r
+\r
+Operation.prototype.getMissingParams = function(args) {\r
+  var missingParams = [];\r
+  // check required params, track the ones that are missing\r
+  var i;\r
+  for(i = 0; i < this.parameters.length; i++) {\r
+    var param = this.parameters[i];\r
+    if(param.required === true) {\r
+      if(typeof args[param.name] === 'undefined')\r
+        missingParams = param.name;\r
+    }\r
+  }\r
+  return missingParams;\r
+};\r
+\r
+Operation.prototype.getBody = function(headers, args, opts) {\r
+  var formParams = {}, body, key;\r
+\r
+  for(var i = 0; i < this.parameters.length; i++) {\r
+    var param = this.parameters[i];\r
+    if(typeof args[param.name] !== 'undefined') {\r
+      if (param.in === 'body') {\r
+        body = args[param.name];\r
+      } else if(param.in === 'formData') {\r
+        formParams[param.name] = args[param.name];\r
+      }\r
+    }\r
+  }\r
+\r
+  // handle form params\r
+  if(headers['Content-Type'] === 'application/x-www-form-urlencoded') {\r
+    var encoded = "";\r
+    for(key in formParams) {\r
+      value = formParams[key];\r
+      if(typeof value !== 'undefined'){\r
+        if(encoded !== "")\r
+          encoded += "&";\r
+        encoded += encodeURIComponent(key) + '=' + encodeURIComponent(value);\r
+      }\r
+    }\r
+    body = encoded;\r
+  }\r
+  else if (headers['Content-Type'] && headers['Content-Type'].indexOf('multipart/form-data') >= 0) {\r
+    if(opts.useJQuery) {\r
+      var bodyParam = new FormData();\r
+      bodyParam.type = 'formData';\r
+      for (key in formParams) {\r
+        value = args[key];\r
+        if (typeof value !== 'undefined') {\r
+          // required for jquery file upload\r
+          if(value.type === 'file' && value.value) {\r
+            delete headers['Content-Type'];\r
+            bodyParam.append(key, value.value);\r
+          }\r
+          else\r
+            bodyParam.append(key, value);\r
+        }\r
+      }\r
+      body = bodyParam;\r
+    }\r
+  }\r
+\r
+  return body;\r
+};\r
+\r
+/**\r
+ * gets sample response for a single operation\r
+ **/\r
+Operation.prototype.getModelSampleJSON = function(type, models) {\r
+  var isPrimitive, listType, sampleJson;\r
+\r
+  listType = (type instanceof Array);\r
+  isPrimitive = models[type] ? false : true;\r
+  sampleJson = isPrimitive ? void 0 : models[type].createJSONSample();\r
+  if (sampleJson) {\r
+    sampleJson = listType ? [sampleJson] : sampleJson;\r
+    if(typeof sampleJson == 'string')\r
+      return sampleJson;\r
+    else if(typeof sampleJson === 'object') {\r
+      var t = sampleJson;\r
+      if(sampleJson instanceof Array && sampleJson.length > 0) {\r
+        t = sampleJson[0];\r
+      }\r
+      if(t.nodeName) {\r
+        var xmlString = new XMLSerializer().serializeToString(t);\r
+        return this.formatXml(xmlString);\r
+      }\r
+      else\r
+        return JSON.stringify(sampleJson, null, 2);\r
+    }\r
+    else\r
+      return sampleJson;\r
+  }\r
+};\r
+\r
+/**\r
+ * legacy binding\r
+ **/\r
+Operation.prototype["do"] = function(args, opts, callback, error, parent) {\r
+  return this.execute(args, opts, callback, error, parent);\r
+};\r
+\r
+\r
+/**\r
+ * executes an operation\r
+ **/\r
+Operation.prototype.execute = function(arg1, arg2, arg3, arg4, parent) {\r
+  var args = arg1 || {};\r
+  var opts = {}, success, error;\r
+  if(typeof arg2 === 'object') {\r
+    opts = arg2;\r
+    success = arg3;\r
+    error = arg4;\r
+  }\r
+\r
+  if(typeof arg2 === 'function') {\r
+    success = arg2;\r
+    error = arg3;\r
+  }\r
+\r
+  success = (success||log);\r
+  error = (error||log);\r
+\r
+  if(opts.useJQuery)\r
+    this.useJQuery = opts.useJQuery;\r
+\r
+  var missingParams = this.getMissingParams(args);\r
+  if(missingParams.length > 0) {\r
+    var message = 'missing required params: ' + missingParams;\r
+    fail(message);\r
+    return;\r
+  }\r
+  var allHeaders = this.getHeaderParams(args);\r
+  var contentTypeHeaders = this.setContentTypes(args, opts);\r
+\r
+  var headers = {}, attrname;\r
+  for (attrname in allHeaders) { headers[attrname] = allHeaders[attrname]; }\r
+  for (attrname in contentTypeHeaders) { headers[attrname] = contentTypeHeaders[attrname]; }\r
+\r
+  var body = this.getBody(headers, args, opts);\r
+  var url = this.urlify(args);\r
+\r
+  var obj = {\r
+    url: url,\r
+    method: this.method.toUpperCase(),\r
+    body: body,\r
+    useJQuery: this.useJQuery,\r
+    headers: headers,\r
+    on: {\r
+      response: function(response) {\r
+        return success(response, parent);\r
+      },\r
+      error: function(response) {\r
+        return error(response, parent);\r
+      }\r
+    }\r
+  };\r
+  var status = authorizations.apply(obj, this.operation.security);\r
+  if(opts.mock === true)\r
+    return obj;\r
+  else\r
+    new SwaggerHttp().execute(obj, opts);\r
+};\r
+\r
+Operation.prototype.setContentTypes = function(args, opts) {\r
+  // default type\r
+  var accepts = 'application/json';\r
+  var consumes = args.parameterContentType || 'application/json';\r
+  var allDefinedParams = this.parameters;\r
+  var definedFormParams = [];\r
+  var definedFileParams = [];\r
+  var body;\r
+  var headers = {};\r
+\r
+  // get params from the operation and set them in definedFileParams, definedFormParams, headers\r
+  var i;\r
+  for(i = 0; i < allDefinedParams.length; i++) {\r
+    var param = allDefinedParams[i];\r
+    if(param.in === 'formData') {\r
+      if(param.type === 'file')\r
+        definedFileParams.push(param);\r
+      else\r
+        definedFormParams.push(param);\r
+    }\r
+    else if(param.in === 'header' && opts) {\r
+      var key = param.name;\r
+      var headerValue = opts[param.name];\r
+      if(typeof opts[param.name] !== 'undefined')\r
+        headers[key] = headerValue;\r
+    }\r
+    else if(param.in === 'body' && typeof args[param.name] !== 'undefined') {\r
+      body = args[param.name];\r
+    }\r
+  }\r
+\r
+  // if there's a body, need to set the consumes header via requestContentType\r
+  if (body && (this.method === 'post' || this.method === 'put' || this.method === 'patch' || this.method === 'delete')) {\r
+    if (opts.requestContentType)\r
+      consumes = opts.requestContentType;\r
+  } else {\r
+    // if any form params, content type must be set\r
+    if(definedFormParams.length > 0) {\r
+      if(opts.requestContentType)           // override if set\r
+        consumes = opts.requestContentType;\r
+      else if(definedFileParams.length > 0) // if a file, must be multipart/form-data\r
+        consumes = 'multipart/form-data';\r
+      else                                  // default to x-www-from-urlencoded\r
+        consumes = 'application/x-www-form-urlencoded';\r
+    }\r
+    else if (this.type == 'DELETE')\r
+      body = '{}';\r
+    else if (this.type != 'DELETE')\r
+      consumes = null;\r
+  }\r
+\r
+  if (consumes && this.consumes) {\r
+    if (this.consumes.indexOf(consumes) === -1) {\r
+      log('server doesn\'t consume ' + consumes + ', try ' + JSON.stringify(this.consumes));\r
+    }\r
+  }\r
+\r
+  if (opts.responseContentType) {\r
+    accepts = opts.responseContentType;\r
+  } else {\r
+    accepts = 'application/json';\r
+  }\r
+  if (accepts && this.produces) {\r
+    if (this.produces.indexOf(accepts) === -1) {\r
+      log('server can\'t produce ' + accepts);\r
+    }\r
+  }\r
+\r
+  if ((consumes && body !== '') || (consumes === 'application/x-www-form-urlencoded'))\r
+    headers['Content-Type'] = consumes;\r
+  if (accepts)\r
+    headers.Accept = accepts;\r
+  return headers;\r
+};\r
+\r
+Operation.prototype.asCurl = function (args) {\r
+  var obj = this.execute(args, {mock: true});\r
+  authorizations.apply(obj);\r
+  var results = [];\r
+  results.push('-X ' + this.method.toUpperCase());\r
+  if (obj.headers) {\r
+    var key;\r
+    for (key in obj.headers)\r
+      results.push('--header "' + key + ': ' + obj.headers[key] + '"');\r
+  }\r
+  if(obj.body) {\r
+    var body;\r
+    if(typeof obj.body === 'object')\r
+      body = JSON.stringify(obj.body);\r
+    else\r
+      body = obj.body;\r
+    results.push('-d "' + body.replace(/"/g, '\\"') + '"');\r
+  }\r
+  return 'curl ' + (results.join(' ')) + ' "' + obj.url + '"';\r
+};\r
+\r
+Operation.prototype.encodePathCollection = function(type, name, value) {\r
+  var encoded = '';\r
+  var i;\r
+  var separator = '';\r
+  if(type === 'ssv')\r
+    separator = '%20';\r
+  else if(type === 'tsv')\r
+    separator = '\\t';\r
+  else if(type === 'pipes')\r
+    separator = '|';\r
+  else\r
+    separator = ',';\r
+\r
+  for(i = 0; i < value.length; i++) {\r
+    if(i === 0)\r
+      encoded = this.encodeQueryParam(value[i]);\r
+    else\r
+      encoded += separator + this.encodeQueryParam(value[i]);\r
+  }\r
+  return encoded;\r
+};\r
+\r
+Operation.prototype.encodeQueryCollection = function(type, name, value) {\r
+  var encoded = '';\r
+  var i;\r
+  if(type === 'default' || type === 'multi') {\r
+    for(i = 0; i < value.length; i++) {\r
+      if(i > 0) encoded += '&';\r
+      encoded += this.encodeQueryParam(name) + '=' + this.encodeQueryParam(value[i]);\r
+    }\r
+  }\r
+  else {\r
+    var separator = '';\r
+    if(type === 'csv')\r
+      separator = ',';\r
+    else if(type === 'ssv')\r
+      separator = '%20';\r
+    else if(type === 'tsv')\r
+      separator = '\\t';\r
+    else if(type === 'pipes')\r
+      separator = '|';\r
+    else if(type === 'brackets') {\r
+      for(i = 0; i < value.length; i++) {\r
+        if(i !== 0)\r
+          encoded += '&';\r
+        encoded += this.encodeQueryParam(name) + '[]=' + this.encodeQueryParam(value[i]);\r
+      }\r
+    }\r
+    if(separator !== '') {\r
+      for(i = 0; i < value.length; i++) {\r
+        if(i === 0)\r
+          encoded = this.encodeQueryParam(name) + '=' + this.encodeQueryParam(value[i]);\r
+        else\r
+          encoded += separator + this.encodeQueryParam(value[i]);\r
+      }\r
+    }\r
+  }\r
+  return encoded;\r
+};\r
+\r
+Operation.prototype.encodeQueryParam = function(arg) {\r
+  return encodeURIComponent(arg);\r
+};\r
+\r
+/**\r
+ * TODO revisit, might not want to leave '/'\r
+ **/\r
+Operation.prototype.encodePathParam = function(pathParam) {\r
+  var encParts, part, parts, i, len;\r
+  pathParam = pathParam.toString();\r
+  if (pathParam.indexOf('/') === -1) {\r
+    return encodeURIComponent(pathParam);\r
+  } else {\r
+    parts = pathParam.split('/');\r
+    encParts = [];\r
+    for (i = 0, len = parts.length; i < len; i++) {\r
+      encParts.push(encodeURIComponent(parts[i]));\r
+    }\r
+    return encParts.join('/');\r
+  }\r
+};\r
+\r
+var Model = function(name, definition) {\r
+  this.name = name;\r
+  this.definition = definition || {};\r
+  this.properties = [];\r
+  var requiredFields = definition.required || [];\r
+  if(definition.type === 'array') {\r
+    var out = new ArrayModel(definition);\r
+    return out;\r
+  }\r
+  var key;\r
+  var props = definition.properties;\r
+  if(props) {\r
+    for(key in props) {\r
+      var required = false;\r
+      var property = props[key];\r
+      if(requiredFields.indexOf(key) >= 0)\r
+        required = true;\r
+      this.properties.push(new Property(key, property, required));\r
+    }\r
+  }\r
+};\r
+\r
+Model.prototype.createJSONSample = function(modelsToIgnore) {\r
+  var i, result = {}, representations = {};\r
+  modelsToIgnore = (modelsToIgnore||{});\r
+  modelsToIgnore[this.name] = this;\r
+  for (i = 0; i < this.properties.length; i++) {\r
+    prop = this.properties[i];\r
+    var sample = prop.getSampleValue(modelsToIgnore, representations);\r
+    result[prop.name] = sample;\r
+  }\r
+  delete modelsToIgnore[this.name];\r
+  return result;\r
+};\r
+\r
+Model.prototype.getSampleValue = function(modelsToIgnore) {\r
+  var i, obj = {}, representations = {};\r
+  for(i = 0; i < this.properties.length; i++ ) {\r
+    var property = this.properties[i];\r
+    obj[property.name] = property.sampleValue(false, modelsToIgnore, representations);\r
+  }\r
+  return obj;\r
+};\r
+\r
+Model.prototype.getMockSignature = function(modelsToIgnore) {\r
+  var i, prop, propertiesStr = [];\r
+  for (i = 0; i < this.properties.length; i++) {\r
+    prop = this.properties[i];\r
+    propertiesStr.push(prop.toString());\r
+  }\r
+  var strong = '<span class="strong">';\r
+  var stronger = '<span class="stronger">';\r
+  var strongClose = '</span>';\r
+  var classOpen = strong + this.name + ' {' + strongClose;\r
+  var classClose = strong + '}' + strongClose;\r
+  var returnVal = classOpen + '<div>' + propertiesStr.join(',</div><div>') + '</div>' + classClose;\r
+  if (!modelsToIgnore)\r
+    modelsToIgnore = {};\r
+\r
+  modelsToIgnore[this.name] = this;\r
+  for (i = 0; i < this.properties.length; i++) {\r
+    prop = this.properties[i];\r
+    var ref = prop.$ref;\r
+    var model = models[ref];\r
+    if (model && typeof modelsToIgnore[model.name] === 'undefined') {\r
+      returnVal = returnVal + ('<br>' + model.getMockSignature(modelsToIgnore));\r
+    }\r
+  }\r
+  return returnVal;\r
+};\r
+\r
+var Property = function(name, obj, required) {\r
+  this.schema = obj;\r
+  this.required = required;\r
+  if(obj.$ref)\r
+    this.$ref = simpleRef(obj.$ref);\r
+  else if (obj.type === 'array' && obj.items) {\r
+    if(obj.items.$ref)\r
+      this.$ref = simpleRef(obj.items.$ref);\r
+    else\r
+      obj = obj.items;\r
+  }\r
+  this.name = name;\r
+  this.description = obj.description;\r
+  this.obj = obj;\r
+  this.optional = true;\r
+  this.optional = !required;\r
+  this.default = obj.default || null;\r
+  this.example = obj.example !== undefined ? obj.example : null;\r
+  this.collectionFormat = obj.collectionFormat || null;\r
+  this.maximum = obj.maximum || null;\r
+  this.exclusiveMaximum = obj.exclusiveMaximum || null;\r
+  this.minimum = obj.minimum || null;\r
+  this.exclusiveMinimum = obj.exclusiveMinimum || null;\r
+  this.maxLength = obj.maxLength || null;\r
+  this.minLength = obj.minLength || null;\r
+  this.pattern = obj.pattern || null;\r
+  this.maxItems = obj.maxItems || null;\r
+  this.minItems = obj.minItems || null;\r
+  this.uniqueItems = obj.uniqueItems || null;\r
+  this['enum'] = obj['enum'] || null;\r
+  this.multipleOf = obj.multipleOf || null;\r
+};\r
+\r
+Property.prototype.getSampleValue = function (modelsToIgnore, representations) {\r
+  return this.sampleValue(false, modelsToIgnore, representations);\r
+};\r
+\r
+Property.prototype.isArray = function () {\r
+  var schema = this.schema;\r
+  if(schema.type === 'array')\r
+    return true;\r
+  else\r
+    return false;\r
+};\r
+\r
+Property.prototype.sampleValue = function(isArray, ignoredModels, representations) {\r
+  isArray = (isArray || this.isArray());\r
+  ignoredModels = (ignoredModels || {});\r
+  // representations = (representations || {});\r
+\r
+  var type = getStringSignature(this.obj, true);\r
+  var output;\r
+\r
+  if(this.$ref) {\r
+    var refModelName = simpleRef(this.$ref);\r
+    var refModel = models[refModelName];\r
+    if(typeof representations[type] !== 'undefined') {\r
+      return representations[type];\r
+    }\r
+    else\r
+\r
+    if(refModel && typeof ignoredModels[type] === 'undefined') {\r
+      ignoredModels[type] = this;\r
+      output = refModel.getSampleValue(ignoredModels, representations);\r
+      representations[type] = output;\r
+    }\r
+    else {\r
+      output = (representations[type] || refModelName);\r
+    }\r
+  }\r
+  else if(this.example)\r
+    output = this.example;\r
+  else if(this.default)\r
+    output = this.default;\r
+  else if(type === 'date-time')\r
+    output = new Date().toISOString();\r
+  else if(type === 'date')\r
+    output = new Date().toISOString().split("T")[0];\r
+  else if(type === 'string')\r
+    output = 'string';\r
+  else if(type === 'integer')\r
+    output = 0;\r
+  else if(type === 'long')\r
+    output = 0;\r
+  else if(type === 'float')\r
+    output = 0.0;\r
+  else if(type === 'double')\r
+    output = 0.0;\r
+  else if(type === 'boolean')\r
+    output = true;\r
+  else\r
+    output = {};\r
+  ignoredModels[type] = output;\r
+  if(isArray)\r
+    return [output];\r
+  else\r
+    return output;\r
+};\r
+\r
+getStringSignature = function(obj, baseComponent) {\r
+  var str = '';\r
+  if(typeof obj.$ref !== 'undefined')\r
+    str += simpleRef(obj.$ref);\r
+  else if(typeof obj.type === 'undefined')\r
+    str += 'object';\r
+  else if(obj.type === 'array') {\r
+    if(baseComponent)\r
+      str += getStringSignature((obj.items || obj.$ref || {}));\r
+    else {\r
+      str += 'Array[';\r
+      str += getStringSignature((obj.items || obj.$ref || {}));\r
+      str += ']';\r
+    }\r
+  }\r
+  else if(obj.type === 'integer' && obj.format === 'int32')\r
+    str += 'integer';\r
+  else if(obj.type === 'integer' && obj.format === 'int64')\r
+    str += 'long';\r
+  else if(obj.type === 'integer' && typeof obj.format === 'undefined')\r
+    str += 'long';\r
+  else if(obj.type === 'string' && obj.format === 'date-time')\r
+    str += 'date-time';\r
+  else if(obj.type === 'string' && obj.format === 'date')\r
+    str += 'date';\r
+  else if(obj.type === 'string' && typeof obj.format === 'undefined')\r
+    str += 'string';\r
+  else if(obj.type === 'number' && obj.format === 'float')\r
+    str += 'float';\r
+  else if(obj.type === 'number' && obj.format === 'double')\r
+    str += 'double';\r
+  else if(obj.type === 'number' && typeof obj.format === 'undefined')\r
+    str += 'double';\r
+  else if(obj.type === 'boolean')\r
+    str += 'boolean';\r
+  else if(obj.$ref)\r
+    str += simpleRef(obj.$ref);\r
+  else\r
+    str += obj.type;\r
+  return str;\r
+};\r
+\r
+simpleRef = function(name) {\r
+  if(typeof name === 'undefined')\r
+    return null;\r
+  if(name.indexOf("#/definitions/") === 0)\r
+    return name.substring('#/definitions/'.length);\r
+  else\r
+    return name;\r
+};\r
+\r
+Property.prototype.toString = function() {\r
+  var str = getStringSignature(this.obj);\r
+  if(str !== '') {\r
+    str = '<span class="propName ' + this.required + '">' + this.name + '</span> (<span class="propType">' + str + '</span>';\r
+    if(!this.required)\r
+      str += ', <span class="propOptKey">optional</span>';\r
+    str += ')';\r
+  }\r
+  else\r
+    str = this.name + ' (' + JSON.stringify(this.obj) + ')';\r
+\r
+  if(typeof this.description !== 'undefined')\r
+    str += ': ' + this.description;\r
+\r
+  if (this['enum']) {\r
+    str += ' = <span class="propVals">[\'' + this['enum'].join('\' or \'') + '\']</span>';\r
+  }\r
+  if (this.descr) {\r
+    str += ': <span class="propDesc">' + this.descr + '</span>';\r
+  }\r
+\r
+\r
+  var options = ''; \r
+  var isArray = this.schema.type === 'array';\r
+  var type;\r
+\r
+  if(isArray) {\r
+    if(this.schema.items)\r
+      type = this.schema.items.type;\r
+    else\r
+      type = '';\r
+  }\r
+  else {\r
+    type = this.schema.type;\r
+  }\r
+\r
+  if (this.default)\r
+    options += optionHtml('Default', this.default);\r
+\r
+  switch (type) {\r
+    case 'string':\r
+      if (this.minLength)\r
+        options += optionHtml('Min. Length', this.minLength);\r
+      if (this.maxLength)\r
+        options += optionHtml('Max. Length', this.maxLength);\r
+      if (this.pattern)\r
+        options += optionHtml('Reg. Exp.', this.pattern);\r
+      break;\r
+    case 'integer':\r
+    case 'number':\r
+      if (this.minimum)\r
+        options += optionHtml('Min. Value', this.minimum);\r
+      if (this.exclusiveMinimum)\r
+        options += optionHtml('Exclusive Min.', "true");\r
+      if (this.maximum)\r
+        options += optionHtml('Max. Value', this.maximum);\r
+      if (this.exclusiveMaximum)\r
+        options += optionHtml('Exclusive Max.', "true");\r
+      if (this.multipleOf)\r
+        options += optionHtml('Multiple Of', this.multipleOf);\r
+      break;\r
+  }\r
+\r
+  if (isArray) {\r
+    if (this.minItems)\r
+      options += optionHtml('Min. Items', this.minItems);\r
+    if (this.maxItems)\r
+      options += optionHtml('Max. Items', this.maxItems);\r
+    if (this.uniqueItems)\r
+      options += optionHtml('Unique Items', "true");\r
+    if (this.collectionFormat)\r
+      options += optionHtml('Coll. Format', this.collectionFormat);\r
+  }\r
+\r
+  if (this['enum']) {\r
+    var enumString;\r
+\r
+    if (type === 'number' || type === 'integer')\r
+      enumString = this['enum'].join(', ');\r
+    else {\r
+      enumString = '"' + this['enum'].join('", "') + '"';\r
+    }\r
+\r
+    options += optionHtml('Enum', enumString);\r
+  }     \r
+\r
+  if (options.length > 0)\r
+    str = '<span class="propWrap">' + str + '<table class="optionsWrapper"><tr><th colspan="2">' + this.name + '</th></tr>' + options + '</table></span>';\r
+  \r
+  return str;\r
+};\r
+\r
+optionHtml = function(label, value) {\r
+  return '<tr><td class="optionName">' + label + ':</td><td>' + value + '</td></tr>';\r
+};\r
+\r
+typeFromJsonSchema = function(type, format) {\r
+  var str;\r
+  if(type === 'integer' && format === 'int32')\r
+    str = 'integer';\r
+  else if(type === 'integer' && format === 'int64')\r
+    str = 'long';\r
+  else if(type === 'integer' && typeof format === 'undefined')\r
+    str = 'long';\r
+  else if(type === 'string' && format === 'date-time')\r
+    str = 'date-time';\r
+  else if(type === 'string' && format === 'date')\r
+    str = 'date';\r
+  else if(type === 'number' && format === 'float')\r
+    str = 'float';\r
+  else if(type === 'number' && format === 'double')\r
+    str = 'double';\r
+  else if(type === 'number' && typeof format === 'undefined')\r
+    str = 'double';\r
+  else if(type === 'boolean')\r
+    str = 'boolean';\r
+  else if(type === 'string')\r
+    str = 'string';\r
+\r
+  return str;\r
+};\r
+\r
+var sampleModels = {};\r
+var cookies = {};\r
+var models = {};\r
+\r
+SwaggerClient.prototype.buildFrom1_2Spec = function (response) {\r
+  if (response.apiVersion !== null) {\r
+    this.apiVersion = response.apiVersion;\r
+  }\r
+  this.apis = {};\r
+  this.apisArray = [];\r
+  this.consumes = response.consumes;\r
+  this.produces = response.produces;\r
+  this.authSchemes = response.authorizations;\r
+  this.info = this.convertInfo(response.info);\r
+\r
+  var isApi = false, i, res;\r
+  for (i = 0; i < response.apis.length; i++) {\r
+    var api = response.apis[i];\r
+    if (api.operations) {\r
+      var j;\r
+      for (j = 0; j < api.operations.length; j++) {\r
+        operation = api.operations[j];\r
+        isApi = true;\r
+      }\r
+    }\r
+  }\r
+  if (response.basePath)\r
+    this.basePath = response.basePath;\r
+  else if (this.url.indexOf('?') > 0)\r
+    this.basePath = this.url.substring(0, this.url.lastIndexOf('?'));\r
+  else\r
+    this.basePath = this.url;\r
+\r
+  if (isApi) {\r
+    var newName = response.resourcePath.replace(/\//g, '');\r
+    this.resourcePath = response.resourcePath;\r
+    res = new SwaggerResource(response, this);\r
+    this.apis[newName] = res;\r
+    this.apisArray.push(res);\r
+    this.finish();\r
+  } else {\r
+    var k;\r
+    this.expectedResourceCount = response.apis.length;\r
+    for (k = 0; k < response.apis.length; k++) {\r
+      var resource = response.apis[k];\r
+      res = new SwaggerResource(resource, this);\r
+      this.apis[res.name] = res;\r
+      this.apisArray.push(res);\r
+    }\r
+  }\r
+  this.isValid = true;\r
+  return this;\r
+};\r
+\r
+SwaggerClient.prototype.finish = function() {\r
+  if (typeof this.success === 'function') {\r
+    this.isValid = true;\r
+    this.ready = true;\r
+    this.isBuilt = true;\r
+    this.selfReflect();\r
+    this.success();\r
+  }  \r
+};\r
+\r
+SwaggerClient.prototype.buildFrom1_1Spec = function (response) {\r
+  log('This API is using a deprecated version of Swagger!  Please see http://github.com/wordnik/swagger-core/wiki for more info');\r
+  if (response.apiVersion !== null)\r
+    this.apiVersion = response.apiVersion;\r
+  this.apis = {};\r
+  this.apisArray = [];\r
+  this.produces = response.produces;\r
+  this.info = this.convertInfo(response.info);\r
+  var isApi = false, res;\r
+  for (var i = 0; i < response.apis.length; i++) {\r
+    var api = response.apis[i];\r
+    if (api.operations) {\r
+      for (var j = 0; j < api.operations.length; j++) {\r
+        operation = api.operations[j];\r
+        isApi = true;\r
+      }\r
+    }\r
+  }\r
+  if (response.basePath) {\r
+    this.basePath = response.basePath;\r
+  } else if (this.url.indexOf('?') > 0) {\r
+    this.basePath = this.url.substring(0, this.url.lastIndexOf('?'));\r
+  } else {\r
+    this.basePath = this.url;\r
+  }\r
+  if (isApi) {\r
+    var newName = response.resourcePath.replace(/\//g, '');\r
+    this.resourcePath = response.resourcePath;\r
+    res = new SwaggerResource(response, this);\r
+    this.apis[newName] = res;\r
+    this.apisArray.push(res);\r
+    this.finish();\r
+  } else {\r
+    this.expectedResourceCount = response.apis.length;\r
+    for (k = 0; k < response.apis.length; k++) {\r
+      resource = response.apis[k];\r
+      res = new SwaggerResource(resource, this);\r
+      this.apis[res.name] = res;\r
+      this.apisArray.push(res);\r
+    }\r
+  }\r
+  this.isValid = true;\r
+  return this;\r
+};\r
+\r
+SwaggerClient.prototype.convertInfo = function (resp) {\r
+  if(typeof resp == 'object') {\r
+    var info = {};\r
+\r
+    info.title = resp.title;\r
+    info.description = resp.description;\r
+    info.termsOfService = resp.termsOfServiceUrl;\r
+    info.contact = {};\r
+    info.contact.name = resp.contact;\r
+    info.license = {};\r
+    info.license.name = resp.license;\r
+    info.license.url = resp.licenseUrl;\r
+\r
+    return info;\r
+  }\r
+};\r
+\r
+SwaggerClient.prototype.selfReflect = function () {\r
+  var resource, tag, ref;\r
+  if (this.apis === null) {\r
+    return false;\r
+  }\r
+  ref = this.apis;\r
+  for (tag in ref) {\r
+    api = ref[tag];\r
+    if (api.ready === null) {\r
+      return false;\r
+    }\r
+    this[tag] = api;\r
+    this[tag].help = __bind(api.help, api);\r
+  }\r
+  this.setConsolidatedModels();\r
+  this.ready = true;\r
+};\r
+\r
+SwaggerClient.prototype.setConsolidatedModels = function () {\r
+  var model, modelName, resource, resource_name, i, apis, models, results;\r
+  this.models = {};\r
+  apis = this.apis;\r
+  for (resource_name in apis) {\r
+    resource = apis[resource_name];\r
+    for (modelName in resource.models) {\r
+      if (typeof this.models[modelName] === 'undefined') {\r
+        this.models[modelName] = resource.models[modelName];\r
+        this.modelsArray.push(resource.models[modelName]);\r
+      }\r
+    }\r
+  }\r
+  models = this.modelsArray;\r
+  results = [];\r
+  for (i = 0; i < models.length; i++) {\r
+    model = models[i];\r
+    results.push(model.setReferencedModels(this.models));\r
+  }\r
+  return results;\r
+};\r
+\r
+var SwaggerResource = function (resourceObj, api) {\r
+  var _this = this;\r
+  this.api = api;\r
+  this.swaggerRequstHeaders = api.swaggerRequstHeaders;\r
+  this.path = (typeof this.api.resourcePath === 'string') ? this.api.resourcePath : resourceObj.path;\r
+  this.description = resourceObj.description;\r
+  this.authorizations = (resourceObj.authorizations || {});\r
+\r
+  var parts = this.path.split('/');\r
+  this.name = parts[parts.length - 1].replace('.{format}', '');\r
+  this.basePath = this.api.basePath;\r
+  this.operations = {};\r
+  this.operationsArray = [];\r
+  this.modelsArray = [];\r
+  this.models = api.models || {};\r
+  this.rawModels = {};\r
+  this.useJQuery = (typeof api.useJQuery !== 'undefined') ? api.useJQuery : null;\r
+\r
+  if ((resourceObj.apis) && this.api.resourcePath) {\r
+    this.addApiDeclaration(resourceObj);\r
+  } else {\r
+    if (typeof this.path === 'undefined') {\r
+      this.api.fail('SwaggerResources must have a path.');\r
+    }\r
+    if (this.path.substring(0, 4) === 'http') {\r
+      this.url = this.path.replace('{format}', 'json');\r
+    } else {\r
+      this.url = this.api.basePath + this.path.replace('{format}', 'json');\r
+    }\r
+    this.api.progress('fetching resource ' + this.name + ': ' + this.url);\r
+    var obj = {\r
+      url: this.url,\r
+      method: 'GET',\r
+      useJQuery: this.useJQuery,\r
+      headers: {\r
+        accept: this.swaggerRequstHeaders\r
+      },\r
+      on: {\r
+        response: function (resp) {\r
+          var responseObj = resp.obj || JSON.parse(resp.data);\r
+          _this.api.resourceCount += 1;\r
+          return _this.addApiDeclaration(responseObj);\r
+        },\r
+        error: function (response) {\r
+          _this.api.resourceCount += 1;\r
+          return _this.api.fail('Unable to read api \'' +\r
+          _this.name + '\' from path ' + _this.url + ' (server returned ' + response.statusText + ')');\r
+        }\r
+      }\r
+    };\r
+    var e = typeof window !== 'undefined' ? window : exports;\r
+    e.authorizations.apply(obj);\r
+    new SwaggerHttp().execute(obj);\r
+  }\r
+};\r
+\r
+SwaggerResource.prototype.help = function (dontPrint) {\r
+  var i;\r
+  var output = 'operations for the "' + this.name + '" tag';\r
+  for(i = 0; i < this.operationsArray.length; i++) {\r
+    var api = this.operationsArray[i];\r
+    output += '\n  * ' + api.nickname + ': ' + api.description;\r
+  }\r
+  if(dontPrint)\r
+    return output;\r
+  else {\r
+    log(output);\r
+    return output;\r
+  }\r
+};\r
+\r
+SwaggerResource.prototype.getAbsoluteBasePath = function (relativeBasePath) {\r
+  var pos, url;\r
+  url = this.api.basePath;\r
+  pos = url.lastIndexOf(relativeBasePath);\r
+  var parts = url.split('/');\r
+  var rootUrl = parts[0] + '//' + parts[2];\r
+\r
+  if (relativeBasePath.indexOf('http') === 0)\r
+    return relativeBasePath;\r
+  if (relativeBasePath === '/')\r
+    return rootUrl;\r
+  if (relativeBasePath.substring(0, 1) == '/') {\r
+    // use root + relative\r
+    return rootUrl + relativeBasePath;\r
+  }\r
+  else {\r
+    pos = this.basePath.lastIndexOf('/');\r
+    var base = this.basePath.substring(0, pos);\r
+    if (base.substring(base.length - 1) == '/')\r
+      return base + relativeBasePath;\r
+    else\r
+      return base + '/' + relativeBasePath;\r
+  }\r
+};\r
+\r
+SwaggerResource.prototype.addApiDeclaration = function (response) {\r
+  if (typeof response.produces === 'string')\r
+    this.produces = response.produces;\r
+  if (typeof response.consumes === 'string')\r
+    this.consumes = response.consumes;\r
+  if ((typeof response.basePath === 'string') && response.basePath.replace(/\s/g, '').length > 0)\r
+    this.basePath = response.basePath.indexOf('http') === -1 ? this.getAbsoluteBasePath(response.basePath) : response.basePath;\r
+  this.resourcePath = response.resourcePath;\r
+  this.addModels(response.models);\r
+  if (response.apis) {\r
+    for (var i = 0 ; i < response.apis.length; i++) {\r
+      var endpoint = response.apis[i];\r
+      this.addOperations(endpoint.path, endpoint.operations, response.consumes, response.produces);\r
+    }\r
+  }\r
+  this.api[this.name] = this;\r
+  this.ready = true;\r
+  if(this.api.resourceCount === this.api.expectedResourceCount)\r
+    this.api.finish();\r
+  return this;\r
+};\r
+\r
+SwaggerResource.prototype.addModels = function (models) {\r
+  if (typeof models === 'object') {\r
+    var modelName;\r
+    for (modelName in models) {\r
+      if (typeof this.models[modelName] === 'undefined') {\r
+        var swaggerModel = new SwaggerModel(modelName, models[modelName]);\r
+        this.modelsArray.push(swaggerModel);\r
+        this.models[modelName] = swaggerModel;\r
+        this.rawModels[modelName] = models[modelName];\r
+      }\r
+    }\r
+    var output = [];\r
+    for (var i = 0; i < this.modelsArray.length; i++) {\r
+      var model = this.modelsArray[i];\r
+      output.push(model.setReferencedModels(this.models));\r
+    }\r
+    return output;\r
+  }\r
+};\r
+\r
+SwaggerResource.prototype.addOperations = function (resource_path, ops, consumes, produces) {\r
+  if (ops) {\r
+    var output = [];\r
+    for (var i = 0; i < ops.length; i++) {\r
+      var o = ops[i];\r
+      consumes = this.consumes;\r
+      produces = this.produces;\r
+      if (typeof o.consumes !== 'undefined')\r
+        consumes = o.consumes;\r
+      else\r
+        consumes = this.consumes;\r
+\r
+      if (typeof o.produces !== 'undefined')\r
+        produces = o.produces;\r
+      else\r
+        produces = this.produces;\r
+      var type = (o.type || o.responseClass);\r
+\r
+      if (type === 'array') {\r
+        ref = null;\r
+        if (o.items)\r
+          ref = o.items.type || o.items.$ref;\r
+        type = 'array[' + ref + ']';\r
+      }\r
+      var responseMessages = o.responseMessages;\r
+      var method = o.method;\r
+      if (o.httpMethod) {\r
+        method = o.httpMethod;\r
+      }\r
+      if (o.supportedContentTypes) {\r
+        consumes = o.supportedContentTypes;\r
+      }\r
+      if (o.errorResponses) {\r
+        responseMessages = o.errorResponses;\r
+        for (var j = 0; j < responseMessages.length; j++) {\r
+          r = responseMessages[j];\r
+          r.message = r.reason;\r
+          r.reason = null;\r
+        }\r
+      }\r
+      o.nickname = this.sanitize(o.nickname);\r
+      var op = new SwaggerOperation(o.nickname,\r
+          resource_path,\r
+          method,\r
+          o.parameters,\r
+          o.summary,\r
+          o.notes,\r
+          type,\r
+          responseMessages, \r
+          this, \r
+          consumes, \r
+          produces, \r
+          o.authorizations, \r
+          o.deprecated);\r
+\r
+      this.operations[op.nickname] = op;\r
+      output.push(this.operationsArray.push(op));\r
+    }\r
+    return output;\r
+  }\r
+};\r
+\r
+SwaggerResource.prototype.sanitize = function (nickname) {\r
+  var op;\r
+  op = nickname.replace(/[\s!@#$%^&*()_+=\[{\]};:<>|.\/?,\\'""-]/g, '_');\r
+  op = op.replace(/((_){2,})/g, '_');\r
+  op = op.replace(/^(_)*/g, '');\r
+  op = op.replace(/([_])*$/g, '');\r
+  return op;\r
+};\r
+\r
+var SwaggerModel = function (modelName, obj) {\r
+  this.name = typeof obj.id !== 'undefined' ? obj.id : modelName;\r
+  this.properties = [];\r
+  var propertyName;\r
+  for (propertyName in obj.properties) {\r
+    if (obj.required) {\r
+      var value;\r
+      for (value in obj.required) {\r
+        if (propertyName === obj.required[value]) {\r
+          obj.properties[propertyName].required = true;\r
+        }\r
+      }\r
+    }\r
+    var prop = new SwaggerModelProperty(propertyName, obj.properties[propertyName], this);\r
+    this.properties.push(prop);\r
+  }\r
+};\r
+\r
+SwaggerModel.prototype.setReferencedModels = function (allModels) {\r
+  var results = [];\r
+  for (var i = 0; i < this.properties.length; i++) {\r
+    var property = this.properties[i];\r
+    var type = property.type || property.dataType;\r
+    if (allModels[type])\r
+      results.push(property.refModel = allModels[type]);\r
+    else if ((property.refDataType) && (allModels[property.refDataType]))\r
+      results.push(property.refModel = allModels[property.refDataType]);\r
+    else\r
+      results.push(void 0);\r
+  }\r
+  return results;\r
+};\r
+\r
+SwaggerModel.prototype.getMockSignature = function (modelsToIgnore) {\r
+  var i, prop, propertiesStr = [];\r
+  for (i = 0; i < this.properties.length; i++) {\r
+    prop = this.properties[i];\r
+    propertiesStr.push(prop.toString());\r
+  }\r
+\r
+  var strong = '<span class="strong">';\r
+  var strongClose = '</span>';\r
+  var classOpen = strong + this.name + ' {' + strongClose;\r
+  var classClose = strong + '}' + strongClose;\r
+  var returnVal = classOpen + '<div>' + propertiesStr.join(',</div><div>') + '</div>' + classClose;\r
+  if (!modelsToIgnore)\r
+    modelsToIgnore = [];\r
+  modelsToIgnore.push(this.name);\r
+\r
+  for (i = 0; i < this.properties.length; i++) {\r
+    prop = this.properties[i];\r
+    if ((prop.refModel) && modelsToIgnore.indexOf(prop.refModel.name) === -1) {\r
+      returnVal = returnVal + ('<br>' + prop.refModel.getMockSignature(modelsToIgnore));\r
+    }\r
+  }\r
+  return returnVal;\r
+};\r
+\r
+SwaggerModel.prototype.createJSONSample = function (modelsToIgnore) {\r
+  if (sampleModels[this.name]) {\r
+    return sampleModels[this.name];\r
+  }\r
+  else {\r
+    var result = {};\r
+    modelsToIgnore = (modelsToIgnore || []);\r
+    modelsToIgnore.push(this.name);\r
+    for (var i = 0; i < this.properties.length; i++) {\r
+      var prop = this.properties[i];\r
+      result[prop.name] = prop.getSampleValue(modelsToIgnore);\r
+    }\r
+    modelsToIgnore.pop(this.name);\r
+    return result;\r
+  }\r
+};\r
+\r
+var SwaggerModelProperty = function (name, obj, model) {\r
+  this.name = name;\r
+  this.dataType = obj.type || obj.dataType || obj.$ref;\r
+  this.isCollection = this.dataType && (this.dataType.toLowerCase() === 'array' || this.dataType.toLowerCase() === 'list' || this.dataType.toLowerCase() === 'set');\r
+  this.descr = obj.description;\r
+  this.required = obj.required;\r
+  this.defaultValue = applyModelPropertyMacro(obj, model);\r
+  if (obj.items) {\r
+    if (obj.items.type) {\r
+      this.refDataType = obj.items.type;\r
+    }\r
+    if (obj.items.$ref) {\r
+      this.refDataType = obj.items.$ref;\r
+    }\r
+  }\r
+  this.dataTypeWithRef = this.refDataType ? (this.dataType + '[' + this.refDataType + ']') : this.dataType;\r
+  if (obj.allowableValues) {\r
+    this.valueType = obj.allowableValues.valueType;\r
+    this.values = obj.allowableValues.values;\r
+    if (this.values) {\r
+      this.valuesString = '\'' + this.values.join('\' or \'') + '\'';\r
+    }\r
+  }\r
+  if (obj['enum']) {\r
+    this.valueType = 'string';\r
+    this.values = obj['enum'];\r
+    if (this.values) {\r
+      this.valueString = '\'' + this.values.join('\' or \'') + '\'';\r
+    }\r
+  }\r
+};\r
+\r
+SwaggerModelProperty.prototype.getSampleValue = function (modelsToIgnore) {\r
+  var result;\r
+  if ((this.refModel) && (modelsToIgnore.indexOf(this.refModel.name) === -1)) {\r
+    result = this.refModel.createJSONSample(modelsToIgnore);\r
+  } else {\r
+    if (this.isCollection) {\r
+      result = this.toSampleValue(this.refDataType);\r
+    } else {\r
+      result = this.toSampleValue(this.dataType);\r
+    }\r
+  }\r
+  if (this.isCollection) {\r
+    return [result];\r
+  } else {\r
+    return result;\r
+  }\r
+};\r
+\r
+SwaggerModelProperty.prototype.toSampleValue = function (value) {\r
+  var result;\r
+  if ((typeof this.defaultValue !== 'undefined') && this.defaultValue) {\r
+    result = this.defaultValue;\r
+  } else if (value === 'integer') {\r
+    result = 0;\r
+  } else if (value === 'boolean') {\r
+    result = false;\r
+  } else if (value === 'double' || value === 'number') {\r
+    result = 0.0;\r
+  } else if (value === 'string') {\r
+    result = '';\r
+  } else {\r
+    result = value;\r
+  }\r
+  return result;\r
+};\r
+\r
+SwaggerModelProperty.prototype.toString = function () {\r
+  var req = this.required ? 'propReq' : 'propOpt';\r
+  var str = '<span class="propName ' + req + '">' + this.name + '</span> (<span class="propType">' + this.dataTypeWithRef + '</span>';\r
+  if (!this.required) {\r
+    str += ', <span class="propOptKey">optional</span>';\r
+  }\r
+  str += ')';\r
+  if (this.values) {\r
+    str += ' = <span class="propVals">[\'' + this.values.join('\' or \'') + '\']</span>';\r
+  }\r
+  if (this.descr) {\r
+    str += ': <span class="propDesc">' + this.descr + '</span>';\r
+  }\r
+  return str;\r
+};\r
+\r
+var SwaggerOperation = function (nickname, path, method, parameters, summary, notes, type, responseMessages, resource, consumes, produces, authorizations, deprecated) {\r
+  var _this = this;\r
+\r
+  var errors = [];\r
+  this.nickname = (nickname || errors.push('SwaggerOperations must have a nickname.'));\r
+  this.path = (path || errors.push('SwaggerOperation ' + nickname + ' is missing path.'));\r
+  this.method = (method || errors.push('SwaggerOperation ' + nickname + ' is missing method.'));\r
+  this.parameters = parameters ? parameters : [];\r
+  this.summary = summary;\r
+  this.notes = notes;\r
+  this.type = type;\r
+  this.responseMessages = (responseMessages || []);\r
+  this.resource = (resource || errors.push('Resource is required'));\r
+  this.consumes = consumes;\r
+  this.produces = produces;\r
+  this.authorizations = typeof authorizations !== 'undefined' ? authorizations : resource.authorizations;\r
+  this.deprecated = deprecated;\r
+  this['do'] = __bind(this['do'], this);\r
+\r
+\r
+  if(typeof this.deprecated === 'string') {\r
+    switch(this.deprecated.toLowerCase()) {\r
+      case 'true': case 'yes': case '1': {\r
+        this.deprecated = true;\r
+        break;\r
+      }\r
+      case 'false': case 'no': case '0': case null: {\r
+        this.deprecated = false;\r
+        break;\r
+      }\r
+      default: this.deprecated = Boolean(this.deprecated);\r
+    }\r
+  }\r
+\r
+  if (errors.length > 0) {\r
+    console.error('SwaggerOperation errors', errors, arguments);\r
+    this.resource.api.fail(errors);\r
+  }\r
+\r
+  this.path = this.path.replace('{format}', 'json');\r
+  this.method = this.method.toLowerCase();\r
+  this.isGetMethod = this.method === 'get';\r
+\r
+  var i, j, v;\r
+  this.resourceName = this.resource.name;\r
+  if (typeof this.type !== 'undefined' && this.type === 'void')\r
+    this.type = null;\r
+  else {\r
+    this.responseClassSignature = this.getSignature(this.type, this.resource.models);\r
+    this.responseSampleJSON = this.getSampleJSON(this.type, this.resource.models);\r
+  }\r
+\r
+  for (i = 0; i < this.parameters.length; i++) {\r
+    var param = this.parameters[i];\r
+    // might take this away\r
+    param.name = param.name || param.type || param.dataType;\r
+    // for 1.1 compatibility\r
+    type = param.type || param.dataType;\r
+    if (type === 'array') {\r
+      type = 'array[' + (param.items.$ref ? param.items.$ref : param.items.type) + ']';\r
+    }\r
+    param.type = type;\r
+\r
+    if (type && type.toLowerCase() === 'boolean') {\r
+      param.allowableValues = {};\r
+      param.allowableValues.values = ['true', 'false'];\r
+    }\r
+    param.signature = this.getSignature(type, this.resource.models);\r
+    param.sampleJSON = this.getSampleJSON(type, this.resource.models);\r
+\r
+    var enumValue = param['enum'];\r
+    if (typeof enumValue !== 'undefined') {\r
+      param.isList = true;\r
+      param.allowableValues = {};\r
+      param.allowableValues.descriptiveValues = [];\r
+\r
+      for (j = 0; j < enumValue.length; j++) {\r
+        v = enumValue[j];\r
+        if (param.defaultValue) {\r
+          param.allowableValues.descriptiveValues.push({\r
+            value: String(v),\r
+            isDefault: (v === param.defaultValue)\r
+          });\r
+        }\r
+        else {\r
+          param.allowableValues.descriptiveValues.push({\r
+            value: String(v),\r
+            isDefault: false\r
+          });\r
+        }\r
+      }\r
+    }\r
+    else if (param.allowableValues) {\r
+      if (param.allowableValues.valueType === 'RANGE')\r
+        param.isRange = true;\r
+      else\r
+        param.isList = true;\r
+      if (param.allowableValues) {\r
+        param.allowableValues.descriptiveValues = [];\r
+        if (param.allowableValues.values) {\r
+          for (j = 0; j < param.allowableValues.values.length; j++) {\r
+            v = param.allowableValues.values[j];\r
+            if (param.defaultValue !== null) {\r
+              param.allowableValues.descriptiveValues.push({\r
+                value: String(v),\r
+                isDefault: (v === param.defaultValue)\r
+              });\r
+            }\r
+            else {\r
+              param.allowableValues.descriptiveValues.push({\r
+                value: String(v),\r
+                isDefault: false\r
+              });\r
+            }\r
+          }\r
+        }\r
+      }\r
+    }\r
+    param.defaultValue = applyParameterMacro(this, param);\r
+  }\r
+  var defaultSuccessCallback = this.resource.api.defaultSuccessCallback || null;\r
+  var defaultErrorCallback = this.resource.api.defaultErrorCallback || null;\r
+\r
+  this.resource[this.nickname] = function (args, opts, callback, error) {\r
+    var arg1, arg2, arg3, arg4;\r
+    if(typeof args === 'function') {  // right shift 3\r
+      arg1 = {}; arg2 = {}; arg3 = args; arg4 = opts;\r
+    }\r
+    else if(typeof args === 'object' && typeof opts === 'function') { // right shift 2\r
+      arg1 = args; arg2 = {}; arg3 = opts; arg4 = callback;\r
+    }\r
+    else {\r
+      arg1 = args; arg2 = opts; arg3 = callback; arg4 = error;\r
+    }\r
+    return _this['do'](arg1 || {}, arg2 || {}, arg3 || defaultSuccessCallback, arg4 || defaultErrorCallback);\r
+  };\r
+\r
+  this.resource[this.nickname].help = function (dontPrint) {\r
+    return _this.help(dontPrint);\r
+  };\r
+  this.resource[this.nickname].asCurl = function (args) {\r
+    return _this.asCurl(args);\r
+  };\r
+};\r
+\r
+SwaggerOperation.prototype.isListType = function (type) {\r
+  if (type && type.indexOf('[') >= 0) {\r
+    return type.substring(type.indexOf('[') + 1, type.indexOf(']'));\r
+  } else {\r
+    return void 0;\r
+  }\r
+};\r
+\r
+SwaggerOperation.prototype.getSignature = function (type, models) {\r
+  var isPrimitive, listType;\r
+  listType = this.isListType(type);\r
+  isPrimitive = ((typeof listType !== 'undefined') && models[listType]) || (typeof models[type] !== 'undefined') ? false : true;\r
+  if (isPrimitive) {\r
+    return type;\r
+  } else {\r
+    if (typeof listType !== 'undefined') {\r
+      return models[listType].getMockSignature();\r
+    } else {\r
+      return models[type].getMockSignature();\r
+    }\r
+  }\r
+};\r
+\r
+SwaggerOperation.prototype.getSampleJSON = function (type, models) {\r
+  var isPrimitive, listType, val;\r
+  listType = this.isListType(type);\r
+  isPrimitive = ((typeof listType !== 'undefined') && models[listType]) || (typeof models[type] !== 'undefined') ? false : true;\r
+  val = isPrimitive ? void 0 : (listType ? models[listType].createJSONSample() : models[type].createJSONSample());\r
+  if (val) {\r
+    val = listType ? [val] : val;\r
+    if (typeof val == 'string')\r
+      return val;\r
+    else if (typeof val === 'object') {\r
+      var t = val;\r
+      if (val instanceof Array && val.length > 0) {\r
+        t = val[0];\r
+      }\r
+      if (t.nodeName) {\r
+        var xmlString = new XMLSerializer().serializeToString(t);\r
+        return this.formatXml(xmlString);\r
+      }\r
+      else\r
+        return JSON.stringify(val, null, 2);\r
+    }\r
+    else\r
+      return val;\r
+  }\r
+};\r
+\r
+SwaggerOperation.prototype['do'] = function (args, opts, callback, error) {\r
+  var key, param, params, possibleParams = [], req, value;\r
+\r
+  if (typeof error !== 'function') {\r
+    error = function (xhr, textStatus, error) {\r
+      return log(xhr, textStatus, error);\r
+    };\r
+  }\r
+\r
+  if (typeof callback !== 'function') {\r
+    callback = function (response) {\r
+      var content;\r
+      content = null;\r
+      if (response !== null) {\r
+        content = response.data;\r
+      } else {\r
+        content = 'no data';\r
+      }\r
+      return log('default callback: ' + content);\r
+    };\r
+  }\r
+\r
+  params = {};\r
+  params.headers = [];\r
+  if (args.headers) {\r
+    params.headers = args.headers;\r
+    delete args.headers;\r
+  }\r
+  // allow override from the opts\r
+  if(opts && opts.responseContentType) {\r
+    params.headers['Content-Type'] = opts.responseContentType;\r
+  }\r
+  if(opts && opts.requestContentType) {\r
+    params.headers.Accept = opts.requestContentType;\r
+  }\r
+\r
+  for (var i = 0; i < this.parameters.length; i++) {\r
+    param = this.parameters[i];\r
+    if (param.paramType === 'header') {\r
+      if (typeof args[param.name] !== 'undefined')\r
+        params.headers[param.name] = args[param.name];\r
+    }\r
+    else if (param.paramType === 'form' || param.paramType.toLowerCase() === 'file')\r
+      possibleParams.push(param);\r
+    else if (param.paramType === 'body' && param.name !== 'body' && typeof args[param.name] !== 'undefined') {\r
+      if (args.body) {\r
+        throw new Error('Saw two body params in an API listing; expecting a max of one.');\r
+      }\r
+      args.body = args[param.name];\r
+    }\r
+  }\r
+\r
+  if (typeof args.body !== 'undefined') {\r
+    params.body = args.body;\r
+    delete args.body;\r
+  }\r
+\r
+  if (possibleParams) {\r
+    for (key in possibleParams) {\r
+      value = possibleParams[key];\r
+      if (args[value.name]) {\r
+        params[value.name] = args[value.name];\r
+      }\r
+    }\r
+  }\r
+\r
+  req = new SwaggerRequest(this.method, this.urlify(args), params, opts, callback, error, this);\r
+  if (opts.mock) {\r
+    return req;\r
+  } else {\r
+    return true;\r
+  }\r
+};\r
+\r
+SwaggerOperation.prototype.pathJson = function () {\r
+  return this.path.replace('{format}', 'json');\r
+};\r
+\r
+SwaggerOperation.prototype.pathXml = function () {\r
+  return this.path.replace('{format}', 'xml');\r
+};\r
+\r
+SwaggerOperation.prototype.encodePathParam = function (pathParam) {\r
+  var encParts, part, parts, _i, _len;\r
+  pathParam = pathParam.toString();\r
+  if (pathParam.indexOf('/') === -1) {\r
+    return encodeURIComponent(pathParam);\r
+  } else {\r
+    parts = pathParam.split('/');\r
+    encParts = [];\r
+    for (_i = 0, _len = parts.length; _i < _len; _i++) {\r
+      part = parts[_i];\r
+      encParts.push(encodeURIComponent(part));\r
+    }\r
+    return encParts.join('/');\r
+  }\r
+};\r
+\r
+SwaggerOperation.prototype.urlify = function (args) {\r
+  var i, j, param, url;\r
+  // ensure no double slashing...\r
+  if(this.resource.basePath.length > 1 && this.resource.basePath.slice(-1) === '/' && this.pathJson().charAt(0) === '/')\r
+    url = this.resource.basePath + this.pathJson().substring(1);\r
+  else\r
+    url = this.resource.basePath + this.pathJson();\r
+  var params = this.parameters;\r
+  for (i = 0; i < params.length; i++) {\r
+    param = params[i];\r
+    if (param.paramType === 'path') {\r
+      if (typeof args[param.name] !== 'undefined') {\r
+        // apply path params and remove from args\r
+        var reg = new RegExp('\\{\\s*?' + param.name + '[^\\{\\}\\/]*(?:\\{.*?\\}[^\\{\\}\\/]*)*\\}(?=(\\/?|$))', 'gi');\r
+        url = url.replace(reg, this.encodePathParam(args[param.name]));\r
+        delete args[param.name];\r
+      }\r
+      else\r
+        throw '' + param.name + ' is a required path param.';\r
+    }\r
+  }\r
+\r
+  var queryParams = '';\r
+  for (i = 0; i < params.length; i++) {\r
+    param = params[i];\r
+    if(param.paramType === 'query') {\r
+      if (queryParams !== '')\r
+        queryParams += '&';    \r
+      if (Array.isArray(param)) {\r
+        var output = '';   \r
+        for(j = 0; j < param.length; j++) {    \r
+          if(j > 0)    \r
+            output += ',';   \r
+          output += encodeURIComponent(param[j]);    \r
+        }    \r
+        queryParams += encodeURIComponent(param.name) + '=' + output;    \r
+      }\r
+      else {\r
+        if (typeof args[param.name] !== 'undefined') {\r
+          queryParams += encodeURIComponent(param.name) + '=' + encodeURIComponent(args[param.name]);\r
+        } else {\r
+          if (param.required)\r
+            throw '' + param.name + ' is a required query param.';\r
+        }\r
+      }\r
+    }\r
+  }\r
+  if ((queryParams) && queryParams.length > 0)\r
+    url += '?' + queryParams;\r
+  return url;\r
+};\r
+\r
+SwaggerOperation.prototype.supportHeaderParams = function () {\r
+  return this.resource.api.supportHeaderParams;\r
+};\r
+\r
+SwaggerOperation.prototype.supportedSubmitMethods = function () {\r
+  return this.resource.api.supportedSubmitMethods;\r
+};\r
+\r
+SwaggerOperation.prototype.getQueryParams = function (args) {\r
+  return this.getMatchingParams(['query'], args);\r
+};\r
+\r
+SwaggerOperation.prototype.getHeaderParams = function (args) {\r
+  return this.getMatchingParams(['header'], args);\r
+};\r
+\r
+SwaggerOperation.prototype.getMatchingParams = function (paramTypes, args) {\r
+  var matchingParams = {};\r
+  var params = this.parameters;\r
+  for (var i = 0; i < params.length; i++) {\r
+    param = params[i];\r
+    if (args && args[param.name])\r
+      matchingParams[param.name] = args[param.name];\r
+  }\r
+  var headers = this.resource.api.headers;\r
+  var name;\r
+  for (name in headers) {\r
+    var value = headers[name];\r
+    matchingParams[name] = value;\r
+  }\r
+  return matchingParams;\r
+};\r
+\r
+SwaggerOperation.prototype.help = function (dontPrint) {\r
+  var msg = this.nickname + ': ' + this.summary;\r
+  var params = this.parameters;\r
+  for (var i = 0; i < params.length; i++) {\r
+    var param = params[i];\r
+    msg += '\n* ' + param.name + (param.required ? ' (required)' : '') + " - " + param.description;\r
+  }\r
+  if(dontPrint)\r
+    return msg;\r
+  else {\r
+    console.log(msg);\r
+    return msg;\r
+  }\r
+};\r
+\r
+SwaggerOperation.prototype.asCurl = function (args) {\r
+  var results = [];\r
+  var i;\r
+\r
+  var headers = SwaggerRequest.prototype.setHeaders(args, {}, this);    \r
+  for(i = 0; i < this.parameters.length; i++) {\r
+    var param = this.parameters[i];\r
+    if(param.paramType && param.paramType === 'header' && args[param.name]) {\r
+      headers[param.name] = args[param.name];\r
+    }\r
+  }\r
+\r
+  var key;\r
+  for (key in headers) {\r
+    results.push('--header "' + key + ': ' + headers[key] + '"');\r
+  }\r
+  return 'curl ' + (results.join(' ')) + ' ' + this.urlify(args);\r
+};\r
+\r
+SwaggerOperation.prototype.formatXml = function (xml) {\r
+  var contexp, formatted, indent, lastType, lines, ln, pad, reg, transitions, wsexp, _fn, _i, _len;\r
+  reg = /(>)(<)(\/*)/g;\r
+  wsexp = /[ ]*(.*)[ ]+\n/g;\r
+  contexp = /(<.+>)(.+\n)/g;\r
+  xml = xml.replace(reg, '$1\n$2$3').replace(wsexp, '$1\n').replace(contexp, '$1\n$2');\r
+  pad = 0;\r
+  formatted = '';\r
+  lines = xml.split('\n');\r
+  indent = 0;\r
+  lastType = 'other';\r
+  transitions = {\r
+    'single->single': 0,\r
+    'single->closing': -1,\r
+    'single->opening': 0,\r
+    'single->other': 0,\r
+    'closing->single': 0,\r
+    'closing->closing': -1,\r
+    'closing->opening': 0,\r
+    'closing->other': 0,\r
+    'opening->single': 1,\r
+    'opening->closing': 0,\r
+    'opening->opening': 1,\r
+    'opening->other': 1,\r
+    'other->single': 0,\r
+    'other->closing': -1,\r
+    'other->opening': 0,\r
+    'other->other': 0\r
+  };\r
+  _fn = function (ln) {\r
+    var fromTo, j, key, padding, type, types, value;\r
+    types = {\r
+      single: Boolean(ln.match(/<.+\/>/)),\r
+      closing: Boolean(ln.match(/<\/.+>/)),\r
+      opening: Boolean(ln.match(/<[^!?].*>/))\r
+    };\r
+    type = ((function () {\r
+      var _results;\r
+      _results = [];\r
+      for (key in types) {\r
+        value = types[key];\r
+        if (value) {\r
+          _results.push(key);\r
+        }\r
+      }\r
+      return _results;\r
+    })())[0];\r
+    type = type === void 0 ? 'other' : type;\r
+    fromTo = lastType + '->' + type;\r
+    lastType = type;\r
+    padding = '';\r
+    indent += transitions[fromTo];\r
+    padding = ((function () {\r
+      var _j, _ref5, _results;\r
+      _results = [];\r
+      for (j = _j = 0, _ref5 = indent; 0 <= _ref5 ? _j < _ref5 : _j > _ref5; j = 0 <= _ref5 ? ++_j : --_j) {\r
+        _results.push('  ');\r
+      }\r
+      return _results;\r
+    })()).join('');\r
+    if (fromTo === 'opening->closing') {\r
+      formatted = formatted.substr(0, formatted.length - 1) + ln + '\n';\r
+    } else {\r
+      formatted += padding + ln + '\n';\r
+    }\r
+  };\r
+  for (_i = 0, _len = lines.length; _i < _len; _i++) {\r
+    ln = lines[_i];\r
+    _fn(ln);\r
+  }\r
+  return formatted;\r
+};\r
+\r
+var SwaggerRequest = function (type, url, params, opts, successCallback, errorCallback, operation, execution) {\r
+  var _this = this;\r
+  var errors = [];\r
+\r
+  this.useJQuery = (typeof operation.resource.useJQuery !== 'undefined' ? operation.resource.useJQuery : null);\r
+  this.type = (type || errors.push('SwaggerRequest type is required (get/post/put/delete/patch/options).'));\r
+  this.url = (url || errors.push('SwaggerRequest url is required.'));\r
+  this.params = params;\r
+  this.opts = opts;\r
+  this.successCallback = (successCallback || errors.push('SwaggerRequest successCallback is required.'));\r
+  this.errorCallback = (errorCallback || errors.push('SwaggerRequest error callback is required.'));\r
+  this.operation = (operation || errors.push('SwaggerRequest operation is required.'));\r
+  this.execution = execution;\r
+  this.headers = (params.headers || {});\r
+\r
+  if (errors.length > 0) {\r
+    throw errors;\r
+  }\r
+\r
+  this.type = this.type.toUpperCase();\r
+\r
+  // set request, response content type headers\r
+  var headers = this.setHeaders(params, opts, this.operation);\r
+  var body = params.body;\r
+\r
+  // encode the body for form submits\r
+  if (headers['Content-Type']) {\r
+    var key, value, values = {}, i;\r
+    var operationParams = this.operation.parameters;\r
+    for (i = 0; i < operationParams.length; i++) {\r
+      var param = operationParams[i];\r
+      if (param.paramType === 'form')\r
+        values[param.name] = param;\r
+    }\r
+\r
+    if (headers['Content-Type'].indexOf('application/x-www-form-urlencoded') === 0) {\r
+      var encoded = '';\r
+      for (key in values) {\r
+        value = this.params[key];\r
+        if (typeof value !== 'undefined') {\r
+          if (encoded !== '')\r
+            encoded += '&';\r
+          encoded += encodeURIComponent(key) + '=' + encodeURIComponent(value);\r
+        }\r
+      }\r
+      body = encoded;\r
+    }\r
+    else if (headers['Content-Type'].indexOf('multipart/form-data') === 0) {\r
+      // encode the body for form submits\r
+      var data = '';\r
+      var boundary = '----SwaggerFormBoundary' + Date.now();\r
+      for (key in values) {\r
+        value = this.params[key];\r
+        if (typeof value !== 'undefined') {\r
+          data += '--' + boundary + '\n';\r
+          data += 'Content-Disposition: form-data; name="' + key + '"';\r
+          data += '\n\n';\r
+          data += value + '\n';\r
+        }\r
+      }\r
+      data += '--' + boundary + '--\n';\r
+      headers['Content-Type'] = 'multipart/form-data; boundary=' + boundary;\r
+      body = data;\r
+    }\r
+  }\r
+\r
+  var obj;\r
+  if (!((this.headers) && (this.headers.mock))) {\r
+    obj = {\r
+      url: this.url,\r
+      method: this.type,\r
+      headers: headers,\r
+      body: body,\r
+      useJQuery: this.useJQuery,\r
+      on: {\r
+        error: function (response) {\r
+          return _this.errorCallback(response, _this.opts.parent);\r
+        },\r
+        redirect: function (response) {\r
+          return _this.successCallback(response, _this.opts.parent);\r
+        },\r
+        307: function (response) {\r
+          return _this.successCallback(response, _this.opts.parent);\r
+        },\r
+        response: function (response) {\r
+          return _this.successCallback(response, _this.opts.parent);\r
+        }\r
+      }\r
+    };\r
+\r
+    var status = false;\r
+    if (this.operation.resource && this.operation.resource.api && this.operation.resource.api.clientAuthorizations) {\r
+      // Get the client authorizations from the resource declaration\r
+      status = this.operation.resource.api.clientAuthorizations.apply(obj, this.operation.authorizations);\r
+    } else {\r
+      // Get the client authorization from the default authorization declaration\r
+      var e;\r
+      if (typeof window !== 'undefined') {\r
+        e = window;\r
+      } else {\r
+        e = exports;\r
+      }\r
+      status = e.authorizations.apply(obj, this.operation.authorizations);\r
+    }\r
+\r
+    if (!opts.mock) {\r
+      if (status !== false) {\r
+        new SwaggerHttp().execute(obj);\r
+      } else {\r
+        obj.canceled = true;\r
+      }\r
+    } else {\r
+      return obj;\r
+    }\r
+  }\r
+  return obj;\r
+};\r
+\r
+SwaggerRequest.prototype.setHeaders = function (params, opts, operation) {\r
+  // default type\r
+  var accepts = opts.responseContentType || 'application/json';\r
+  var consumes = opts.requestContentType || 'application/json';\r
+\r
+  var allDefinedParams = operation.parameters;\r
+  var definedFormParams = [];\r
+  var definedFileParams = [];\r
+  var body = params.body;\r
+  var headers = {};\r
+\r
+  // get params from the operation and set them in definedFileParams, definedFormParams, headers\r
+  var i;\r
+  for (i = 0; i < allDefinedParams.length; i++) {\r
+    var param = allDefinedParams[i];\r
+    if (param.paramType === 'form')\r
+      definedFormParams.push(param);\r
+    else if (param.paramType === 'file')\r
+      definedFileParams.push(param);\r
+    else if (param.paramType === 'header' && this.params.headers) {\r
+      var key = param.name;\r
+      var headerValue = this.params.headers[param.name];\r
+      if (typeof this.params.headers[param.name] !== 'undefined')\r
+        headers[key] = headerValue;\r
+    }\r
+  }\r
+\r
+  // if there's a body, need to set the accepts header via requestContentType\r
+  if (body && (this.type === 'POST' || this.type === 'PUT' || this.type === 'PATCH' || this.type === 'DELETE')) {\r
+    if (this.opts.requestContentType)\r
+      consumes = this.opts.requestContentType;\r
+  } else {\r
+    // if any form params, content type must be set\r
+    if (definedFormParams.length > 0) {\r
+      if (definedFileParams.length > 0)\r
+        consumes = 'multipart/form-data';\r
+      else\r
+        consumes = 'application/x-www-form-urlencoded';\r
+    }\r
+    else if (this.type === 'DELETE')\r
+      body = '{}';\r
+    else if (this.type != 'DELETE')\r
+      consumes = null;\r
+  }\r
+\r
+  if (consumes && this.operation.consumes) {\r
+    if (this.operation.consumes.indexOf(consumes) === -1) {\r
+      log('server doesn\'t consume ' + consumes + ', try ' + JSON.stringify(this.operation.consumes));\r
+    }\r
+  }\r
+\r
+  if (this.opts && this.opts.responseContentType) {\r
+    accepts = this.opts.responseContentType;\r
+  } else {\r
+    accepts = 'application/json';\r
+  }\r
+  if (accepts && operation.produces) {\r
+    if (operation.produces.indexOf(accepts) === -1) {\r
+      log('server can\'t produce ' + accepts);\r
+    }\r
+  }\r
+\r
+  if ((consumes && body !== '') || (consumes === 'application/x-www-form-urlencoded'))\r
+    headers['Content-Type'] = consumes;\r
+  if (accepts)\r
+    headers.Accept = accepts;\r
+  return headers;\r
+};\r
+\r
+/**\r
+ * SwaggerHttp is a wrapper for executing requests\r
+ */\r
+var SwaggerHttp = function() {};\r
+\r
+SwaggerHttp.prototype.execute = function(obj, opts) {\r
+  if(obj && (typeof obj.useJQuery === 'boolean'))\r
+    this.useJQuery = obj.useJQuery;\r
+  else\r
+    this.useJQuery = this.isIE8();\r
+\r
+  if(obj && typeof obj.body === 'object') {\r
+    if(obj.body.type && obj.body.type !== 'formData')\r
+      obj.body = JSON.stringify(obj.body);\r
+    else {\r
+      obj.contentType = false;\r
+      obj.processData = false;\r
+      // delete obj.cache;\r
+      delete obj.headers['Content-Type'];\r
+    }\r
+  }\r
+\r
+  if(this.useJQuery)\r
+    return new JQueryHttpClient(opts).execute(obj);\r
+  else\r
+    return new ShredHttpClient(opts).execute(obj);\r
+};\r
+\r
+SwaggerHttp.prototype.isIE8 = function() {\r
+  var detectedIE = false;\r
+  if (typeof navigator !== 'undefined' && navigator.userAgent) {\r
+    nav = navigator.userAgent.toLowerCase();\r
+    if (nav.indexOf('msie') !== -1) {\r
+      var version = parseInt(nav.split('msie')[1]);\r
+      if (version <= 8) {\r
+        detectedIE = true;\r
+      }\r
+    }\r
+  }\r
+  return detectedIE;\r
+};\r
+\r
+/*\r
+ * JQueryHttpClient lets a browser take advantage of JQuery's cross-browser magic.\r
+ * NOTE: when jQuery is available it will export both '$' and 'jQuery' to the global space.\r
+ *       Since we are using closures here we need to alias it for internal use.\r
+ */\r
+var JQueryHttpClient = function(options) {\r
+  "use strict";\r
+  if(!jQuery){\r
+    var jQuery = window.jQuery;\r
+  }\r
+};\r
+\r
+JQueryHttpClient.prototype.execute = function(obj) {\r
+  var cb = obj.on;\r
+  var request = obj;\r
+\r
+  obj.type = obj.method;\r
+  obj.cache = false;\r
+  delete obj.useJQuery;\r
+\r
+  /*\r
+  obj.beforeSend = function(xhr) {\r
+    var key, results;\r
+    if (obj.headers) {\r
+      results = [];\r
+      for (key in obj.headers) {\r
+        if (key.toLowerCase() === "content-type") {\r
+          results.push(obj.contentType = obj.headers[key]);\r
+        } else if (key.toLowerCase() === "accept") {\r
+          results.push(obj.accepts = obj.headers[key]);\r
+        } else {\r
+          results.push(xhr.setRequestHeader(key, obj.headers[key]));\r
+        }\r
+      }\r
+      return results;\r
+    }\r
+  };*/\r
+\r
+  obj.data = obj.body;\r
+  delete obj.body;\r
+  obj.complete = function(response, textStatus, opts) {\r
+    var headers = {},\r
+      headerArray = response.getAllResponseHeaders().split("\n");\r
+\r
+    for(var i = 0; i < headerArray.length; i++) {\r
+      var toSplit = headerArray[i].trim();\r
+      if(toSplit.length === 0)\r
+        continue;\r
+      var separator = toSplit.indexOf(":");\r
+      if(separator === -1) {\r
+        // Name but no value in the header\r
+        headers[toSplit] = null;\r
+        continue;\r
+      }\r
+      var name = toSplit.substring(0, separator).trim(),\r
+        value = toSplit.substring(separator + 1).trim();\r
+      headers[name] = value;\r
+    }\r
+\r
+    var out = {\r
+      url: request.url,\r
+      method: request.method,\r
+      status: response.status,\r
+      statusText: response.statusText,\r
+      data: response.responseText,\r
+      headers: headers\r
+    };\r
+\r
+    var contentType = (headers["content-type"]||headers["Content-Type"]||null);\r
+    if(contentType) {\r
+      if(contentType.indexOf("application/json") === 0 || contentType.indexOf("+json") > 0) {\r
+        try {\r
+          out.obj = response.responseJSON || JSON.parse(out.data) || {};\r
+        } catch (ex) {\r
+          // do not set out.obj\r
+          log("unable to parse JSON content");\r
+        }\r
+      }\r
+    }\r
+\r
+    if(response.status >= 200 && response.status < 300)\r
+      cb.response(out);\r
+    else if(response.status === 0 || (response.status >= 400 && response.status < 599))\r
+      cb.error(out);\r
+    else\r
+      return cb.response(out);\r
+  };\r
+\r
+  jQuery.support.cors = true;\r
+  return jQuery.ajax(obj);\r
+};\r
+\r
+/*\r
+ * ShredHttpClient is a light-weight, node or browser HTTP client\r
+ */\r
+var ShredHttpClient = function(opts) {\r
+  this.opts = (opts||{});\r
+  this.isInitialized = false;\r
+\r
+  var identity, toString;\r
+\r
+  if (typeof window !== 'undefined') {\r
+    this.Shred = require("./shred");\r
+    this.content = require("./shred/content");\r
+  }\r
+  else\r
+    this.Shred = require("shred");\r
+  this.shred = new this.Shred(opts);\r
+};\r
+\r
+ShredHttpClient.prototype.initShred = function () {\r
+  this.isInitialized = true;\r
+  this.registerProcessors(this.shred);\r
+};\r
+\r
+ShredHttpClient.prototype.registerProcessors = function(shred) {\r
+  var identity = function(x) {\r
+    return x;\r
+  };\r
+  var toString = function(x) {\r
+    return x.toString();\r
+  };\r
+\r
+  if (typeof window !== 'undefined') {\r
+    this.content.registerProcessor(["application/json; charset=utf-8", "application/json", "json"], {\r
+      parser: identity,\r
+      stringify: toString\r
+    });\r
+  } else {\r
+    this.Shred.registerProcessor(["application/json; charset=utf-8", "application/json", "json"], {\r
+      parser: identity,\r
+      stringify: toString\r
+    });\r
+  }\r
+};\r
+\r
+ShredHttpClient.prototype.execute = function(obj) {\r
+  if(!this.isInitialized)\r
+    this.initShred();\r
+\r
+  var cb = obj.on, res;\r
+  var transform = function(response) {\r
+    var out = {\r
+      headers: response._headers,\r
+      url: response.request.url,\r
+      method: response.request.method,\r
+      status: response.status,\r
+      data: response.content.data\r
+    };\r
+\r
+    var headers = response._headers.normalized || response._headers;\r
+    var contentType = (headers["content-type"]||headers["Content-Type"]||null);\r
+\r
+    if(contentType) {\r
+      if(contentType.indexOf("application/json") === 0 || contentType.indexOf("+json") > 0) {\r
+        if(response.content.data && response.content.data !== "")\r
+          try{\r
+            out.obj = JSON.parse(response.content.data);\r
+          }\r
+          catch (e) {\r
+            // unable to parse\r
+          }\r
+        else\r
+          out.obj = {};\r
+      }\r
+    }\r
+    return out;\r
+  };\r
+\r
+  // Transform an error into a usable response-like object\r
+  var transformError = function (error) {\r
+    var out = {\r
+      // Default to a status of 0 - The client will treat this as a generic permissions sort of error\r
+      status: 0,\r
+      data: error.message || error\r
+    };\r
+\r
+    if (error.code) {\r
+      out.obj = error;\r
+\r
+      if (error.code === 'ENOTFOUND' || error.code === 'ECONNREFUSED') {\r
+        // We can tell the client that this should be treated as a missing resource and not as a permissions thing\r
+        out.status = 404;\r
+      }\r
+    }\r
+    return out;\r
+  };\r
+\r
+  res = {\r
+    error: function (response) {\r
+      if (obj)\r
+        return cb.error(transform(response));\r
+    },\r
+    // Catch the Shred error raised when the request errors as it is made (i.e. No Response is coming)\r
+    request_error: function (err) {\r
+      if (obj)\r
+        return cb.error(transformError(err));\r
+    },\r
+    response: function (response) {\r
+      if (obj) {\r
+        return cb.response(transform(response));\r
+      }\r
+    }\r
+  };\r
+  if (obj) {\r
+    obj.on = res;\r
+  }\r
+  return this.shred.request(obj);\r
+};\r
+\r
+\r
+var e = (typeof window !== 'undefined' ? window : exports);\r
+\r
+e.authorizations = authorizations = new SwaggerAuthorizations();\r
+e.ApiKeyAuthorization = ApiKeyAuthorization;\r
+e.PasswordAuthorization = PasswordAuthorization;\r
+e.CookieAuthorization = CookieAuthorization;\r
+e.SwaggerClient = SwaggerClient;\r
+e.SwaggerApi = SwaggerClient;\r
+e.Operation = Operation;\r
+e.Model = Model;\r
+e.addModel = addModel;\r
+e.Resolver = Resolver;\r
+})();
\ No newline at end of file