You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by re...@apache.org on 2014/10/29 13:39:03 UTC

[03/10] CXF-6046: Enhance SwaggerFeature to support JAX-RS annotations. Added initial demo skeleton.

http://git-wip-us.apache.org/repos/asf/cxf/blob/5e06ba0c/distribution/src/main/release/samples/jax_rs/description_swagger/src/main/resources/swagger/lib/swagger.js
----------------------------------------------------------------------
diff --git a/distribution/src/main/release/samples/jax_rs/description_swagger/src/main/resources/swagger/lib/swagger.js b/distribution/src/main/release/samples/jax_rs/description_swagger/src/main/resources/swagger/lib/swagger.js
new file mode 100644
index 0000000..20b5ed2
--- /dev/null
+++ b/distribution/src/main/release/samples/jax_rs/description_swagger/src/main/resources/swagger/lib/swagger.js
@@ -0,0 +1,1678 @@
+// swagger.js
+// version 2.0.41
+
+(function () {
+
+  var __bind = function (fn, me) {
+    return function () {
+      return fn.apply(me, arguments);
+    };
+  };
+
+  var log = function () {
+    log.history = log.history || [];
+    log.history.push(arguments);
+    if (this.console) {
+      console.log(Array.prototype.slice.call(arguments)[0]);
+    }
+  };
+
+  // if you want to apply conditional formatting of parameter values
+  var parameterMacro = function (value) {
+    return value;
+  }
+
+  // if you want to apply conditional formatting of model property values
+  var modelPropertyMacro = function (value) {
+    return value;
+  }
+
+  if (!Array.prototype.indexOf) {
+    Array.prototype.indexOf = function (obj, start) {
+      for (var i = (start || 0), j = this.length; i < j; i++) {
+        if (this[i] === obj) { return i; }
+      }
+      return -1;
+    }
+  }
+
+  if (!('filter' in Array.prototype)) {
+    Array.prototype.filter = function (filter, that /*opt*/) {
+      var other = [], v;
+      for (var i = 0, n = this.length; i < n; i++)
+        if (i in this && filter.call(that, v = this[i], i, this))
+          other.push(v);
+      return other;
+    };
+  }
+
+  if (!('map' in Array.prototype)) {
+    Array.prototype.map = function (mapper, that /*opt*/) {
+      var other = new Array(this.length);
+      for (var i = 0, n = this.length; i < n; i++)
+        if (i in this)
+          other[i] = mapper.call(that, this[i], i, this);
+      return other;
+    };
+  }
+
+  Object.keys = Object.keys || (function () {
+    var hasOwnProperty = Object.prototype.hasOwnProperty,
+      hasDontEnumBug = !{ toString: null }.propertyIsEnumerable("toString"),
+      DontEnums = [
+      'toString',
+      'toLocaleString',
+      'valueOf',
+      'hasOwnProperty',
+      'isPrototypeOf',
+      'propertyIsEnumerable',
+      'constructor'
+      ],
+    DontEnumsLength = DontEnums.length;
+
+    return function (o) {
+      if (typeof o != "object" && typeof o != "function" || o === null)
+        throw new TypeError("Object.keys called on a non-object");
+
+      var result = [];
+      for (var name in o) {
+        if (hasOwnProperty.call(o, name))
+          result.push(name);
+      }
+
+      if (hasDontEnumBug) {
+        for (var i = 0; i < DontEnumsLength; i++) {
+          if (hasOwnProperty.call(o, DontEnums[i]))
+            result.push(DontEnums[i]);
+        }
+      }
+
+      return result;
+    };
+  })();
+
+  var SwaggerApi = function (url, options) {
+    this.isBuilt = false;
+    this.url = null;
+    this.debug = false;
+    this.basePath = null;
+    this.authorizations = null;
+    this.authorizationScheme = null;
+    this.info = null;
+    this.useJQuery = false;
+    this.modelsArray = [];
+    this.isValid;
+
+    options = (options || {});
+    if (url)
+      if (url.url)
+        options = url;
+      else
+        this.url = url;
+    else
+      options = url;
+
+    if (options.url != null)
+      this.url = options.url;
+
+    if (options.success != null)
+      this.success = options.success;
+
+    if (typeof options.useJQuery === 'boolean')
+      this.useJQuery = options.useJQuery;
+
+    this.failure = options.failure != null ? options.failure : function () { };
+    this.progress = options.progress != null ? options.progress : function () { };
+    if (options.success != null) {
+      this.build();
+      this.isBuilt = true;
+    }
+  }
+
+  SwaggerApi.prototype.build = function () {
+    if (this.isBuilt)
+      return this;
+    var _this = this;
+    this.progress('fetching resource list: ' + this.url);
+    var obj = {
+      useJQuery: this.useJQuery,
+      url: this.url,
+      method: "get",
+      headers: {
+        accept: "application/json,application/json;charset=\"utf-8\",*/*"
+      },
+      on: {
+        error: function (response) {
+          if (_this.url.substring(0, 4) !== 'http') {
+            return _this.fail('Please specify the protocol for ' + _this.url);
+          } else if (response.status === 0) {
+            return _this.fail('Can\'t read from server.  It may not have the appropriate access-control-origin settings.');
+          } else if (response.status === 404) {
+            return _this.fail('Can\'t read swagger JSON from ' + _this.url);
+          } else {
+            return _this.fail(response.status + ' : ' + response.statusText + ' ' + _this.url);
+          }
+        },
+        response: function (resp) {
+          var responseObj = resp.obj || JSON.parse(resp.data);
+          _this.swaggerVersion = responseObj.swaggerVersion;
+          if (_this.swaggerVersion === "1.2") {
+            return _this.buildFromSpec(responseObj);
+          } else {
+            return _this.buildFrom1_1Spec(responseObj);
+          }
+        }
+      }
+    };
+    var e = (typeof window !== 'undefined' ? window : exports);
+    e.authorizations.apply(obj);
+    new SwaggerHttp().execute(obj);
+    return this;
+  };
+
+  SwaggerApi.prototype.buildFromSpec = function (response) {
+    if (response.apiVersion != null) {
+      this.apiVersion = response.apiVersion;
+    }
+    this.apis = {};
+    this.apisArray = [];
+    this.consumes = response.consumes;
+    this.produces = response.produces;
+    this.authSchemes = response.authorizations;
+    if (response.info != null) {
+      this.info = response.info;
+    }
+    var isApi = false;
+    var i;
+    for (i = 0; i < response.apis.length; i++) {
+      var api = response.apis[i];
+      if (api.operations) {
+        var j;
+        for (j = 0; j < api.operations.length; j++) {
+          operation = api.operations[j];
+          isApi = true;
+        }
+      }
+    }
+    if (response.basePath)
+      this.basePath = response.basePath;
+    else if (this.url.indexOf('?') > 0)
+      this.basePath = this.url.substring(0, this.url.lastIndexOf('?'));
+    else
+      this.basePath = this.url;
+
+    if (isApi) {
+      var newName = response.resourcePath.replace(/\//g, '');
+      this.resourcePath = response.resourcePath;
+      var res = new SwaggerResource(response, this);
+      this.apis[newName] = res;
+      this.apisArray.push(res);
+    } else {
+      var k;
+      for (k = 0; k < response.apis.length; k++) {
+        var resource = response.apis[k];
+        var res = new SwaggerResource(resource, this);
+        this.apis[res.name] = res;
+        this.apisArray.push(res);
+      }
+    }
+    this.isValid = true;
+    if (this.success) {
+      this.success();
+    }
+    return this;
+  };
+
+  SwaggerApi.prototype.buildFrom1_1Spec = function (response) {
+    log("This API is using a deprecated version of Swagger!  Please see http://github.com/wordnik/swagger-core/wiki for more info");
+    if (response.apiVersion != null)
+      this.apiVersion = response.apiVersion;
+    this.apis = {};
+    this.apisArray = [];
+    this.produces = response.produces;
+    if (response.info != null) {
+      this.info = response.info;
+    }
+    var isApi = false;
+    for (var i = 0; i < response.apis.length; i++) {
+      var api = response.apis[i];
+      if (api.operations) {
+        for (var j = 0; j < api.operations.length; j++) {
+          operation = api.operations[j];
+          isApi = true;
+        }
+      }
+    }
+    if (response.basePath) {
+      this.basePath = response.basePath;
+    } else if (this.url.indexOf('?') > 0) {
+      this.basePath = this.url.substring(0, this.url.lastIndexOf('?'));
+    } else {
+      this.basePath = this.url;
+    }
+    if (isApi) {
+      var newName = response.resourcePath.replace(/\//g, '');
+      this.resourcePath = response.resourcePath;
+      var res = new SwaggerResource(response, this);
+      this.apis[newName] = res;
+      this.apisArray.push(res);
+    } else {
+      for (k = 0; k < response.apis.length; k++) {
+        resource = response.apis[k];
+        var res = new SwaggerResource(resource, this);
+        this.apis[res.name] = res;
+        this.apisArray.push(res);
+      }
+    }
+    this.isValid = true;
+    if (this.success) {
+      this.success();
+    }
+    return this;
+  };
+
+  SwaggerApi.prototype.selfReflect = function () {
+    var resource, resource_name, _ref;
+    if (this.apis == null) {
+      return false;
+    }
+    _ref = this.apis;
+    for (resource_name in _ref) {
+      resource = _ref[resource_name];
+      if (resource.ready == null) {
+        return false;
+      }
+    }
+    this.setConsolidatedModels();
+    this.ready = true;
+    if (this.success != null) {
+      return this.success();
+    }
+  };
+
+  SwaggerApi.prototype.fail = function (message) {
+    this.failure(message);
+    throw message;
+  };
+
+  SwaggerApi.prototype.setConsolidatedModels = function () {
+    var model, modelName, resource, resource_name, _i, _len, _ref, _ref1, _results;
+    this.models = {};
+    _ref = this.apis;
+    for (resource_name in _ref) {
+      resource = _ref[resource_name];
+      for (modelName in resource.models) {
+        if (this.models[modelName] == null) {
+          this.models[modelName] = resource.models[modelName];
+          this.modelsArray.push(resource.models[modelName]);
+        }
+      }
+    }
+    _ref1 = this.modelsArray;
+    _results = [];
+    for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
+      model = _ref1[_i];
+      _results.push(model.setReferencedModels(this.models));
+    }
+    return _results;
+  };
+
+  SwaggerApi.prototype.help = function () {
+    var operation, operation_name, parameter, resource, resource_name, _i, _len, _ref, _ref1, _ref2;
+    _ref = this.apis;
+    for (resource_name in _ref) {
+      resource = _ref[resource_name];
+      log(resource_name);
+      _ref1 = resource.operations;
+      for (operation_name in _ref1) {
+        operation = _ref1[operation_name];
+        log("  " + operation.nickname);
+        _ref2 = operation.parameters;
+        for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
+          parameter = _ref2[_i];
+          log("  " + parameter.name + (parameter.required ? ' (required)' : '') + " - " + parameter.description);
+        }
+      }
+    }
+    return this;
+  };
+
+  var SwaggerResource = function (resourceObj, api) {
+    var _this = this;
+    this.api = api;
+    this.api = this.api;
+    var consumes = (this.consumes | []);
+    var produces = (this.produces | []);
+    this.path = this.api.resourcePath != null ? this.api.resourcePath : resourceObj.path;
+    this.description = resourceObj.description;
+
+    var parts = this.path.split("/");
+    this.name = parts[parts.length - 1].replace('.{format}', '');
+    this.basePath = this.api.basePath;
+    this.operations = {};
+    this.operationsArray = [];
+    this.modelsArray = [];
+    this.models = {};
+    this.rawModels = {};
+    this.useJQuery = (typeof api.useJQuery !== 'undefined' ? api.useJQuery : null);
+
+    if ((resourceObj.apis != null) && (this.api.resourcePath != null)) {
+      this.addApiDeclaration(resourceObj);
+    } else {
+      if (this.path == null) {
+        this.api.fail("SwaggerResources must have a path.");
+      }
+      if (this.path.substring(0, 4) === 'http') {
+        this.url = this.path.replace('{format}', 'json');
+      } else {
+        this.url = this.api.basePath + this.path.replace('{format}', 'json');
+      }
+      this.api.progress('fetching resource ' + this.name + ': ' + this.url);
+      var obj = {
+        url: this.url,
+        method: "get",
+        useJQuery: this.useJQuery,
+        headers: {
+          accept: "application/json,application/json;charset=\"utf-8\",*/*"
+        },
+        on: {
+          response: function (resp) {
+            var responseObj = resp.obj || JSON.parse(resp.data);
+            return _this.addApiDeclaration(responseObj);
+          },
+          error: function (response) {
+            return _this.api.fail("Unable to read api '" +
+              _this.name + "' from path " + _this.url + " (server returned " + response.statusText + ")");
+          }
+        }
+      };
+      var e = typeof window !== 'undefined' ? window : exports;
+      e.authorizations.apply(obj);
+      new SwaggerHttp().execute(obj);
+    }
+  }
+
+  SwaggerResource.prototype.getAbsoluteBasePath = function (relativeBasePath) {
+    var pos, url;
+    url = this.api.basePath;
+    pos = url.lastIndexOf(relativeBasePath);
+    var parts = url.split("/");
+    var rootUrl = parts[0] + "//" + parts[2];
+
+    if (relativeBasePath.indexOf("http") === 0)
+      return relativeBasePath;
+    if (relativeBasePath === "/")
+      return rootUrl;
+    if (relativeBasePath.substring(0, 1) == "/") {
+      // use root + relative
+      return rootUrl + relativeBasePath;
+    }
+    else {
+      var pos = this.basePath.lastIndexOf("/");
+      var base = this.basePath.substring(0, pos);
+      if (base.substring(base.length - 1) == "/")
+        return base + relativeBasePath;
+      else
+        return base + "/" + relativeBasePath;
+    }
+  };
+
+  SwaggerResource.prototype.addApiDeclaration = function (response) {
+    if (response.produces != null)
+      this.produces = response.produces;
+    if (response.consumes != null)
+      this.consumes = response.consumes;
+    if ((response.basePath != null) && response.basePath.replace(/\s/g, '').length > 0)
+      this.basePath = response.basePath.indexOf("http") === -1 ? this.getAbsoluteBasePath(response.basePath) : response.basePath;
+
+    this.addModels(response.models);
+    if (response.apis) {
+      for (var i = 0 ; i < response.apis.length; i++) {
+        var endpoint = response.apis[i];
+        this.addOperations(endpoint.path, endpoint.operations, response.consumes, response.produces);
+      }
+    }
+    this.api[this.name] = this;
+    this.ready = true;
+    return this.api.selfReflect();
+  };
+
+  SwaggerResource.prototype.addModels = function (models) {
+    if (models != null) {
+      var modelName;
+      for (modelName in models) {
+        if (this.models[modelName] == null) {
+          var swaggerModel = new SwaggerModel(modelName, models[modelName]);
+          this.modelsArray.push(swaggerModel);
+          this.models[modelName] = swaggerModel;
+          this.rawModels[modelName] = models[modelName];
+        }
+      }
+      var output = [];
+      for (var i = 0; i < this.modelsArray.length; i++) {
+        var model = this.modelsArray[i];
+        output.push(model.setReferencedModels(this.models));
+      }
+      return output;
+    }
+  };
+
+  SwaggerResource.prototype.addOperations = function (resource_path, ops, consumes, produces) {
+    if (ops) {
+      var output = [];
+      for (var i = 0; i < ops.length; i++) {
+        var o = ops[i];
+        consumes = this.consumes;
+        produces = this.produces;
+        if (o.consumes != null)
+          consumes = o.consumes;
+        else
+          consumes = this.consumes;
+
+        if (o.produces != null)
+          produces = o.produces;
+        else
+          produces = this.produces;
+        var type = (o.type || o.responseClass);
+
+        if (type === "array") {
+          ref = null;
+          if (o.items)
+            ref = o.items["type"] || o.items["$ref"];
+          type = "array[" + ref + "]";
+        }
+        var responseMessages = o.responseMessages;
+        var method = o.method;
+        if (o.httpMethod) {
+          method = o.httpMethod;
+        }
+        if (o.supportedContentTypes) {
+          consumes = o.supportedContentTypes;
+        }
+        if (o.errorResponses) {
+          responseMessages = o.errorResponses;
+          for (var j = 0; j < responseMessages.length; j++) {
+            r = responseMessages[j];
+            r.message = r.reason;
+            r.reason = null;
+          }
+        }
+        o.nickname = this.sanitize(o.nickname);
+        var op = new SwaggerOperation(o.nickname, resource_path, method, o.parameters, o.summary, o.notes, type, responseMessages, this, consumes, produces, o.authorizations);
+        this.operations[op.nickname] = op;
+        output.push(this.operationsArray.push(op));
+      }
+      return output;
+    }
+  };
+
+  SwaggerResource.prototype.sanitize = function (nickname) {
+    var op;
+    op = nickname.replace(/[\s!@#$%^&*()_+=\[{\]};:<>|.\/?,\\'""-]/g, '_');
+    op = op.replace(/((_){2,})/g, '_');
+    op = op.replace(/^(_)*/g, '');
+    op = op.replace(/([_])*$/g, '');
+    return op;
+  };
+
+  SwaggerResource.prototype.help = function () {
+    var op = this.operations;
+    var output = [];
+    var operation_name;
+    for (operation_name in op) {
+      operation = op[operation_name];
+      var msg = "  " + operation.nickname;
+      for (var i = 0; i < operation.parameters; i++) {
+        parameter = operation.parameters[i];
+        msg.concat("  " + parameter.name + (parameter.required ? ' (required)' : '') + " - " + parameter.description);
+      }
+      output.push(msg);
+    }
+    return output;
+  };
+
+  var SwaggerModel = function (modelName, obj) {
+    this.name = obj.id != null ? obj.id : modelName;
+    this.properties = [];
+    var propertyName;
+    for (propertyName in obj.properties) {
+      if (obj.required != null) {
+        var value;
+        for (value in obj.required) {
+          if (propertyName === obj.required[value]) {
+            obj.properties[propertyName].required = true;
+          }
+        }
+      }
+      var prop = new SwaggerModelProperty(propertyName, obj.properties[propertyName]);
+      this.properties.push(prop);
+    }
+  }
+
+  SwaggerModel.prototype.setReferencedModels = function (allModels) {
+    var results = [];
+    for (var i = 0; i < this.properties.length; i++) {
+      var property = this.properties[i];
+      var type = property.type || property.dataType;
+      if (allModels[type] != null)
+        results.push(property.refModel = allModels[type]);
+      else if ((property.refDataType != null) && (allModels[property.refDataType] != null))
+        results.push(property.refModel = allModels[property.refDataType]);
+      else
+        results.push(void 0);
+    }
+    return results;
+  };
+
+  SwaggerModel.prototype.getMockSignature = function (modelsToIgnore) {
+    var propertiesStr = [];
+    for (var i = 0; i < this.properties.length; i++) {
+      var prop = this.properties[i];
+      propertiesStr.push(prop.toString());
+    }
+
+    var strong = '<span class="strong">';
+    var stronger = '<span class="stronger">';
+    var strongClose = '</span>';
+    var classOpen = strong + this.name + ' {' + strongClose;
+    var classClose = strong + '}' + strongClose;
+    var returnVal = classOpen + '<div>' + propertiesStr.join(',</div><div>') + '</div>' + classClose;
+    if (!modelsToIgnore)
+      modelsToIgnore = [];
+    modelsToIgnore.push(this.name);
+
+    for (var i = 0; i < this.properties.length; i++) {
+      var prop = this.properties[i];
+      if ((prop.refModel != null) && modelsToIgnore.indexOf(prop.refModel.name) === -1) {
+        returnVal = returnVal + ('<br>' + prop.refModel.getMockSignature(modelsToIgnore));
+      }
+    }
+    return returnVal;
+  };
+
+  SwaggerModel.prototype.createJSONSample = function (modelsToIgnore) {
+    if (sampleModels[this.name]) {
+      return sampleModels[this.name];
+    }
+    else {
+      var result = {};
+      var modelsToIgnore = (modelsToIgnore || [])
+      modelsToIgnore.push(this.name);
+      for (var i = 0; i < this.properties.length; i++) {
+        var prop = this.properties[i];
+        result[prop.name] = prop.getSampleValue(modelsToIgnore);
+      }
+      modelsToIgnore.pop(this.name);
+      return result;
+    }
+  };
+
+  var SwaggerModelProperty = function (name, obj) {
+    this.name = name;
+    this.dataType = obj.type || obj.dataType || obj["$ref"];
+    this.isCollection = this.dataType && (this.dataType.toLowerCase() === 'array' || this.dataType.toLowerCase() === 'list' || this.dataType.toLowerCase() === 'set');
+    this.descr = obj.description;
+    this.required = obj.required;
+    this.defaultValue = modelPropertyMacro(obj.defaultValue);
+    if (obj.items != null) {
+      if (obj.items.type != null) {
+        this.refDataType = obj.items.type;
+      }
+      if (obj.items.$ref != null) {
+        this.refDataType = obj.items.$ref;
+      }
+    }
+    this.dataTypeWithRef = this.refDataType != null ? (this.dataType + '[' + this.refDataType + ']') : this.dataType;
+    if (obj.allowableValues != null) {
+      this.valueType = obj.allowableValues.valueType;
+      this.values = obj.allowableValues.values;
+      if (this.values != null) {
+        this.valuesString = "'" + this.values.join("' or '") + "'";
+      }
+    }
+    if (obj["enum"] != null) {
+      this.valueType = "string";
+      this.values = obj["enum"];
+      if (this.values != null) {
+        this.valueString = "'" + this.values.join("' or '") + "'";
+      }
+    }
+  }
+
+  SwaggerModelProperty.prototype.getSampleValue = function (modelsToIgnore) {
+    var result;
+    if ((this.refModel != null) && (modelsToIgnore.indexOf(this.refModel.name) === -1)) {
+      result = this.refModel.createJSONSample(modelsToIgnore);
+    } else {
+      if (this.isCollection) {
+        result = this.toSampleValue(this.refDataType);
+      } else {
+        result = this.toSampleValue(this.dataType);
+      }
+    }
+    if (this.isCollection) {
+      return [result];
+    } else {
+      return result;
+    }
+  };
+
+  SwaggerModelProperty.prototype.toSampleValue = function (value) {
+    var result;
+    if ((typeof this.defaultValue !== 'undefined') && this.defaultValue !== null) {
+      result = this.defaultValue;
+    } else if (value === "integer") {
+      result = 0;
+    } else if (value === "boolean") {
+      result = false;
+    } else if (value === "double" || value === "number") {
+      result = 0.0;
+    } else if (value === "string") {
+      result = "";
+    } else {
+      result = value;
+    }
+    return result;
+  };
+
+  SwaggerModelProperty.prototype.toString = function () {
+    var req = this.required ? 'propReq' : 'propOpt';
+    var str = '<span class="propName ' + req + '">' + this.name + '</span> (<span class="propType">' + this.dataTypeWithRef + '</span>';
+    if (!this.required) {
+      str += ', <span class="propOptKey">optional</span>';
+    }
+    str += ')';
+    if (this.values != null) {
+      str += " = <span class='propVals'>['" + this.values.join("' or '") + "']</span>";
+    }
+    if (this.descr != null) {
+      str += ': <span class="propDesc">' + this.descr + '</span>';
+    }
+    return str;
+  };
+
+  var SwaggerOperation = function (nickname, path, method, parameters, summary, notes, type, responseMessages, resource, consumes, produces, authorizations) {
+    var _this = this;
+
+    var errors = [];
+    this.nickname = (nickname || errors.push("SwaggerOperations must have a nickname."));
+    this.path = (path || errors.push("SwaggerOperation " + nickname + " is missing path."));
+    this.method = (method || errors.push("SwaggerOperation " + nickname + " is missing method."));
+    this.parameters = parameters != null ? parameters : [];
+    this.summary = summary;
+    this.notes = notes;
+    this.type = type;
+    this.responseMessages = (responseMessages || []);
+    this.resource = (resource || errors.push("Resource is required"));
+    this.consumes = consumes;
+    this.produces = produces;
+    this.authorizations = authorizations;
+    this["do"] = __bind(this["do"], this);
+
+    if (errors.length > 0) {
+      console.error('SwaggerOperation errors', errors, arguments);
+      this.resource.api.fail(errors);
+    }
+
+    this.path = this.path.replace('{format}', 'json');
+    this.method = this.method.toLowerCase();
+    this.isGetMethod = this.method === "get";
+
+    this.resourceName = this.resource.name;
+    if (typeof this.type !== 'undefined' && this.type === 'void')
+      this.type = null;
+    else {
+      this.responseClassSignature = this.getSignature(this.type, this.resource.models);
+      this.responseSampleJSON = this.getSampleJSON(this.type, this.resource.models);
+    }
+
+    for (var i = 0; i < this.parameters.length; i++) {
+      var param = this.parameters[i];
+      // might take this away
+      param.name = param.name || param.type || param.dataType;
+
+      // for 1.1 compatibility
+      var type = param.type || param.dataType;
+      if (type === 'array') {
+        type = 'array[' + (param.items.$ref ? param.items.$ref : param.items.type) + ']';
+      }
+      param.type = type;
+
+      if (type.toLowerCase() === 'boolean') {
+        param.allowableValues = {};
+        param.allowableValues.values = ["true", "false"];
+      }
+      param.signature = this.getSignature(type, this.resource.models);
+      param.sampleJSON = this.getSampleJSON(type, this.resource.models);
+
+      var enumValue = param["enum"];
+      if (enumValue != null) {
+        param.isList = true;
+        param.allowableValues = {};
+        param.allowableValues.descriptiveValues = [];
+
+        for (var j = 0; j < enumValue.length; j++) {
+          var v = enumValue[j];
+          if (param.defaultValue != null) {
+            param.allowableValues.descriptiveValues.push({
+              value: String(v),
+              isDefault: (v === param.defaultValue)
+            });
+          }
+          else {
+            param.allowableValues.descriptiveValues.push({
+              value: String(v),
+              isDefault: false
+            });
+          }
+        }
+      }
+      else if (param.allowableValues != null) {
+        if (param.allowableValues.valueType === "RANGE")
+          param.isRange = true;
+        else
+          param.isList = true;
+        if (param.allowableValues != null) {
+          param.allowableValues.descriptiveValues = [];
+          if (param.allowableValues.values) {
+            for (var j = 0; j < param.allowableValues.values.length; j++) {
+              var v = param.allowableValues.values[j];
+              if (param.defaultValue != null) {
+                param.allowableValues.descriptiveValues.push({
+                  value: String(v),
+                  isDefault: (v === param.defaultValue)
+                });
+              }
+              else {
+                param.allowableValues.descriptiveValues.push({
+                  value: String(v),
+                  isDefault: false
+                });
+              }
+            }
+          }
+        }
+      }
+      param.defaultValue = parameterMacro(param.defaultValue);
+    }
+    this.resource[this.nickname] = function (args, callback, error) {
+      return _this["do"](args, callback, error);
+    };
+    this.resource[this.nickname].help = function () {
+      return _this.help();
+    };
+  }
+
+  SwaggerOperation.prototype.isListType = function (type) {
+    if (type && type.indexOf('[') >= 0) {
+      return type.substring(type.indexOf('[') + 1, type.indexOf(']'));
+    } else {
+      return void 0;
+    }
+  };
+
+  SwaggerOperation.prototype.getSignature = function (type, models) {
+    var isPrimitive, listType;
+    listType = this.isListType(type);
+    isPrimitive = ((listType != null) && models[listType]) || (models[type] != null) ? false : true;
+    if (isPrimitive) {
+      return type;
+    } else {
+      if (listType != null) {
+        return models[listType].getMockSignature();
+      } else {
+        return models[type].getMockSignature();
+      }
+    }
+  };
+
+  SwaggerOperation.prototype.getSampleJSON = function (type, models) {
+    var isPrimitive, listType, val;
+    listType = this.isListType(type);
+    isPrimitive = ((listType != null) && models[listType]) || (models[type] != null) ? false : true;
+    val = isPrimitive ? void 0 : (listType != null ? models[listType].createJSONSample() : models[type].createJSONSample());
+    if (val) {
+      val = listType ? [val] : val;
+      if (typeof val == "string")
+        return val;
+      else if (typeof val === "object") {
+        var t = val;
+        if (val instanceof Array && val.length > 0) {
+          t = val[0];
+        }
+        if (t.nodeName) {
+          var xmlString = new XMLSerializer().serializeToString(t);
+          return this.formatXml(xmlString);
+        }
+        else
+          return JSON.stringify(val, null, 2);
+      }
+      else
+        return val;
+    }
+  };
+
+  SwaggerOperation.prototype["do"] = function (args, opts, callback, error) {
+    var key, param, params, possibleParams, req, requestContentType, responseContentType, value, _i, _len, _ref;
+    if (args == null) {
+      args = {};
+    }
+    if (opts == null) {
+      opts = {};
+    }
+    requestContentType = null;
+    responseContentType = null;
+    if ((typeof args) === "function") {
+      error = opts;
+      callback = args;
+      args = {};
+    }
+    if ((typeof opts) === "function") {
+      error = callback;
+      callback = opts;
+    }
+    if (error == null) {
+      error = function (xhr, textStatus, error) {
+        return log(xhr, textStatus, error);
+      };
+    }
+    if (callback == null) {
+      callback = function (response) {
+        var content;
+        content = null;
+        if (response != null) {
+          content = response.data;
+        } else {
+          content = "no data";
+        }
+        return log("default callback: " + content);
+      };
+    }
+    params = {};
+    params.headers = [];
+    if (args.headers != null) {
+      params.headers = args.headers;
+      delete args.headers;
+    }
+
+    var possibleParams = [];
+    for (var i = 0; i < this.parameters.length; i++) {
+      var param = this.parameters[i];
+      if (param.paramType === 'header') {
+        if (args[param.name])
+          params.headers[param.name] = args[param.name];
+      }
+      else if (param.paramType === 'form' || param.paramType.toLowerCase() === 'file')
+        possibleParams.push(param);
+    }
+
+    if (args.body != null) {
+      params.body = args.body;
+      delete args.body;
+    }
+
+    if (possibleParams) {
+      var key;
+      for (key in possibleParams) {
+        var value = possibleParams[key];
+        if (args[value.name]) {
+          params[value.name] = args[value.name];
+        }
+      }
+    }
+
+    req = new SwaggerRequest(this.method, this.urlify(args), params, opts, callback, error, this);
+    if (opts.mock != null) {
+      return req;
+    } else {
+      return true;
+    }
+  };
+
+  SwaggerOperation.prototype.pathJson = function () {
+    return this.path.replace("{format}", "json");
+  };
+
+  SwaggerOperation.prototype.pathXml = function () {
+    return this.path.replace("{format}", "xml");
+  };
+
+  SwaggerOperation.prototype.encodePathParam = function (pathParam) {
+    var encParts, part, parts, _i, _len;
+    pathParam = pathParam.toString();
+    if (pathParam.indexOf("/") === -1) {
+      return encodeURIComponent(pathParam);
+    } else {
+      parts = pathParam.split("/");
+      encParts = [];
+      for (_i = 0, _len = parts.length; _i < _len; _i++) {
+        part = parts[_i];
+        encParts.push(encodeURIComponent(part));
+      }
+      return encParts.join("/");
+    }
+  };
+
+  SwaggerOperation.prototype.urlify = function (args) {
+    var url = this.resource.basePath + this.pathJson();
+    var params = this.parameters;
+    for (var i = 0; i < params.length; i++) {
+      var param = params[i];
+      if (param.paramType === 'path') {
+        if (args[param.name]) {
+          // apply path params and remove from args
+          var reg = new RegExp('\\{\\s*?' + param.name + '.*?\\}(?=\\s*?(\\/|$))', 'gi');
+          url = url.replace(reg, this.encodePathParam(args[param.name]));
+          delete args[param.name];
+        }
+        else
+          throw "" + param.name + " is a required path param.";
+      }
+    }
+
+    var queryParams = "";
+    for (var i = 0; i < params.length; i++) {
+      var param = params[i];
+      if (param.paramType === 'query') {
+        if (args[param.name] !== undefined) {
+          var value = args[param.name];
+          if (queryParams !== '')
+            queryParams += '&';
+          if (Array.isArray(value)) {
+            var j;
+            var output = '';
+            for(j = 0; j < value.length; j++) {
+              if(j > 0)
+                output += ',';
+              output += encodeURIComponent(value[j]);
+            }
+            queryParams += encodeURIComponent(param.name) + '=' + output;
+          }
+          else {
+            queryParams += encodeURIComponent(param.name) + '=' + encodeURIComponent(args[param.name]);            
+          }
+        }
+      }
+    }
+    if ((queryParams != null) && queryParams.length > 0)
+      url += '?' + queryParams;
+    return url;
+  };
+
+  SwaggerOperation.prototype.supportHeaderParams = function () {
+    return this.resource.api.supportHeaderParams;
+  };
+
+  SwaggerOperation.prototype.supportedSubmitMethods = function () {
+    return this.resource.api.supportedSubmitMethods;
+  };
+
+  SwaggerOperation.prototype.getQueryParams = function (args) {
+    return this.getMatchingParams(['query'], args);
+  };
+
+  SwaggerOperation.prototype.getHeaderParams = function (args) {
+    return this.getMatchingParams(['header'], args);
+  };
+
+  SwaggerOperation.prototype.getMatchingParams = function (paramTypes, args) {
+    var matchingParams = {};
+    var params = this.parameters;
+    for (var i = 0; i < params.length; i++) {
+      param = params[i];
+      if (args && args[param.name])
+        matchingParams[param.name] = args[param.name];
+    }
+    var headers = this.resource.api.headers;
+    var name;
+    for (name in headers) {
+      var value = headers[name];
+      matchingParams[name] = value;
+    }
+    return matchingParams;
+  };
+
+  SwaggerOperation.prototype.help = function () {
+    var msg = "";
+    var params = this.parameters;
+    for (var i = 0; i < params.length; i++) {
+      var param = params[i];
+      if (msg !== "")
+        msg += "\n";
+      msg += "* " + param.name + (param.required ? ' (required)' : '') + " - " + param.description;
+    }
+    return msg;
+  };
+
+
+  SwaggerOperation.prototype.formatXml = function (xml) {
+    var contexp, formatted, indent, lastType, lines, ln, pad, reg, transitions, wsexp, _fn, _i, _len;
+    reg = /(>)(<)(\/*)/g;
+    wsexp = /[ ]*(.*)[ ]+\n/g;
+    contexp = /(<.+>)(.+\n)/g;
+    xml = xml.replace(reg, '$1\n$2$3').replace(wsexp, '$1\n').replace(contexp, '$1\n$2');
+    pad = 0;
+    formatted = '';
+    lines = xml.split('\n');
+    indent = 0;
+    lastType = 'other';
+    transitions = {
+      'single->single': 0,
+      'single->closing': -1,
+      'single->opening': 0,
+      'single->other': 0,
+      'closing->single': 0,
+      'closing->closing': -1,
+      'closing->opening': 0,
+      'closing->other': 0,
+      'opening->single': 1,
+      'opening->closing': 0,
+      'opening->opening': 1,
+      'opening->other': 1,
+      'other->single': 0,
+      'other->closing': -1,
+      'other->opening': 0,
+      'other->other': 0
+    };
+    _fn = function (ln) {
+      var fromTo, j, key, padding, type, types, value;
+      types = {
+        single: Boolean(ln.match(/<.+\/>/)),
+        closing: Boolean(ln.match(/<\/.+>/)),
+        opening: Boolean(ln.match(/<[^!?].*>/))
+      };
+      type = ((function () {
+        var _results;
+        _results = [];
+        for (key in types) {
+          value = types[key];
+          if (value) {
+            _results.push(key);
+          }
+        }
+        return _results;
+      })())[0];
+      type = type === void 0 ? 'other' : type;
+      fromTo = lastType + '->' + type;
+      lastType = type;
+      padding = '';
+      indent += transitions[fromTo];
+      padding = ((function () {
+        var _j, _ref5, _results;
+        _results = [];
+        for (j = _j = 0, _ref5 = indent; 0 <= _ref5 ? _j < _ref5 : _j > _ref5; j = 0 <= _ref5 ? ++_j : --_j) {
+          _results.push('  ');
+        }
+        return _results;
+      })()).join('');
+      if (fromTo === 'opening->closing') {
+        return formatted = formatted.substr(0, formatted.length - 1) + ln + '\n';
+      } else {
+        return formatted += padding + ln + '\n';
+      }
+    };
+    for (_i = 0, _len = lines.length; _i < _len; _i++) {
+      ln = lines[_i];
+      _fn(ln);
+    }
+    return formatted;
+  };
+
+  var SwaggerRequest = function (type, url, params, opts, successCallback, errorCallback, operation, execution) {
+    var _this = this;
+    var errors = [];
+    this.useJQuery = (typeof operation.resource.useJQuery !== 'undefined' ? operation.resource.useJQuery : null);
+    this.type = (type || errors.push("SwaggerRequest type is required (get/post/put/delete/patch/options)."));
+    this.url = (url || errors.push("SwaggerRequest url is required."));
+    this.params = params;
+    this.opts = opts;
+    this.successCallback = (successCallback || errors.push("SwaggerRequest successCallback is required."));
+    this.errorCallback = (errorCallback || errors.push("SwaggerRequest error callback is required."));
+    this.operation = (operation || errors.push("SwaggerRequest operation is required."));
+    this.execution = execution;
+    this.headers = (params.headers || {});
+
+    if (errors.length > 0) {
+      throw errors;
+    }
+
+    this.type = this.type.toUpperCase();
+
+    // set request, response content type headers
+    var headers = this.setHeaders(params, this.operation);
+    var body = params.body;
+
+    // encode the body for form submits
+    if (headers["Content-Type"]) {
+      var values = {};
+      var i;
+      var operationParams = this.operation.parameters;
+      for (i = 0; i < operationParams.length; i++) {
+        var param = operationParams[i];
+        if (param.paramType === "form")
+          values[param.name] = param;
+      }
+
+      if (headers["Content-Type"].indexOf("application/x-www-form-urlencoded") === 0) {
+        var encoded = "";
+        var key, value;
+        for (key in values) {
+          value = this.params[key];
+          if (typeof value !== 'undefined') {
+            if (encoded !== "")
+              encoded += "&";
+            encoded += encodeURIComponent(key) + '=' + encodeURIComponent(value);
+          }
+        }
+        body = encoded;
+      }
+      else if (headers["Content-Type"].indexOf("multipart/form-data") === 0) {
+        // encode the body for form submits
+        var data = "";
+        var boundary = "----SwaggerFormBoundary" + Date.now();
+        var key, value;
+        for (key in values) {
+          value = this.params[key];
+          if (typeof value !== 'undefined') {
+            data += '--' + boundary + '\n';
+            data += 'Content-Disposition: form-data; name="' + key + '"';
+            data += '\n\n';
+            data += value + "\n";
+          }
+        }
+        data += "--" + boundary + "--\n";
+        headers["Content-Type"] = "multipart/form-data; boundary=" + boundary;
+        body = data;
+      }
+    }
+
+    var obj;
+    if (!((this.headers != null) && (this.headers.mock != null))) {
+      obj = {
+        url: this.url,
+        method: this.type,
+        headers: headers,
+        body: body,
+        useJQuery: this.useJQuery,
+        on: {
+          error: function (response) {
+            return _this.errorCallback(response, _this.opts.parent);
+          },
+          redirect: function (response) {
+            return _this.successCallback(response, _this.opts.parent);
+          },
+          307: function (response) {
+            return _this.successCallback(response, _this.opts.parent);
+          },
+          response: function (response) {
+            return _this.successCallback(response, _this.opts.parent);
+          }
+        }
+      };
+      var e;
+      if (typeof window !== 'undefined') {
+        e = window;
+      } else {
+        e = exports;
+      }
+      var status = e.authorizations.apply(obj, this.operation.authorizations);
+      if (opts.mock == null) {
+        if (status !== false) {
+          new SwaggerHttp().execute(obj);
+        } else {
+          obj.canceled = true;
+        }
+      } else {
+        return obj;
+      }
+    }
+    return obj;
+  };
+
+  SwaggerRequest.prototype.setHeaders = function (params, operation) {
+    // default type
+    var accepts = "application/json";
+    var consumes = "application/json";
+
+    var allDefinedParams = this.operation.parameters;
+    var definedFormParams = [];
+    var definedFileParams = [];
+    var body = params.body;
+    var headers = {};
+
+    // get params from the operation and set them in definedFileParams, definedFormParams, headers
+    var i;
+    for (i = 0; i < allDefinedParams.length; i++) {
+      var param = allDefinedParams[i];
+      if (param.paramType === "form")
+        definedFormParams.push(param);
+      else if (param.paramType === "file")
+        definedFileParams.push(param);
+      else if (param.paramType === "header" && this.params.headers) {
+        var key = param.name;
+        var headerValue = this.params.headers[param.name];
+        if (typeof this.params.headers[param.name] !== 'undefined')
+          headers[key] = headerValue;
+      }
+    }
+
+    // if there's a body, need to set the accepts header via requestContentType
+    if (body && (this.type === "POST" || this.type === "PUT" || this.type === "PATCH" || this.type === "DELETE")) {
+      if (this.opts.requestContentType)
+        consumes = this.opts.requestContentType;
+    } else {
+      // if any form params, content type must be set
+      if (definedFormParams.length > 0) {
+        if (definedFileParams.length > 0)
+          consumes = "multipart/form-data";
+        else
+          consumes = "application/x-www-form-urlencoded";
+      }
+      else if (this.type === "DELETE")
+        body = "{}";
+      else if (this.type != "DELETE")
+        accepts = null;
+    }
+
+    if (consumes && this.operation.consumes) {
+      if (this.operation.consumes.indexOf(consumes) === -1) {
+        log("server doesn't consume " + consumes + ", try " + JSON.stringify(this.operation.consumes));
+        consumes = this.operation.consumes[0];
+      }
+    }
+
+    if (this.opts.responseContentType) {
+      accepts = this.opts.responseContentType;
+    } else {
+      accepts = "application/json";
+    }
+    if (accepts && this.operation.produces) {
+      if (this.operation.produces.indexOf(accepts) === -1) {
+        log("server can't produce " + accepts);
+        accepts = this.operation.produces[0];
+      }
+    }
+
+    if ((consumes && body !== "") || (consumes === "application/x-www-form-urlencoded"))
+      headers["Content-Type"] = consumes;
+    if (accepts)
+      headers["Accept"] = accepts;
+    return headers;
+  }
+
+  SwaggerRequest.prototype.asCurl = function () {
+    var results = [];
+    if (this.headers) {
+      var key;
+      for (key in this.headers) {
+        results.push("--header \"" + key + ": " + this.headers[v] + "\"");
+      }
+    }
+    return "curl " + (results.join(" ")) + " " + this.url;
+  };
+
+  /**
+   * SwaggerHttp is a wrapper for executing requests
+   */
+  var SwaggerHttp = function () { };
+
+  SwaggerHttp.prototype.execute = function (obj) {
+    if (obj && (typeof obj.useJQuery === 'boolean'))
+      this.useJQuery = obj.useJQuery;
+    else
+      this.useJQuery = this.isIE8();
+
+    if (this.useJQuery)
+      return new JQueryHttpClient().execute(obj);
+    else
+      return new ShredHttpClient().execute(obj);
+  }
+
+  SwaggerHttp.prototype.isIE8 = function () {
+    var detectedIE = false;
+    if (typeof navigator !== 'undefined' && navigator.userAgent) {
+      nav = navigator.userAgent.toLowerCase();
+      if (nav.indexOf('msie') !== -1) {
+        var version = parseInt(nav.split('msie')[1]);
+        if (version <= 8) {
+          detectedIE = true;
+        }
+      }
+    }
+    return detectedIE;
+  };
+
+  /*
+   * JQueryHttpClient lets a browser take advantage of JQuery's cross-browser magic.
+   * NOTE: when jQuery is available it will export both '$' and 'jQuery' to the global space.
+   *     Since we are using closures here we need to alias it for internal use.
+   */
+  var JQueryHttpClient = function (options) {
+    "use strict";
+    if (!jQuery) {
+      var jQuery = window.jQuery;
+    }
+  }
+
+  JQueryHttpClient.prototype.execute = function (obj) {
+    var cb = obj.on;
+    var request = obj;
+
+    obj.type = obj.method;
+    obj.cache = false;
+
+    obj.beforeSend = function (xhr) {
+      var key, results;
+      if (obj.headers) {
+        results = [];
+        var key;
+        for (key in obj.headers) {
+          if (key.toLowerCase() === "content-type") {
+            results.push(obj.contentType = obj.headers[key]);
+          } else if (key.toLowerCase() === "accept") {
+            results.push(obj.accepts = obj.headers[key]);
+          } else {
+            results.push(xhr.setRequestHeader(key, obj.headers[key]));
+          }
+        }
+        return results;
+      }
+    };
+
+    obj.data = obj.body;
+    obj.complete = function (response, textStatus, opts) {
+      var headers = {},
+        headerArray = response.getAllResponseHeaders().split("\n");
+
+      for (var i = 0; i < headerArray.length; i++) {
+        var toSplit = headerArray[i].trim();
+        if (toSplit.length === 0)
+          continue;
+        var separator = toSplit.indexOf(":");
+        if (separator === -1) {
+          // Name but no value in the header
+          headers[toSplit] = null;
+          continue;
+        }
+        var name = toSplit.substring(0, separator).trim(),
+          value = toSplit.substring(separator + 1).trim();
+        headers[name] = value;
+      }
+
+      var out = {
+        url: request.url,
+        method: request.method,
+        status: response.status,
+        data: response.responseText,
+        headers: headers
+      };
+
+      var contentType = (headers["content-type"] || headers["Content-Type"] || null)
+
+      if (contentType != null) {
+        if (contentType.indexOf("application/json") == 0 || contentType.indexOf("+json") > 0) {
+          if (response.responseText && response.responseText !== "")
+            out.obj = JSON.parse(response.responseText);
+          else
+            out.obj = {}
+        }
+      }
+
+      if (response.status >= 200 && response.status < 300)
+        cb.response(out);
+      else if (response.status === 0 || (response.status >= 400 && response.status < 599))
+        cb.error(out);
+      else
+        return cb.response(out);
+    };
+
+    jQuery.support.cors = true;
+    return jQuery.ajax(obj);
+  }
+
+  /*
+   * ShredHttpClient is a light-weight, node or browser HTTP client
+   */
+  var ShredHttpClient = function (options) {
+    this.options = (options || {});
+    this.isInitialized = false;
+
+    var identity, toString;
+
+    if (typeof window !== 'undefined') {
+      this.Shred = require("./shred");
+      this.content = require("./shred/content");
+    }
+    else
+      this.Shred = require("shred");
+    this.shred = new this.Shred();
+  }
+
+  ShredHttpClient.prototype.initShred = function () {
+    this.isInitialized = true;
+    this.registerProcessors(this.shred);
+  }
+
+  ShredHttpClient.prototype.registerProcessors = function (shred) {
+    var identity = function (x) {
+      return x;
+    };
+    var toString = function (x) {
+      return x.toString();
+    };
+
+    if (typeof window !== 'undefined') {
+      this.content.registerProcessor(["application/json; charset=utf-8", "application/json", "json"], {
+        parser: identity,
+        stringify: toString
+      });
+    } else {
+      this.Shred.registerProcessor(["application/json; charset=utf-8", "application/json", "json"], {
+        parser: identity,
+        stringify: toString
+      });
+    }
+  }
+
+  ShredHttpClient.prototype.execute = function (obj) {
+    if (!this.isInitialized)
+      this.initShred();
+
+    var cb = obj.on, res;
+
+    var transform = function (response) {
+      var out = {
+        headers: response._headers,
+        url: response.request.url,
+        method: response.request.method,
+        status: response.status,
+        data: response.content.data
+      };
+
+      var contentType = (response._headers["content-type"] || response._headers["Content-Type"] || null)
+
+      if (contentType != null) {
+        if (contentType.indexOf("application/json") == 0 || contentType.indexOf("+json") > 0) {
+          if (response.content.data && response.content.data !== "")
+            out.obj = JSON.parse(response.content.data);
+          else
+            out.obj = {}
+        }
+      }
+      return out;
+    };
+
+    // Transform an error into a usable response-like object
+    var transformError = function (error) {
+      var out = {
+        // Default to a status of 0 - The client will treat this as a generic permissions sort of error
+        status: 0,
+        data: error.message || error
+      };
+
+      if (error.code) {
+        out.obj = error;
+
+        if (error.code === 'ENOTFOUND' || error.code === 'ECONNREFUSED') {
+          // We can tell the client that this should be treated as a missing resource and not as a permissions thing
+          out.status = 404;
+        }
+      }
+
+      return out;
+    };
+
+    var res = {
+      error: function (response) {
+        if (obj)
+          return cb.error(transform(response));
+      },
+      // Catch the Shred error raised when the request errors as it is made (i.e. No Response is coming)
+      request_error: function (err) {
+        if (obj)
+          return cb.error(transformError(err));
+      },
+      redirect: function (response) {
+        if (obj)
+          return cb.redirect(transform(response));
+      },
+      307: function (response) {
+        if (obj)
+          return cb.redirect(transform(response));
+      },
+      response: function (response) {
+        if (obj)
+          return cb.response(transform(response));
+      }
+    };
+    if (obj) {
+      obj.on = res;
+    }
+    return this.shred.request(obj);
+  };
+
+  /**
+   * SwaggerAuthorizations applys the correct authorization to an operation being executed
+   */
+  var SwaggerAuthorizations = function () {
+    this.authz = {};
+  };
+
+  SwaggerAuthorizations.prototype.add = function (name, auth) {
+    this.authz[name] = auth;
+    return auth;
+  };
+
+  SwaggerAuthorizations.prototype.remove = function (name) {
+    return delete this.authz[name];
+  };
+
+  SwaggerAuthorizations.prototype.apply = function (obj, authorizations) {
+    var status = null;
+    var key, value, result;
+
+    // if the "authorizations" key is undefined, or has an empty array, add all keys
+    if (typeof authorizations === 'undefined' || Object.keys(authorizations).length == 0) {
+      for (key in this.authz) {
+        value = this.authz[key];
+        result = value.apply(obj, authorizations);
+        if (result === true)
+          status = true;
+      }
+    }
+    else {
+      for (name in authorizations) {
+        for (key in this.authz) {
+          if (key == name) {
+            value = this.authz[key];
+            result = value.apply(obj, authorizations);
+            if (result === true)
+              status = true;
+          }
+        }
+      }
+    }
+
+    return status;
+  };
+
+  /**
+   * ApiKeyAuthorization allows a query param or header to be injected
+   */
+  var ApiKeyAuthorization = function (name, value, type, delimiter) {
+    this.name = name;
+    this.value = value;
+    this.type = type;
+    this.delimiter = delimiter;
+  };
+
+  ApiKeyAuthorization.prototype.apply = function (obj, authorizations) {
+    if (this.type === "query") {
+      if (obj.url.indexOf('?') > 0)
+        obj.url = obj.url + "&" + this.name + "=" + this.value;
+      else
+        obj.url = obj.url + "?" + this.name + "=" + this.value;
+      return true;
+    } else if (this.type === "header") {
+      if (typeof obj.headers[this.name] !== 'undefined') {
+        if (typeof this.delimiter !== 'undefined')
+          obj.headers[this.name] = obj.headers[this.name] + this.delimiter + this.value;
+      }
+      else
+        obj.headers[this.name] = this.value;
+      return true;
+    }
+  };
+
+  var CookieAuthorization = function (cookie) {
+    this.cookie = cookie;
+  }
+
+  CookieAuthorization.prototype.apply = function (obj, authorizations) {
+    obj.cookieJar = obj.cookieJar || CookieJar();
+    obj.cookieJar.setCookie(this.cookie);
+    return true;
+  }
+
+  /**
+   * Password Authorization is a basic auth implementation
+   */
+  var PasswordAuthorization = function (name, username, password) {
+    this.name = name;
+    this.username = username;
+    this.password = password;
+    this._btoa = null;
+    if (typeof window !== 'undefined')
+      this._btoa = btoa;
+    else
+      this._btoa = require("btoa");
+  };
+
+  PasswordAuthorization.prototype.apply = function (obj, authorizations) {
+    var base64encoder = this._btoa;
+    obj.headers["Authorization"] = "Basic " + base64encoder(this.username + ":" + this.password);
+    return true;
+  };
+
+  var e = (typeof window !== 'undefined' ? window : exports);
+
+  var sampleModels = {};
+  var cookies = {};
+
+  e.SampleModels = sampleModels;
+  e.SwaggerHttp = SwaggerHttp;
+  e.SwaggerRequest = SwaggerRequest;
+  e.authorizations = new SwaggerAuthorizations();
+  e.ApiKeyAuthorization = ApiKeyAuthorization;
+  e.PasswordAuthorization = PasswordAuthorization;
+  e.CookieAuthorization = CookieAuthorization;
+  e.JQueryHttpClient = JQueryHttpClient;
+  e.ShredHttpClient = ShredHttpClient;
+  e.SwaggerOperation = SwaggerOperation;
+  e.SwaggerModel = SwaggerModel;
+  e.SwaggerModelProperty = SwaggerModelProperty;
+  e.SwaggerResource = SwaggerResource;
+  e.SwaggerApi = SwaggerApi;
+  e.log = log;
+
+})();

http://git-wip-us.apache.org/repos/asf/cxf/blob/5e06ba0c/distribution/src/main/release/samples/jax_rs/description_swagger/src/main/resources/swagger/lib/underscore-min.js
----------------------------------------------------------------------
diff --git a/distribution/src/main/release/samples/jax_rs/description_swagger/src/main/resources/swagger/lib/underscore-min.js b/distribution/src/main/release/samples/jax_rs/description_swagger/src/main/resources/swagger/lib/underscore-min.js
new file mode 100644
index 0000000..5a0cb3b
--- /dev/null
+++ b/distribution/src/main/release/samples/jax_rs/description_swagger/src/main/resources/swagger/lib/underscore-min.js
@@ -0,0 +1,32 @@
+// Underscore.js 1.3.3
+// (c) 2009-2012 Jeremy Ashkenas, DocumentCloud Inc.
+// Underscore is freely distributable under the MIT license.
+// Portions of Underscore are inspired or borrowed from Prototype,
+// Oliver Steele's Functional, and John Resig's Micro-Templating.
+// For all details and documentation:
+// http://documentcloud.github.com/underscore
+(function(){function r(a,c,d){if(a===c)return 0!==a||1/a==1/c;if(null==a||null==c)return a===c;a._chain&&(a=a._wrapped);c._chain&&(c=c._wrapped);if(a.isEqual&&b.isFunction(a.isEqual))return a.isEqual(c);if(c.isEqual&&b.isFunction(c.isEqual))return c.isEqual(a);var e=l.call(a);if(e!=l.call(c))return!1;switch(e){case "[object String]":return a==""+c;case "[object Number]":return a!=+a?c!=+c:0==a?1/a==1/c:a==+c;case "[object Date]":case "[object Boolean]":return+a==+c;case "[object RegExp]":return a.source==
+c.source&&a.global==c.global&&a.multiline==c.multiline&&a.ignoreCase==c.ignoreCase}if("object"!=typeof a||"object"!=typeof c)return!1;for(var f=d.length;f--;)if(d[f]==a)return!0;d.push(a);var f=0,g=!0;if("[object Array]"==e){if(f=a.length,g=f==c.length)for(;f--&&(g=f in a==f in c&&r(a[f],c[f],d)););}else{if("constructor"in a!="constructor"in c||a.constructor!=c.constructor)return!1;for(var h in a)if(b.has(a,h)&&(f++,!(g=b.has(c,h)&&r(a[h],c[h],d))))break;if(g){for(h in c)if(b.has(c,h)&&!f--)break;
+g=!f}}d.pop();return g}var s=this,I=s._,o={},k=Array.prototype,p=Object.prototype,i=k.slice,J=k.unshift,l=p.toString,K=p.hasOwnProperty,y=k.forEach,z=k.map,A=k.reduce,B=k.reduceRight,C=k.filter,D=k.every,E=k.some,q=k.indexOf,F=k.lastIndexOf,p=Array.isArray,L=Object.keys,t=Function.prototype.bind,b=function(a){return new m(a)};"undefined"!==typeof exports?("undefined"!==typeof module&&module.exports&&(exports=module.exports=b),exports._=b):s._=b;b.VERSION="1.3.3";var j=b.each=b.forEach=function(a,
+c,d){if(a!=null)if(y&&a.forEach===y)a.forEach(c,d);else if(a.length===+a.length)for(var e=0,f=a.length;e<f;e++){if(e in a&&c.call(d,a[e],e,a)===o)break}else for(e in a)if(b.has(a,e)&&c.call(d,a[e],e,a)===o)break};b.map=b.collect=function(a,c,b){var e=[];if(a==null)return e;if(z&&a.map===z)return a.map(c,b);j(a,function(a,g,h){e[e.length]=c.call(b,a,g,h)});if(a.length===+a.length)e.length=a.length;return e};b.reduce=b.foldl=b.inject=function(a,c,d,e){var f=arguments.length>2;a==null&&(a=[]);if(A&&
+a.reduce===A){e&&(c=b.bind(c,e));return f?a.reduce(c,d):a.reduce(c)}j(a,function(a,b,i){if(f)d=c.call(e,d,a,b,i);else{d=a;f=true}});if(!f)throw new TypeError("Reduce of empty array with no initial value");return d};b.reduceRight=b.foldr=function(a,c,d,e){var f=arguments.length>2;a==null&&(a=[]);if(B&&a.reduceRight===B){e&&(c=b.bind(c,e));return f?a.reduceRight(c,d):a.reduceRight(c)}var g=b.toArray(a).reverse();e&&!f&&(c=b.bind(c,e));return f?b.reduce(g,c,d,e):b.reduce(g,c)};b.find=b.detect=function(a,
+c,b){var e;G(a,function(a,g,h){if(c.call(b,a,g,h)){e=a;return true}});return e};b.filter=b.select=function(a,c,b){var e=[];if(a==null)return e;if(C&&a.filter===C)return a.filter(c,b);j(a,function(a,g,h){c.call(b,a,g,h)&&(e[e.length]=a)});return e};b.reject=function(a,c,b){var e=[];if(a==null)return e;j(a,function(a,g,h){c.call(b,a,g,h)||(e[e.length]=a)});return e};b.every=b.all=function(a,c,b){var e=true;if(a==null)return e;if(D&&a.every===D)return a.every(c,b);j(a,function(a,g,h){if(!(e=e&&c.call(b,
+a,g,h)))return o});return!!e};var G=b.some=b.any=function(a,c,d){c||(c=b.identity);var e=false;if(a==null)return e;if(E&&a.some===E)return a.some(c,d);j(a,function(a,b,h){if(e||(e=c.call(d,a,b,h)))return o});return!!e};b.include=b.contains=function(a,c){var b=false;if(a==null)return b;if(q&&a.indexOf===q)return a.indexOf(c)!=-1;return b=G(a,function(a){return a===c})};b.invoke=function(a,c){var d=i.call(arguments,2);return b.map(a,function(a){return(b.isFunction(c)?c||a:a[c]).apply(a,d)})};b.pluck=
+function(a,c){return b.map(a,function(a){return a[c]})};b.max=function(a,c,d){if(!c&&b.isArray(a)&&a[0]===+a[0])return Math.max.apply(Math,a);if(!c&&b.isEmpty(a))return-Infinity;var e={computed:-Infinity};j(a,function(a,b,h){b=c?c.call(d,a,b,h):a;b>=e.computed&&(e={value:a,computed:b})});return e.value};b.min=function(a,c,d){if(!c&&b.isArray(a)&&a[0]===+a[0])return Math.min.apply(Math,a);if(!c&&b.isEmpty(a))return Infinity;var e={computed:Infinity};j(a,function(a,b,h){b=c?c.call(d,a,b,h):a;b<e.computed&&
+(e={value:a,computed:b})});return e.value};b.shuffle=function(a){var b=[],d;j(a,function(a,f){d=Math.floor(Math.random()*(f+1));b[f]=b[d];b[d]=a});return b};b.sortBy=function(a,c,d){var e=b.isFunction(c)?c:function(a){return a[c]};return b.pluck(b.map(a,function(a,b,c){return{value:a,criteria:e.call(d,a,b,c)}}).sort(function(a,b){var c=a.criteria,d=b.criteria;return c===void 0?1:d===void 0?-1:c<d?-1:c>d?1:0}),"value")};b.groupBy=function(a,c){var d={},e=b.isFunction(c)?c:function(a){return a[c]};
+j(a,function(a,b){var c=e(a,b);(d[c]||(d[c]=[])).push(a)});return d};b.sortedIndex=function(a,c,d){d||(d=b.identity);for(var e=0,f=a.length;e<f;){var g=e+f>>1;d(a[g])<d(c)?e=g+1:f=g}return e};b.toArray=function(a){return!a?[]:b.isArray(a)||b.isArguments(a)?i.call(a):a.toArray&&b.isFunction(a.toArray)?a.toArray():b.values(a)};b.size=function(a){return b.isArray(a)?a.length:b.keys(a).length};b.first=b.head=b.take=function(a,b,d){return b!=null&&!d?i.call(a,0,b):a[0]};b.initial=function(a,b,d){return i.call(a,
+0,a.length-(b==null||d?1:b))};b.last=function(a,b,d){return b!=null&&!d?i.call(a,Math.max(a.length-b,0)):a[a.length-1]};b.rest=b.tail=function(a,b,d){return i.call(a,b==null||d?1:b)};b.compact=function(a){return b.filter(a,function(a){return!!a})};b.flatten=function(a,c){return b.reduce(a,function(a,e){if(b.isArray(e))return a.concat(c?e:b.flatten(e));a[a.length]=e;return a},[])};b.without=function(a){return b.difference(a,i.call(arguments,1))};b.uniq=b.unique=function(a,c,d){var d=d?b.map(a,d):a,
+e=[];a.length<3&&(c=true);b.reduce(d,function(d,g,h){if(c?b.last(d)!==g||!d.length:!b.include(d,g)){d.push(g);e.push(a[h])}return d},[]);return e};b.union=function(){return b.uniq(b.flatten(arguments,true))};b.intersection=b.intersect=function(a){var c=i.call(arguments,1);return b.filter(b.uniq(a),function(a){return b.every(c,function(c){return b.indexOf(c,a)>=0})})};b.difference=function(a){var c=b.flatten(i.call(arguments,1),true);return b.filter(a,function(a){return!b.include(c,a)})};b.zip=function(){for(var a=
+i.call(arguments),c=b.max(b.pluck(a,"length")),d=Array(c),e=0;e<c;e++)d[e]=b.pluck(a,""+e);return d};b.indexOf=function(a,c,d){if(a==null)return-1;var e;if(d){d=b.sortedIndex(a,c);return a[d]===c?d:-1}if(q&&a.indexOf===q)return a.indexOf(c);d=0;for(e=a.length;d<e;d++)if(d in a&&a[d]===c)return d;return-1};b.lastIndexOf=function(a,b){if(a==null)return-1;if(F&&a.lastIndexOf===F)return a.lastIndexOf(b);for(var d=a.length;d--;)if(d in a&&a[d]===b)return d;return-1};b.range=function(a,b,d){if(arguments.length<=
+1){b=a||0;a=0}for(var d=arguments[2]||1,e=Math.max(Math.ceil((b-a)/d),0),f=0,g=Array(e);f<e;){g[f++]=a;a=a+d}return g};var H=function(){};b.bind=function(a,c){var d,e;if(a.bind===t&&t)return t.apply(a,i.call(arguments,1));if(!b.isFunction(a))throw new TypeError;e=i.call(arguments,2);return d=function(){if(!(this instanceof d))return a.apply(c,e.concat(i.call(arguments)));H.prototype=a.prototype;var b=new H,g=a.apply(b,e.concat(i.call(arguments)));return Object(g)===g?g:b}};b.bindAll=function(a){var c=
+i.call(arguments,1);c.length==0&&(c=b.functions(a));j(c,function(c){a[c]=b.bind(a[c],a)});return a};b.memoize=function(a,c){var d={};c||(c=b.identity);return function(){var e=c.apply(this,arguments);return b.has(d,e)?d[e]:d[e]=a.apply(this,arguments)}};b.delay=function(a,b){var d=i.call(arguments,2);return setTimeout(function(){return a.apply(null,d)},b)};b.defer=function(a){return b.delay.apply(b,[a,1].concat(i.call(arguments,1)))};b.throttle=function(a,c){var d,e,f,g,h,i,j=b.debounce(function(){h=
+g=false},c);return function(){d=this;e=arguments;f||(f=setTimeout(function(){f=null;h&&a.apply(d,e);j()},c));g?h=true:i=a.apply(d,e);j();g=true;return i}};b.debounce=function(a,b,d){var e;return function(){var f=this,g=arguments;d&&!e&&a.apply(f,g);clearTimeout(e);e=setTimeout(function(){e=null;d||a.apply(f,g)},b)}};b.once=function(a){var b=false,d;return function(){if(b)return d;b=true;return d=a.apply(this,arguments)}};b.wrap=function(a,b){return function(){var d=[a].concat(i.call(arguments,0));
+return b.apply(this,d)}};b.compose=function(){var a=arguments;return function(){for(var b=arguments,d=a.length-1;d>=0;d--)b=[a[d].apply(this,b)];return b[0]}};b.after=function(a,b){return a<=0?b():function(){if(--a<1)return b.apply(this,arguments)}};b.keys=L||function(a){if(a!==Object(a))throw new TypeError("Invalid object");var c=[],d;for(d in a)b.has(a,d)&&(c[c.length]=d);return c};b.values=function(a){return b.map(a,b.identity)};b.functions=b.methods=function(a){var c=[],d;for(d in a)b.isFunction(a[d])&&
+c.push(d);return c.sort()};b.extend=function(a){j(i.call(arguments,1),function(b){for(var d in b)a[d]=b[d]});return a};b.pick=function(a){var c={};j(b.flatten(i.call(arguments,1)),function(b){b in a&&(c[b]=a[b])});return c};b.defaults=function(a){j(i.call(arguments,1),function(b){for(var d in b)a[d]==null&&(a[d]=b[d])});return a};b.clone=function(a){return!b.isObject(a)?a:b.isArray(a)?a.slice():b.extend({},a)};b.tap=function(a,b){b(a);return a};b.isEqual=function(a,b){return r(a,b,[])};b.isEmpty=
+function(a){if(a==null)return true;if(b.isArray(a)||b.isString(a))return a.length===0;for(var c in a)if(b.has(a,c))return false;return true};b.isElement=function(a){return!!(a&&a.nodeType==1)};b.isArray=p||function(a){return l.call(a)=="[object Array]"};b.isObject=function(a){return a===Object(a)};b.isArguments=function(a){return l.call(a)=="[object Arguments]"};b.isArguments(arguments)||(b.isArguments=function(a){return!(!a||!b.has(a,"callee"))});b.isFunction=function(a){return l.call(a)=="[object Function]"};
+b.isString=function(a){return l.call(a)=="[object String]"};b.isNumber=function(a){return l.call(a)=="[object Number]"};b.isFinite=function(a){return b.isNumber(a)&&isFinite(a)};b.isNaN=function(a){return a!==a};b.isBoolean=function(a){return a===true||a===false||l.call(a)=="[object Boolean]"};b.isDate=function(a){return l.call(a)=="[object Date]"};b.isRegExp=function(a){return l.call(a)=="[object RegExp]"};b.isNull=function(a){return a===null};b.isUndefined=function(a){return a===void 0};b.has=function(a,
+b){return K.call(a,b)};b.noConflict=function(){s._=I;return this};b.identity=function(a){return a};b.times=function(a,b,d){for(var e=0;e<a;e++)b.call(d,e)};b.escape=function(a){return(""+a).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;").replace(/\//g,"&#x2F;")};b.result=function(a,c){if(a==null)return null;var d=a[c];return b.isFunction(d)?d.call(a):d};b.mixin=function(a){j(b.functions(a),function(c){M(c,b[c]=a[c])})};var N=0;b.uniqueId=
+function(a){var b=N++;return a?a+b:b};b.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var u=/.^/,n={"\\":"\\","'":"'",r:"\r",n:"\n",t:"\t",u2028:"\u2028",u2029:"\u2029"},v;for(v in n)n[n[v]]=v;var O=/\\|'|\r|\n|\t|\u2028|\u2029/g,P=/\\(\\|'|r|n|t|u2028|u2029)/g,w=function(a){return a.replace(P,function(a,b){return n[b]})};b.template=function(a,c,d){d=b.defaults(d||{},b.templateSettings);a="__p+='"+a.replace(O,function(a){return"\\"+n[a]}).replace(d.escape||
+u,function(a,b){return"'+\n_.escape("+w(b)+")+\n'"}).replace(d.interpolate||u,function(a,b){return"'+\n("+w(b)+")+\n'"}).replace(d.evaluate||u,function(a,b){return"';\n"+w(b)+"\n;__p+='"})+"';\n";d.variable||(a="with(obj||{}){\n"+a+"}\n");var a="var __p='';var print=function(){__p+=Array.prototype.join.call(arguments, '')};\n"+a+"return __p;\n",e=new Function(d.variable||"obj","_",a);if(c)return e(c,b);c=function(a){return e.call(this,a,b)};c.source="function("+(d.variable||"obj")+"){\n"+a+"}";return c};
+b.chain=function(a){return b(a).chain()};var m=function(a){this._wrapped=a};b.prototype=m.prototype;var x=function(a,c){return c?b(a).chain():a},M=function(a,c){m.prototype[a]=function(){var a=i.call(arguments);J.call(a,this._wrapped);return x(c.apply(b,a),this._chain)}};b.mixin(b);j("pop,push,reverse,shift,sort,splice,unshift".split(","),function(a){var b=k[a];m.prototype[a]=function(){var d=this._wrapped;b.apply(d,arguments);var e=d.length;(a=="shift"||a=="splice")&&e===0&&delete d[0];return x(d,
+this._chain)}});j(["concat","join","slice"],function(a){var b=k[a];m.prototype[a]=function(){return x(b.apply(this._wrapped,arguments),this._chain)}});m.prototype.chain=function(){this._chain=true;return this};m.prototype.value=function(){return this._wrapped}}).call(this);

http://git-wip-us.apache.org/repos/asf/cxf/blob/5e06ba0c/distribution/src/main/release/samples/jax_rs/description_swagger/src/main/resources/swagger/o2c.html
----------------------------------------------------------------------
diff --git a/distribution/src/main/release/samples/jax_rs/description_swagger/src/main/resources/swagger/o2c.html b/distribution/src/main/release/samples/jax_rs/description_swagger/src/main/resources/swagger/o2c.html
new file mode 100644
index 0000000..d32d130
--- /dev/null
+++ b/distribution/src/main/release/samples/jax_rs/description_swagger/src/main/resources/swagger/o2c.html
@@ -0,0 +1,15 @@
+<script>
+var qp = null;
+if(window.location.hash) {
+  qp = location.hash.substring(1);
+}
+else {
+  qp = location.search.substring(1);
+}
+qp = qp ? JSON.parse('{"' + qp.replace(/&/g, '","').replace(/=/g,'":"') + '"}',
+  function(key, value) {
+    return key===""?value:decodeURIComponent(value) }
+  ):{}
+window.opener.onOAuthComplete(qp);
+window.close();
+</script>
\ No newline at end of file