diff --git a/dist/index.html b/dist/index.html
index a2887e0a..5f9d8523 100644
--- a/dist/index.html
+++ b/dist/index.html
@@ -1,74 +1,80 @@
- Swagger UI
-
-
-
-
-
-
-
-
-
-
-
-
-
+ Swagger UI
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
diff --git a/dist/lib/swagger.js b/dist/lib/swagger.js
index 0ce1513e..177a109d 100644
--- a/dist/lib/swagger.js
+++ b/dist/lib/swagger.js
@@ -1,6 +1,6 @@
// Generated by CoffeeScript 1.4.0
(function() {
- var SwaggerApi, SwaggerModel, SwaggerModelProperty, SwaggerOperation, SwaggerRequest, SwaggerResource,
+ var ApiKeyAuthorization, SwaggerApi, SwaggerAuthorizations, SwaggerHttp, SwaggerModel, SwaggerModelProperty, SwaggerOperation, SwaggerRequest, SwaggerResource,
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
SwaggerApi = (function() {
@@ -9,10 +9,12 @@
SwaggerApi.prototype.debug = false;
- SwaggerApi.prototype.api_key = null;
-
SwaggerApi.prototype.basePath = null;
+ SwaggerApi.prototype.authorizations = null;
+
+ SwaggerApi.prototype.authorizationScheme = null;
+
function SwaggerApi(options) {
if (options == null) {
options = {};
@@ -20,97 +22,64 @@
if (options.discoveryUrl != null) {
this.discoveryUrl = options.discoveryUrl;
}
- if (options.debug != null) {
- this.debug = options.debug;
- }
- this.apiKeyName = options.apiKeyName != null ? options.apiKeyName : 'api_key';
- if (options.apiKey != null) {
- this.api_key = options.apiKey;
- }
- if (options.api_key != null) {
- this.api_key = options.api_key;
- }
- if (options.verbose != null) {
- this.verbose = options.verbose;
- }
- this.supportHeaderParams = options.supportHeaderParams != null ? options.supportHeaderParams : false;
this.supportedSubmitMethods = options.supportedSubmitMethods != null ? options.supportedSubmitMethods : ['get'];
if (options.success != null) {
this.success = options.success;
}
this.failure = options.failure != null ? options.failure : function() {};
this.progress = options.progress != null ? options.progress : function() {};
- this.headers = options.headers != null ? options.headers : {};
- this.booleanValues = options.booleanValues != null ? options.booleanValues : new Array('true', 'false');
- this.discoveryUrl = this.suffixApiKey(this.discoveryUrl);
+ this.defaultHeaders = options.headers != null ? options.headers : {};
if (options.success != null) {
this.build();
}
}
SwaggerApi.prototype.build = function() {
- var _this = this;
+ var obj,
+ _this = this;
this.progress('fetching resource list: ' + this.discoveryUrl);
- return jQuery.getJSON(this.discoveryUrl, function(response) {
- var res, resource, _i, _j, _len, _len1, _ref, _ref1;
- if (response.apiVersion != null) {
- _this.apiVersion = response.apiVersion;
- }
- if ((response.basePath != null) && jQuery.trim(response.basePath).length > 0) {
- _this.basePath = response.basePath;
- if (_this.basePath.match(/^HTTP/i) == null) {
- _this.fail("discoveryUrl basePath must be a URL.");
- }
- _this.basePath = _this.basePath.replace(/\/$/, '');
- } else {
- if (_this.discoveryUrl.indexOf('?') > 0) {
- _this.basePath = _this.discoveryUrl.substring(0, _this.discoveryUrl.lastIndexOf('?'));
- } else {
- _this.basePath = _this.discoveryUrl;
- }
- log('derived basepath from discoveryUrl as ' + _this.basePath);
- }
- _this.apis = {};
- _this.apisArray = [];
- if (response.resourcePath != null) {
- _this.resourcePath = response.resourcePath;
- res = null;
- _ref = response.apis;
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
- resource = _ref[_i];
- if (res === null) {
- res = new SwaggerResource(resource, _this);
+ obj = {
+ url: this.discoveryUrl,
+ method: "get",
+ on: {
+ error: function(response) {
+ if (_this.discoveryUrl.substring(0, 4) !== 'http') {
+ return _this.fail('Please specify the protocol for ' + _this.discoveryUrl);
+ } else if (error.status === 0) {
+ return _this.fail('Can\'t read from server. It may not have the appropriate access-control-origin settings.');
+ } else if (error.status === 404) {
+ return _this.fail('Can\'t read swagger JSON from ' + _this.discoveryUrl);
} else {
- res.addOperations(resource.path, resource.operations);
+ return _this.fail(error.status + ' : ' + error.statusText + ' ' + _this.discoveryUrl);
}
- }
- if (res != null) {
- _this.apis[res.name] = res;
- _this.apisArray.push(res);
- res.ready = true;
- _this.selfReflect();
- }
- } else {
- _ref1 = response.apis;
- for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
- resource = _ref1[_j];
- res = new SwaggerResource(resource, _this);
- _this.apis[res.name] = res;
- _this.apisArray.push(res);
+ },
+ response: function(rawResponse) {
+ var res, resource, response, _i, _len, _ref;
+ response = JSON.parse(rawResponse.content.data);
+ if (response.apiVersion != null) {
+ _this.apiVersion = response.apiVersion;
+ }
+ _this.apis = {};
+ _this.apisArray = [];
+ if (response.basePath) {
+ _this.basePath = response.basePath;
+ } else if (_this.discoveryUrl.indexOf('?') > 0) {
+ _this.basePath = _this.discoveryUrl.substring(0, _this.discoveryUrl.lastIndexOf('?'));
+ } else {
+ _this.basePath = _this.discoveryUrl;
+ }
+ _ref = response.apis;
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ resource = _ref[_i];
+ res = new SwaggerResource(resource, _this);
+ _this.apis[res.name] = res;
+ _this.apisArray.push(res);
+ }
+ return _this;
}
}
- return _this;
- }).error(function(error) {
- if (_this.discoveryUrl.substring(0, 4) !== 'http') {
- return _this.fail('Please specify the protocol for ' + _this.discoveryUrl);
- } else if (error.status === 0) {
- return _this.fail('Can\'t read from server. It may not have the appropriate access-control-origin settings.');
- } else if (error.status === 404) {
- return _this.fail('Can\'t read swagger JSON from ' + _this.discoveryUrl);
- } else {
- return _this.fail(error.status + ' : ' + error.statusText + ' ' + _this.discoveryUrl);
- }
- });
+ };
+ return new SwaggerHttp().execute(obj);
};
SwaggerApi.prototype.selfReflect = function() {
@@ -160,16 +129,6 @@
return _results;
};
- SwaggerApi.prototype.suffixApiKey = function(url) {
- var sep;
- if ((this.api_key != null) && jQuery.trim(this.api_key).length > 0 && (url != null)) {
- sep = url.indexOf('?') > 0 ? '&' : '?';
- return url + sep + this.apiKeyName + '=' + this.api_key;
- } else {
- return url;
- }
- };
-
SwaggerApi.prototype.help = function() {
var operation, operation_name, parameter, resource, resource_name, _i, _len, _ref, _ref1, _ref2;
_ref = this.apis;
@@ -196,16 +155,24 @@
SwaggerResource = (function() {
+ SwaggerResource.prototype.api = null;
+
+ SwaggerResource.prototype.produces = null;
+
+ SwaggerResource.prototype.consumes = null;
+
function SwaggerResource(resourceObj, api) {
- var parts,
+ var consumes, obj, parts, produces,
_this = this;
this.api = api;
+ this.api = this.api;
+ produces = [];
+ consumes = [];
this.path = this.api.resourcePath != null ? this.api.resourcePath : resourceObj.path;
this.description = resourceObj.description;
parts = this.path.split("/");
this.name = parts[parts.length - 1].replace('.{format}', '');
this.basePath = this.api.basePath;
- console.log('bp: ' + this.basePath);
this.operations = {};
this.operationsArray = [];
this.modelsArray = [];
@@ -219,30 +186,42 @@
if (this.path == null) {
this.api.fail("SwaggerResources must have a path.");
}
- this.url = this.api.suffixApiKey(this.api.basePath + this.path.replace('{format}', 'json'));
- console.log('basePath: ' + this.api.basePath);
- console.log('url: ' + this.url);
+ this.url = this.api.basePath + this.path.replace('{format}', 'json');
this.api.progress('fetching resource ' + this.name + ': ' + this.url);
- jQuery.getJSON(this.url, function(response) {
- var endpoint, _i, _len, _ref;
- if ((response.basePath != null) && jQuery.trim(response.basePath).length > 0) {
- _this.basePath = response.basePath;
- _this.basePath = _this.basePath.replace(/\/$/, '');
- }
- _this.addModels(response.models);
- if (response.apis) {
- _ref = response.apis;
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
- endpoint = _ref[_i];
- _this.addOperations(endpoint.path, endpoint.operations);
+ obj = {
+ url: this.url,
+ method: "get",
+ on: {
+ error: function(response) {
+ return _this.api.fail("Unable to read api '" + _this.name + "' from path " + _this.url + " (server returned " + error.statusText + ")");
+ },
+ response: function(rawResponse) {
+ var endpoint, response, _i, _len, _ref;
+ response = JSON.parse(rawResponse.content._body);
+ 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;
+ }
+ _this.addModels(response.models);
+ if (response.apis) {
+ _ref = response.apis;
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ endpoint = _ref[_i];
+ _this.addOperations(endpoint.path, endpoint.operations);
+ }
+ }
+ _this.api[_this.name] = _this;
+ _this.ready = true;
+ return _this.api.selfReflect();
}
}
- _this.api[_this.name] = _this;
- _this.ready = true;
- return _this.api.selfReflect();
- }).error(function(error) {
- return _this.api.fail("Unable to read api '" + _this.name + "' from path " + _this.url + " (server returned " + error.statusText + ")");
- });
+ };
+ new SwaggerHttp().execute(obj);
}
}
@@ -267,29 +246,35 @@
};
SwaggerResource.prototype.addOperations = function(resource_path, ops) {
- var consumes, err, errorResponses, o, op, _i, _j, _len, _len1, _results;
+ var consumes, method, o, op, produces, responseMessages, _i, _len, _results;
if (ops) {
_results = [];
for (_i = 0, _len = ops.length; _i < _len; _i++) {
o = ops[_i];
- consumes = o.consumes;
+ consumes = null;
+ produces = null;
+ if (o.consumes != null) {
+ consumes = o.consumes;
+ } else {
+ consumes = this.consumes;
+ }
+ if (o.produces != null) {
+ produces = o.produces;
+ } else {
+ produces = this.produces;
+ }
+ responseMessages = o.responseMessages;
+ method = o.method;
+ if (o.httpMethod) {
+ method = o.httpMethod;
+ }
if (o.supportedContentTypes) {
consumes = o.supportedContentTypes;
}
- errorResponses = o.responseMessages;
- if (errorResponses) {
- for (_j = 0, _len1 = errorResponses.length; _j < _len1; _j++) {
- err = errorResponses[_j];
- err.reason = err.message;
- }
- }
if (o.errorResponses) {
- errorResponses = o.errorResponses;
+ responseMessages = o.errorResponses;
}
- if (o.method) {
- o.httpMethod = o.method;
- }
- op = new SwaggerOperation(o.nickname, resource_path, o.httpMethod, o.parameters, o.summary, o.notes, o.responseClass, errorResponses, this, o.consumes, o.produces);
+ op = new SwaggerOperation(o.nickname, resource_path, method, o.parameters, o.summary, o.notes, o.responseClass, responseMessages, this, consumes, produces);
this.operations[op.nickname] = op;
_results.push(this.operationsArray.push(op));
}
@@ -298,18 +283,20 @@
};
SwaggerResource.prototype.help = function() {
- var operation, operation_name, parameter, _i, _len, _ref, _ref1;
+ var msg, operation, operation_name, parameter, _i, _len, _ref, _ref1, _results;
_ref = this.operations;
+ _results = [];
for (operation_name in _ref) {
operation = _ref[operation_name];
- console.log(" " + operation.nickname);
+ msg = " " + operation.nickname;
_ref1 = operation.parameters;
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
parameter = _ref1[_i];
- console.log(" " + parameter.name + (parameter.required ? ' (required)' : '') + " - " + parameter.description);
+ msg.concat(" " + parameter.name + (parameter.required ? ' (required)' : '') + " - " + parameter.description);
}
+ _results.push(msg);
}
- return this;
+ return _results;
};
return SwaggerResource;
@@ -456,17 +443,17 @@
SwaggerOperation = (function() {
- function SwaggerOperation(nickname, path, httpMethod, parameters, summary, notes, responseClass, errorResponses, resource, consumes, produces) {
+ function SwaggerOperation(nickname, path, method, parameters, summary, notes, responseClass, responseMessages, resource, consumes, produces) {
var parameter, v, _i, _j, _len, _len1, _ref, _ref1, _ref2,
_this = this;
this.nickname = nickname;
this.path = path;
- this.httpMethod = httpMethod;
+ this.method = method;
this.parameters = parameters != null ? parameters : [];
this.summary = summary;
this.notes = notes;
this.responseClass = responseClass;
- this.errorResponses = errorResponses;
+ this.responseMessages = responseMessages;
this.resource = resource;
this.consumes = consumes;
this.produces = produces;
@@ -478,12 +465,12 @@
if (this.path == null) {
this.resource.api.fail("SwaggerOperation " + nickname + " is missing path.");
}
- if (this.httpMethod == null) {
- this.resource.api.fail("SwaggerOperation " + nickname + " is missing httpMethod.");
+ if (this.method == null) {
+ this.resource.api.fail("SwaggerOperation " + nickname + " is missing method.");
}
this.path = this.path.replace('{format}', 'json');
- this.httpMethod = this.httpMethod.toLowerCase();
- this.isGetMethod = this.httpMethod === "get";
+ this.method = this.method.toLowerCase();
+ this.isGetMethod = this.method === "get";
this.resourceName = this.resource.name;
if (((_ref = this.responseClass) != null ? _ref.toLowerCase() : void 0) === 'void') {
this.responseClass = void 0;
@@ -492,7 +479,7 @@
this.responseClassSignature = this.getSignature(this.responseClass, this.resource.models);
this.responseSampleJSON = this.getSampleJSON(this.responseClass, this.resource.models);
}
- this.errorResponses = this.errorResponses || [];
+ this.responseMessages = this.responseMessages || [];
_ref1 = this.parameters;
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
parameter = _ref1[_i];
@@ -569,10 +556,12 @@
};
SwaggerOperation.prototype["do"] = function(args, callback, error) {
- var body, headers;
+ var key, param, params, possibleParams, requestContentType, responseContentType, value;
if (args == null) {
args = {};
}
+ requestContentType = null;
+ responseContentType = null;
if ((typeof args) === "function") {
error = callback;
callback = args;
@@ -585,18 +574,49 @@
}
if (callback == null) {
callback = function(data) {
- return console.log(data);
+ return console.log("default callback: " + data);
};
}
+ params = {};
+ if (args.requestContentType) {
+ requestContentType = args.requestContentType;
+ }
+ if (args.responseContentType) {
+ responseContentType = args.responseContentType;
+ }
if (args.headers != null) {
- headers = args.headers;
+ params.headers = args.headers;
delete args.headers;
}
if (args.body != null) {
- body = args.body;
+ params.body = args.body;
delete args.body;
}
- return new SwaggerRequest(this.httpMethod, this.urlify(args), headers, body, callback, error, this);
+ possibleParams = (function() {
+ var _i, _len, _ref, _results;
+ _ref = this.parameters;
+ _results = [];
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ param = _ref[_i];
+ if (param.paramType === "form") {
+ _results.push(param);
+ }
+ }
+ return _results;
+ }).call(this);
+ if (possibleParams) {
+ for (key in possibleParams) {
+ value = possibleParams[key];
+ if (args[value.name]) {
+ params[value.name] = args[value.name];
+ }
+ }
+ }
+ if (args.mock != null) {
+ params.mock = args["mock"];
+ }
+ params["parent"] = args["parent"];
+ return new SwaggerRequest(this.method, this.urlify(args), params, requestContentType, responseContentType, callback, error, this);
};
SwaggerOperation.prototype.pathJson = function() {
@@ -607,11 +627,8 @@
return this.path.replace("{format}", "xml");
};
- SwaggerOperation.prototype.urlify = function(args, includeApiKey) {
- var param, queryParams, reg, url, _i, _len, _ref;
- if (includeApiKey == null) {
- includeApiKey = true;
- }
+ SwaggerOperation.prototype.urlify = function(args) {
+ var param, queryParams, reg, url, _i, _j, _len, _len1, _ref, _ref1;
url = this.resource.basePath + this.pathJson();
_ref = this.parameters;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
@@ -626,13 +643,18 @@
}
}
}
- if (includeApiKey && (this.resource.api.api_key != null) && this.resource.api.api_key.length > 0) {
- args[this.apiKeyName] = this.resource.api.api_key;
- }
- if (this.supportHeaderParams()) {
- queryParams = jQuery.param(this.getQueryParams(args, includeApiKey));
- } else {
- queryParams = jQuery.param(this.getQueryAndHeaderParams(args, includeApiKey));
+ queryParams = "";
+ _ref1 = this.parameters;
+ for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
+ param = _ref1[_j];
+ if (param.paramType === 'query') {
+ if (args[param.name]) {
+ if (queryParams !== "") {
+ queryParams += "&";
+ }
+ queryParams += encodeURIComponent(param.name) + '=' + encodeURIComponent(args[param.name]);
+ }
+ }
}
if ((queryParams != null) && queryParams.length > 0) {
url += "?" + queryParams;
@@ -648,58 +670,44 @@
return this.resource.api.supportedSubmitMethods;
};
- SwaggerOperation.prototype.getQueryAndHeaderParams = function(args, includeApiKey) {
- if (includeApiKey == null) {
- includeApiKey = true;
- }
- return this.getMatchingParams(['query', 'header'], args, includeApiKey);
+ SwaggerOperation.prototype.getQueryParams = function(args) {
+ return this.getMatchingParams(['query'], args);
};
- SwaggerOperation.prototype.getQueryParams = function(args, includeApiKey) {
- if (includeApiKey == null) {
- includeApiKey = true;
- }
- return this.getMatchingParams(['query'], args, includeApiKey);
+ SwaggerOperation.prototype.getHeaderParams = function(args) {
+ return this.getMatchingParams(['header'], args);
};
- SwaggerOperation.prototype.getHeaderParams = function(args, includeApiKey) {
- if (includeApiKey == null) {
- includeApiKey = true;
- }
- return this.getMatchingParams(['header'], args, includeApiKey);
- };
-
- SwaggerOperation.prototype.getMatchingParams = function(paramTypes, args, includeApiKey) {
+ SwaggerOperation.prototype.getMatchingParams = function(paramTypes, args) {
var matchingParams, name, param, value, _i, _len, _ref, _ref1;
matchingParams = {};
_ref = this.parameters;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
param = _ref[_i];
- if ((jQuery.inArray(param.paramType, paramTypes) >= 0) && args[param.name]) {
+ if (args && args[param.name]) {
matchingParams[param.name] = args[param.name];
}
}
- if (includeApiKey && (this.resource.api.api_key != null) && this.resource.api.api_key.length > 0) {
- matchingParams[this.resource.api.apiKeyName] = this.resource.api.api_key;
- }
- if (jQuery.inArray('header', paramTypes) >= 0) {
- _ref1 = this.resource.api.headers;
- for (name in _ref1) {
- value = _ref1[name];
- matchingParams[name] = value;
- }
+ _ref1 = this.resource.api.headers;
+ for (name in _ref1) {
+ value = _ref1[name];
+ matchingParams[name] = value;
}
return matchingParams;
};
SwaggerOperation.prototype.help = function() {
- var parameter, _i, _len, _ref;
+ var msg, parameter, _i, _len, _ref;
+ msg = "";
_ref = this.parameters;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
parameter = _ref[_i];
- console.log(" " + parameter.name + (parameter.required ? ' (required)' : '') + " - " + parameter.description);
+ if (msg !== "") {
+ msg += "\n";
+ }
+ msg += "* " + parameter.name + (parameter.required ? ' (required)' : '') + " - " + parameter.description;
}
- return this;
+ return msg;
};
return SwaggerOperation;
@@ -708,16 +716,18 @@
SwaggerRequest = (function() {
- function SwaggerRequest(type, url, headers, body, successCallback, errorCallback, operation) {
- var obj,
+ function SwaggerRequest(type, url, params, requestContentType, responseContentType, successCallback, errorCallback, operation, execution) {
+ var body, e, fields, headers, key, myHeaders, obj, param, parent, possibleParams, urlEncoded, value, values,
_this = this;
this.type = type;
this.url = url;
- this.headers = headers;
- this.body = body;
+ this.params = params;
+ this.requestContentType = requestContentType;
+ this.responseContentType = responseContentType;
this.successCallback = successCallback;
this.errorCallback = errorCallback;
this.operation = operation;
+ this.execution = execution;
if (this.type == null) {
throw "SwaggerRequest type is required (get/post/put/delete).";
}
@@ -733,30 +743,133 @@
if (this.operation == null) {
throw "SwaggerRequest operation is required.";
}
- if (this.operation.resource.api.verbose) {
- console.log(this.asCurl());
+ this.type = this.type.toUpperCase();
+ headers = params.headers;
+ myHeaders = {};
+ body = params.body;
+ parent = params["parent"];
+ requestContentType = "application/json";
+ if (body && (this.type === "POST" || this.type === "PUT" || this.type === "PATCH")) {
+ if (this.requestContentType) {
+ requestContentType = this.requestContentType;
+ }
+ } else {
+ if (((function() {
+ var _i, _len, _ref, _results;
+ _ref = this.operation.parameters;
+ _results = [];
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ param = _ref[_i];
+ if (param.paramType === "form") {
+ _results.push(param);
+ }
+ }
+ return _results;
+ }).call(this)).length > 0) {
+ requestContentType = "application/x-www-form-urlencoded";
+ } else if (this.type !== "DELETE") {
+ requestContentType = null;
+ }
}
- this.headers || (this.headers = {});
- if (this.operation.resource.api.api_key != null) {
- this.headers[this.apiKeyName] = this.operation.resource.api.api_key;
+ if (requestContentType && this.operation.consumes) {
+ if (this.operation.consumes.indexOf(requestContentType) === -1) {
+ console.log("server doesn't consume " + requestContentType + ", try " + JSON.stringify(this.operation.consumes));
+ if (this.requestContentType === null) {
+ requestContentType = this.operation.consumes[0];
+ }
+ } else {
+ console.log("it's ok to send " + requestContentType);
+ }
}
- if (this.headers.mock == null) {
+ responseContentType = null;
+ if (this.type === "POST" || this.type === "GET") {
+ if (this.responseContentType) {
+ responseContentType = this.responseContentType;
+ } else {
+ responseContentType = "application/json";
+ }
+ } else {
+ responseContentType = null;
+ }
+ if (responseContentType && this.operation.produces) {
+ if (this.operation.produces.indexOf(responseContentType) === -1) {
+ console.log("server can't produce " + responseContentType);
+ } else {
+ console.log("get ready for " + responseContentType);
+ }
+ }
+ if (requestContentType && requestContentType.indexOf("application/x-www-form-urlencoded") === 0) {
+ console.log("pulling fields");
+ fields = {};
+ possibleParams = (function() {
+ var _i, _len, _ref, _results;
+ _ref = this.operation.parameters;
+ _results = [];
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ param = _ref[_i];
+ if (param.paramType === "form") {
+ _results.push(param);
+ }
+ }
+ return _results;
+ }).call(this);
+ console.log(possibleParams);
+ values = {};
+ for (key in possibleParams) {
+ value = possibleParams[key];
+ if (this.params[value.name]) {
+ values[value.name] = this.params[value.name];
+ }
+ }
+ urlEncoded = "";
+ for (key in values) {
+ value = values[key];
+ if (urlEncoded !== "") {
+ urlEncoded += "&";
+ }
+ urlEncoded += encodeURIComponent(key) + '=' + encodeURIComponent(value);
+ }
+ body = urlEncoded;
+ }
+ if (requestContentType) {
+ myHeaders["Content-Type"] = requestContentType;
+ }
+ if (responseContentType) {
+ myHeaders["Accept"] = responseContentType;
+ }
+ if (!((headers != null) && (headers.mock != null))) {
obj = {
- type: this.type,
url: this.url,
- data: JSON.stringify(this.body),
- dataType: 'json',
- error: function(xhr, textStatus, error) {
- return _this.errorCallback(xhr, textStatus, error);
- },
- success: function(data) {
- return _this.successCallback(data);
+ method: this.type,
+ headers: myHeaders,
+ body: body,
+ on: {
+ error: function(response) {
+ return _this.errorCallback(response, _this.params["parent"]);
+ },
+ redirect: function(response) {
+ return _this.successCallback(response, _this.params["parent"]);
+ },
+ 307: function(response) {
+ return _this.successCallback(response, _this.params["parent"]);
+ },
+ response: function(response) {
+ return _this.successCallback(response, _this.params["parent"]);
+ }
}
};
- if (obj.type.toLowerCase() === "post" || obj.type.toLowerCase() === "put") {
- obj.contentType = "application/json";
+ e = {};
+ if (typeof window !== 'undefined') {
+ e = window;
+ } else {
+ e = exports;
+ }
+ e.authorizations.apply(obj);
+ if (params.mock == null) {
+ new SwaggerHttp().execute(obj);
+ } else {
+ return obj;
}
- jQuery.ajax(obj);
}
}
@@ -779,14 +892,115 @@
})();
- window.SwaggerApi = SwaggerApi;
+ SwaggerHttp = (function() {
- window.SwaggerResource = SwaggerResource;
+ SwaggerHttp.prototype.shred = null;
- window.SwaggerOperation = SwaggerOperation;
+ function SwaggerHttp() {
+ var Shred;
+ Shred = null;
+ if (typeof window !== 'undefined') {
+ Shred = require("./shred");
+ } else {
+ Shred = require("shred");
+ }
+ this.shred = new Shred();
+ }
- window.SwaggerRequest = SwaggerRequest;
+ SwaggerHttp.prototype.execute = function(obj) {
+ var Content, identity, toString,
+ _this = this;
+ Content = require("./shred/content");
+ identity = function(x) {
+ return x;
+ };
+ toString = function(x) {
+ return x.toString;
+ };
+ Content.registerProcessor(["application/json; charset=utf-8", "application/json", "json"], {
+ parser: identity,
+ stringify: toString
+ });
+ return this.shred.request(obj);
+ };
- window.SwaggerModelProperty = SwaggerModelProperty;
+ return SwaggerHttp;
+
+ })();
+
+ SwaggerAuthorizations = (function() {
+
+ SwaggerAuthorizations.prototype.authz = null;
+
+ function SwaggerAuthorizations() {
+ this.authz = {};
+ }
+
+ SwaggerAuthorizations.prototype.add = function(name, auth) {
+ this.authz[name] = auth;
+ return auth;
+ };
+
+ SwaggerAuthorizations.prototype.apply = function(obj) {
+ var key, value, _ref, _results;
+ _ref = this.authz;
+ _results = [];
+ for (key in _ref) {
+ value = _ref[key];
+ _results.push(value.apply(obj));
+ }
+ return _results;
+ };
+
+ return SwaggerAuthorizations;
+
+ })();
+
+ ApiKeyAuthorization = (function() {
+
+ ApiKeyAuthorization.prototype.type = null;
+
+ ApiKeyAuthorization.prototype.name = null;
+
+ ApiKeyAuthorization.prototype.value = null;
+
+ function ApiKeyAuthorization(name, value, type) {
+ this.name = name;
+ this.value = value;
+ this.type = type;
+ }
+
+ ApiKeyAuthorization.prototype.apply = function(obj) {
+ 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") {
+ return obj.headers[this.name] = this.value;
+ }
+ };
+
+ return ApiKeyAuthorization;
+
+ })();
+
+ this.SwaggerApi = SwaggerApi;
+
+ this.SwaggerResource = SwaggerResource;
+
+ this.SwaggerOperation = SwaggerOperation;
+
+ this.SwaggerRequest = SwaggerRequest;
+
+ this.SwaggerModelProperty = SwaggerModelProperty;
+
+ this.SwaggerAuthorizations = new SwaggerAuthorizations();
+
+ this.ApiKeyAuthorization = ApiKeyAuthorization;
+
+ this.authorizations = new SwaggerAuthorizations();
}).call(this);
diff --git a/dist/swagger-ui.js b/dist/swagger-ui.js
index 7727a913..f6e604c8 100644
--- a/dist/swagger-ui.js
+++ b/dist/swagger-ui.js
@@ -191,7 +191,7 @@ templates['content_type'] = template(function (Handlebars,depth0,helpers,partial
function program1(depth0,data) {
var buffer = "", stack1, stack2;
- buffer += "\n ";
+ buffer += "\n ";
foundHelper = helpers.produces;
stack1 = foundHelper || depth0.produces;
stack2 = helpers.each;
@@ -222,7 +222,7 @@ function program2(depth0,data) {
function program4(depth0,data) {
- return "\n
\n";}
+ return "\n
\n";}
buffer += "
\n
\n";
+ stack1 = depth0;
+ if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
+ else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "this", { hash: {} }); }
+ if(stack1 || stack1 === 0) { buffer += stack1; }
+ buffer += "\n ";
+ return buffer;}
+
+function program4(depth0,data) {
+
+
+ return "\n \n";}
+
+ buffer += "\n\n";
+ return buffer;});
+})();
+
(function() {
var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
templates['signature'] = template(function (Handlebars,depth0,helpers,partials,data) {
@@ -1219,7 +1331,7 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials
// Generated by CoffeeScript 1.4.0
(function() {
- var ContentTypeView, HeaderView, MainView, OperationView, ParameterView, ResourceView, SignatureView, StatusCodeView, SwaggerUi,
+ var ContentTypeView, HeaderView, MainView, OperationView, ParameterContentTypeView, ParameterView, ResourceView, ResponseContentTypeView, SignatureView, StatusCodeView, SwaggerUi,
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
@@ -1500,8 +1612,8 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials
OperationView.prototype.initialize = function() {};
OperationView.prototype.render = function() {
- var contentTypeModel, contentTypeView, isMethodSubmissionSupported, param, responseSignatureView, signatureModel, statusCode, _i, _j, _len, _len1, _ref, _ref1;
- isMethodSubmissionSupported = jQuery.inArray(this.model.httpMethod, this.model.supportedSubmitMethods()) >= 0;
+ var contentTypeModel, isMethodSubmissionSupported, param, responseContentTypeView, responseSignatureView, signatureModel, statusCode, _i, _j, _len, _len1, _ref, _ref1;
+ isMethodSubmissionSupported = true;
if (!isMethodSubmissionSupported) {
this.model.isReadOnly = true;
}
@@ -1523,22 +1635,18 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials
contentTypeModel = {
isParam: false
};
- if (this.model.supportedContentTypes) {
- contentTypeModel.produces = this.model.supportedContentTypes;
- }
- if (this.model.produces) {
- contentTypeModel.produces = this.model.produces;
- }
- contentTypeView = new ContentTypeView({
+ contentTypeModel.consumes = this.model.consumes;
+ contentTypeModel.produces = this.model.produces;
+ responseContentTypeView = new ResponseContentTypeView({
model: contentTypeModel
});
- $('.content-type', $(this.el)).append(contentTypeView.render().el);
+ $('.response-content-type', $(this.el)).append(responseContentTypeView.render().el);
_ref = this.model.parameters;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
param = _ref[_i];
- this.addParameter(param);
+ this.addParameter(param, contentTypeModel.consumes);
}
- _ref1 = this.model.errorResponses;
+ _ref1 = this.model.responseMessages;
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
statusCode = _ref1[_j];
this.addStatusCode(statusCode);
@@ -1546,8 +1654,9 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials
return this;
};
- OperationView.prototype.addParameter = function(param) {
+ OperationView.prototype.addParameter = function(param, consumes) {
var paramView;
+ param.consumes = consumes;
paramView = new ParameterView({
model: param,
tagName: 'tr',
@@ -1566,8 +1675,7 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials
};
OperationView.prototype.submitOperation = function(e) {
- var bodyParam, consumes, error_free, form, headerParams, invocationUrl, isFileUpload, isFormPost, map, o, obj, param, paramContentTypeField, responseContentTypeField, _i, _j, _k, _l, _len, _len1, _len2, _len3, _len4, _m, _ref, _ref1, _ref2, _ref3, _ref4,
- _this = this;
+ var error_free, form, map, o, _i, _len, _ref;
if (e != null) {
e.preventDefault();
}
@@ -1587,7 +1695,9 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials
}
});
if (error_free) {
- map = {};
+ map = {
+ parent: this
+ };
_ref = form.serializeArray();
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
o = _ref[_i];
@@ -1595,101 +1705,17 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials
map[o.name] = o.value;
}
}
- isFileUpload = form.children().find('input[type~="file"]').size() !== 0;
- isFormPost = false;
- consumes = "application/json";
- if (this.model.consumes && this.model.consumes.length > 0) {
- consumes = this.model.consumes[0];
- } else {
- _ref1 = this.model.parameters;
- for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
- o = _ref1[_j];
- if (o.paramType === 'form') {
- isFormPost = true;
- consumes = false;
- }
- }
- if (isFileUpload) {
- consumes = false;
- } else if (this.model.httpMethod.toLowerCase() === "post" && isFormPost === false) {
- consumes = "application/json";
- }
- }
- if (isFileUpload) {
- bodyParam = new FormData();
- _ref2 = this.model.parameters;
- for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {
- param = _ref2[_k];
- if ((param.paramType === 'body' || 'form') && param.name !== 'file' && param.name !== 'File' && (map[param.name] != null)) {
- bodyParam.append(param.name, map[param.name]);
- }
- }
- $.each(form.children().find('input[type~="file"]'), function(i, el) {
- return bodyParam.append($(el).attr('name'), el.files[0]);
- });
- console.log(bodyParam);
- } else if (isFormPost) {
- bodyParam = new FormData();
- _ref3 = this.model.parameters;
- for (_l = 0, _len3 = _ref3.length; _l < _len3; _l++) {
- param = _ref3[_l];
- if (map[param.name] != null) {
- bodyParam.append(param.name, map[param.name]);
- }
- }
- } else {
- bodyParam = null;
- _ref4 = this.model.parameters;
- for (_m = 0, _len4 = _ref4.length; _m < _len4; _m++) {
- param = _ref4[_m];
- if (param.paramType === 'body') {
- bodyParam = map[param.name];
- }
- }
- }
- log("bodyParam = " + bodyParam);
- headerParams = null;
- invocationUrl = this.model.supportHeaderParams() ? (headerParams = this.model.getHeaderParams(map), this.model.urlify(map, false)) : this.model.urlify(map, true);
- log('submitting ' + invocationUrl);
- $(".request_url", $(this.el)).html("
" + invocationUrl + "
");
- $(".response_throbber", $(this.el)).show();
- obj = {
- type: this.model.httpMethod,
- url: invocationUrl,
- headers: headerParams,
- data: bodyParam,
- contentType: consumes,
- dataType: 'json',
- processData: false,
- error: function(xhr, textStatus, error) {
- return _this.showErrorStatus(xhr, textStatus, error);
- },
- success: function(data) {
- return _this.showResponse(data);
- },
- complete: function(data) {
- return _this.showCompleteStatus(data);
- }
- };
- paramContentTypeField = $("td select[name=contentType]", $(this.el)).val();
- if (paramContentTypeField) {
- obj.contentType = paramContentTypeField;
- }
- log('content type = ' + obj.contentType);
- if (!(obj.data || (obj.type === 'GET' || obj.type === 'DELETE')) && obj.contentType === !"application/x-www-form-urlencoded") {
- obj.contentType = false;
- }
- log('content type is now = ' + obj.contentType);
- responseContentTypeField = $('.content > .content-type > div > select[name=contentType]', $(this.el)).val();
- if (responseContentTypeField) {
- obj.headers = obj.headers != null ? obj.headers : {};
- obj.headers.accept = responseContentTypeField;
- }
- jQuery.ajax(obj);
- return false;
+ console.log(map);
+ map["responseContentType"] = $("div select[name=responseContentType]", $(this.el)).val();
+ map["requestContentType"] = $("div select[name=parameterContentType]", $(this.el)).val();
+ return this.model["do"](map, this.showCompleteStatus, this.showErrorStatus, this);
}
};
+ OperationView.prototype.success = function(response, parent) {
+ return parent.showCompleteStatus(response);
+ };
+
OperationView.prototype.hideResponse = function(e) {
if (e != null) {
e.preventDefault();
@@ -1704,12 +1730,12 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials
return $(".response_body", $(this.el)).html(escape(prettyJson));
};
- OperationView.prototype.showErrorStatus = function(data) {
- return this.showStatus(data);
+ OperationView.prototype.showErrorStatus = function(data, parent) {
+ return parent.showStatus(data);
};
- OperationView.prototype.showCompleteStatus = function(data) {
- return this.showStatus(data);
+ OperationView.prototype.showCompleteStatus = function(data, parent) {
+ return parent.showStatus(data);
};
OperationView.prototype.formatXml = function(xml) {
@@ -1786,18 +1812,31 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials
};
OperationView.prototype.showStatus = function(data) {
- var code, pre, response_body;
- try {
- code = $('').text(JSON.stringify(JSON.parse(data.responseText), null, 2));
+ var code, content, contentType, headers, pre, response_body;
+ content = data.content.data;
+ headers = data.getHeaders();
+ contentType = headers["Content-Type"];
+ if (content === void 0) {
+ code = $('').text("no content");
pre = $('').append(code);
- } catch (error) {
- code = $('').text(this.formatXml(data.responseText));
+ } else if (contentType.indexOf("application/json") === 0) {
+ code = $('').text(JSON.stringify(JSON.parse(content), null, 2));
+ pre = $('').append(code);
+ } else if (contentType.indexOf("application/xml") === 0) {
+ code = $('').text(this.formatXml(content));
pre = $('').append(code);
+ } else if (contentType.indexOf("text/html") === 0) {
+ code = $('').html(content);
+ pre = $('').append(code);
+ } else {
+ code = $('').text(content);
+ pre = $('').append(code);
}
response_body = pre;
+ $(".request_url").html("" + data.request.url + "
");
$(".response_code", $(this.el)).html("" + data.status + "
");
$(".response_body", $(this.el)).html(response_body);
- $(".response_headers", $(this.el)).html("" + data.getAllResponseHeaders() + "
");
+ $(".response_headers", $(this.el)).html("" + JSON.stringify(data.getHeaders()) + "
");
$(".response", $(this.el)).slideDown();
$(".response_hider", $(this.el)).show();
$(".response_throbber", $(this.el)).hide();
@@ -1806,7 +1845,7 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials
OperationView.prototype.toggleOperationContent = function() {
var elem;
- elem = $('#' + Docs.escapeResourceName(this.model.resourceName) + "_" + this.model.nickname + "_" + this.model.httpMethod + "_" + this.model.number + "_content");
+ elem = $('#' + Docs.escapeResourceName(this.model.resourceName) + "_" + this.model.nickname + "_" + this.model.method + "_" + this.model.number + "_content");
if (elem.is(':visible')) {
return Docs.collapseOperation(elem);
} else {
@@ -1854,7 +1893,7 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials
ParameterView.prototype.initialize = function() {};
ParameterView.prototype.render = function() {
- var contentTypeModel, contentTypeView, signatureModel, signatureView, template;
+ var contentTypeModel, isParam, parameterContentTypeView, responseContentTypeView, signatureModel, signatureView, template;
if (this.model.paramType === 'body') {
this.model.isBody = true;
}
@@ -1877,19 +1916,25 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials
} else {
$('.model-signature', $(this.el)).html(this.model.signature);
}
+ isParam = false;
+ if (this.model.isBody) {
+ isParam = true;
+ }
contentTypeModel = {
- isParam: false
+ isParam: isParam
};
- if (this.model.supportedContentTypes) {
- contentTypeModel.produces = this.model.supportedContentTypes;
+ contentTypeModel.consumes = this.model.consumes;
+ if (isParam) {
+ parameterContentTypeView = new ParameterContentTypeView({
+ model: contentTypeModel
+ });
+ $('.parameter-content-type', $(this.el)).append(parameterContentTypeView.render().el);
+ } else {
+ responseContentTypeView = new ResponseContentTypeView({
+ model: contentTypeModel
+ });
+ $('.response-content-type', $(this.el)).append(responseContentTypeView.render().el);
}
- if (this.model.produces) {
- contentTypeModel.produces = this.model.produces;
- }
- contentTypeView = new ContentTypeView({
- model: contentTypeModel
- });
- $('.content-type', $(this.el)).append(contentTypeView.render().el);
return this;
};
@@ -2000,12 +2045,7 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials
var template;
template = this.template();
$(this.el).html(template(this.model));
- this.isParam = this.model.isParam;
- if (this.isParam) {
- $('label[for=contentType]', $(this.el)).text('Parameter content type:');
- } else {
- $('label[for=contentType]', $(this.el)).text('Response Content Type');
- }
+ $('label[for=contentType]', $(this.el)).text('Response Content Type');
return this;
};
@@ -2017,4 +2057,56 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials
})(Backbone.View);
+ ResponseContentTypeView = (function(_super) {
+
+ __extends(ResponseContentTypeView, _super);
+
+ function ResponseContentTypeView() {
+ return ResponseContentTypeView.__super__.constructor.apply(this, arguments);
+ }
+
+ ResponseContentTypeView.prototype.initialize = function() {};
+
+ ResponseContentTypeView.prototype.render = function() {
+ var template;
+ template = this.template();
+ $(this.el).html(template(this.model));
+ $('label[for=responseContentType]', $(this.el)).text('Response Content Type');
+ return this;
+ };
+
+ ResponseContentTypeView.prototype.template = function() {
+ return Handlebars.templates.response_content_type;
+ };
+
+ return ResponseContentTypeView;
+
+ })(Backbone.View);
+
+ ParameterContentTypeView = (function(_super) {
+
+ __extends(ParameterContentTypeView, _super);
+
+ function ParameterContentTypeView() {
+ return ParameterContentTypeView.__super__.constructor.apply(this, arguments);
+ }
+
+ ParameterContentTypeView.prototype.initialize = function() {};
+
+ ParameterContentTypeView.prototype.render = function() {
+ var template;
+ template = this.template();
+ $(this.el).html(template(this.model));
+ $('label[for=parameterContentType]', $(this.el)).text('Parameter content type:');
+ return this;
+ };
+
+ ParameterContentTypeView.prototype.template = function() {
+ return Handlebars.templates.parameter_content_type;
+ };
+
+ return ParameterContentTypeView;
+
+ })(Backbone.View);
+
}).call(this);
diff --git a/dist/swagger-ui.min.js b/dist/swagger-ui.min.js
index 4947965e..9362cb88 100644
--- a/dist/swagger-ui.min.js
+++ b/dist/swagger-ui.min.js
@@ -1 +1 @@
-$(function(){$.fn.vAlign=function(){return this.each(function(c){var a=$(this).height();var d=$(this).parent().height();var b=(d-a)/2;$(this).css("margin-top",b)})};$.fn.stretchFormtasticInputWidthToParent=function(){return this.each(function(b){var d=$(this).closest("form").innerWidth();var c=parseInt($(this).closest("form").css("padding-left"),10)+parseInt($(this).closest("form").css("padding-right"),10);var a=parseInt($(this).css("padding-left"),10)+parseInt($(this).css("padding-right"),10);$(this).css("width",d-c-a)})};$("form.formtastic li.string input, form.formtastic textarea").stretchFormtasticInputWidthToParent();$("ul.downplayed li div.content p").vAlign();$("form.sandbox").submit(function(){var a=true;$(this).find("input.required").each(function(){$(this).removeClass("error");if($(this).val()==""){$(this).addClass("error");$(this).wiggle();a=false}});return a})});function clippyCopiedCallback(b){$("#api_key_copied").fadeIn().delay(1000).fadeOut()}function log(){if(window.console){console.log.apply(console,arguments)}}if(Function.prototype.bind&&console&&typeof console.log=="object"){["log","info","warn","error","assert","dir","clear","profile","profileEnd"].forEach(function(a){console[a]=this.bind(console[a],console)},Function.prototype.call)}var Docs={shebang:function(){var b=$.param.fragment().split("/");b.shift();switch(b.length){case 1:var d="resource_"+b[0];Docs.expandEndpointListForResource(b[0]);$("#"+d).slideto({highlight:false});break;case 2:Docs.expandEndpointListForResource(b[0]);$("#"+d).slideto({highlight:false});var c=b.join("_");var a=c+"_content";Docs.expandOperation($("#"+a));$("#"+c).slideto({highlight:false});break}},toggleEndpointListForResource:function(b){var a=$("li#resource_"+Docs.escapeResourceName(b)+" ul.endpoints");if(a.is(":visible")){Docs.collapseEndpointListForResource(b)}else{Docs.expandEndpointListForResource(b)}},expandEndpointListForResource:function(b){var b=Docs.escapeResourceName(b);if(b==""){$(".resource ul.endpoints").slideDown();return}$("li#resource_"+b).addClass("active");var a=$("li#resource_"+b+" ul.endpoints");a.slideDown()},collapseEndpointListForResource:function(b){var b=Docs.escapeResourceName(b);$("li#resource_"+b).removeClass("active");var a=$("li#resource_"+b+" ul.endpoints");a.slideUp()},expandOperationsForResource:function(a){Docs.expandEndpointListForResource(a);if(a==""){$(".resource ul.endpoints li.operation div.content").slideDown();return}$("li#resource_"+Docs.escapeResourceName(a)+" li.operation div.content").each(function(){Docs.expandOperation($(this))})},collapseOperationsForResource:function(a){Docs.expandEndpointListForResource(a);$("li#resource_"+Docs.escapeResourceName(a)+" li.operation div.content").each(function(){Docs.collapseOperation($(this))})},escapeResourceName:function(a){return a.replace(/[!"#$%&'()*+,.\/:;<=>?@\[\\\]\^`{|}~]/g,"\\$&")},expandOperation:function(a){a.slideDown()},collapseOperation:function(a){a.slideUp()}};(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.content_type=b(function(g,p,f,n,m){f=f||g.helpers;var l="",c,s,k,j,q=this,h="function",o=f.helperMissing,i=void 0;function e(x,w){var t="",v,u;t+="\n ";k=f.produces;v=k||x.produces;u=f.each;j=q.program(2,d,w);j.hash={};j.fn=j;j.inverse=q.noop;v=u.call(x,v,j);if(v||v===0){t+=v}t+="\n";return t}function d(w,v){var t="",u;t+='\n \n ";return t}function r(u,t){return'\n \n'}l+='\n\n";return l})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.main=b(function(f,p,e,n,m){e=e||f.helpers;var k="",c,r,j,i,q=this,g="function",o=e.helperMissing,h=void 0,l=this.escapeExpression;function d(v,u){var s="",t;s+='\n , api version: ';j=e.apiVersion;t=j||v.apiVersion;if(typeof t===g){t=t.call(v,{hash:{}})}else{if(t===h){t=o.call(v,"apiVersion",{hash:{}})}}s+=l(t)+"\n ";return s}k+="\n\n";return k})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.operation=b(function(h,u,s,m,w){s=s||h.helpers;var t="",j,g,i,q,p=this,e="function",r=s.helperMissing,c=void 0,d=this.escapeExpression;function o(A,z){var x="",y;x+="\n Implementation Notes
\n ";i=s.notes;y=i||A.notes;if(typeof y===e){y=y.call(A,{hash:{}})}else{if(y===c){y=r.call(A,"notes",{hash:{}})}}if(y||y===0){x+=y}x+="
\n ";return x}function n(y,x){return'\n Response Class
\n
\n
\n \n '}function l(y,x){return'\n Parameters
\n \n \n \n | Parameter | \n Value | \n Description | \n Parameter Type | \n Data Type | \n
\n \n \n\n \n
\n '}function k(y,x){return"\n \n Error Status Codes
\n \n \n \n | HTTP Status Code | \n Reason | \n
\n \n \n \n \n
\n "}function f(y,x){return"\n "}function v(y,x){return"\n \n "}t+="\n \n - \n \n
\n ";i=s.notes;j=i||u.notes;g=s["if"];q=p.program(1,o,w);q.hash={};q.fn=q;q.inverse=p.noop;j=g.call(u,j,q);if(j||j===0){t+=j}t+="\n ";i=s.responseClass;j=i||u.responseClass;g=s["if"];q=p.program(3,n,w);q.hash={};q.fn=q;q.inverse=p.noop;j=g.call(u,j,q);if(j||j===0){t+=j}t+="\n
\n
\n
Request URL
\n
\n
Response Body
\n
\n
Response Code
\n
\n
Response Headers
\n \n
\n
\n \n
\n";return t})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param=b(function(h,v,t,m,y){t=t||h.helpers;var u="",j,g,i,r,q=this,e="function",s=t.helperMissing,c=void 0,d=this.escapeExpression;function p(D,C){var z="",B,A;z+="\n ";i=t.isFile;B=i||D.isFile;A=t["if"];r=q.program(2,o,C);r.hash={};r.fn=r;r.inverse=q.program(4,n,C);B=A.call(D,B,r);if(B||B===0){z+=B}z+="\n ";return z}function o(C,B){var z="",A;z+='\n \n ";return z}function n(D,C){var z="",B,A;z+="\n ";i=t.defaultValue;B=i||D.defaultValue;A=t["if"];r=q.program(5,l,C);r.hash={};r.fn=r;r.inverse=q.program(7,k,C);B=A.call(D,B,r);if(B||B===0){z+=B}z+="\n ";return z}function l(C,B){var z="",A;z+="\n \n ";return z}function k(C,B){var z="",A;z+="\n \n
\n \n ';return z}function f(D,C){var z="",B,A;z+="\n ";i=t.defaultValue;B=i||D.defaultValue;A=t["if"];r=q.program(10,x,C);r.hash={};r.fn=r;r.inverse=q.program(12,w,C);B=A.call(D,B,r);if(B||B===0){z+=B}z+="\n ";return z}function x(C,B){var z="",A;z+="\n \n ";return z}function w(C,B){var z="",A;z+="\n \n ";return z}u+="";i=t.name;j=i||v.name;if(typeof j===e){j=j.call(v,{hash:{}})}else{if(j===c){j=s.call(v,"name",{hash:{}})}}u+=d(j)+" | \n\n\n ";i=t.isBody;j=i||v.isBody;g=t["if"];r=q.program(1,p,y);r.hash={};r.fn=r;r.inverse=q.program(9,f,y);j=g.call(v,j,r);if(j||j===0){u+=j}u+="\n\n | \n";i=t.description;j=i||v.description;if(typeof j===e){j=j.call(v,{hash:{}})}else{if(j===c){j=s.call(v,"description",{hash:{}})}}if(j||j===0){u+=j}u+=" | \n";i=t.paramType;j=i||v.paramType;if(typeof j===e){j=j.call(v,{hash:{}})}else{if(j===c){j=s.call(v,"paramType",{hash:{}})}}if(j||j===0){u+=j}u+=' | \n\n \n | \n\n';return u})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param_list=b(function(h,v,t,m,x){t=t||h.helpers;var u="",k,g,j,r,q=this,e="function",s=t.helperMissing,c=void 0,d=this.escapeExpression;function p(z,y){return"\n "}function o(C,B){var y="",A,z;y+="\n ";j=t.defaultValue;A=j||C.defaultValue;z=t["if"];r=q.program(4,n,B);r.hash={};r.fn=r;r.inverse=q.program(6,l,B);A=z.call(C,A,r);if(A||A===0){y+=A}y+="\n ";return y}function n(z,y){return"\n "}function l(z,y){return"\n \n "}function i(C,B){var y="",A,z;y+="\n ";j=t.isDefault;A=j||C.isDefault;z=t["if"];r=q.program(9,f,B);r.hash={};r.fn=r;r.inverse=q.program(11,w,B);A=z.call(C,A,r);if(A||A===0){y+=A}y+="\n ";return y}function f(B,A){var y="",z;y+="\n \n ";return y}function w(B,A){var y="",z;y+="\n \n ";return y}u+="";j=t.name;k=j||v.name;if(typeof k===e){k=k.call(v,{hash:{}})}else{if(k===c){k=s.call(v,"name",{hash:{}})}}u+=d(k)+" | \n\n \n | \n";j=t.description;k=j||v.description;if(typeof k===e){k=k.call(v,{hash:{}})}else{if(k===c){k=s.call(v,"description",{hash:{}})}}if(k||k===0){u+=k}u+=" | \n";j=t.paramType;k=j||v.paramType;if(typeof k===e){k=k.call(v,{hash:{}})}else{if(k===c){k=s.call(v,"paramType",{hash:{}})}}if(k||k===0){u+=k}u+=' | \n | \n';return u})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param_readonly=b(function(g,t,r,k,u){r=r||g.helpers;var s="",i,f,h,p,o=this,e="function",q=r.helperMissing,c=void 0,d=this.escapeExpression;function n(y,x){var v="",w;v+="\n \n ";return v}function m(z,y){var v="",x,w;v+="\n ";h=r.defaultValue;x=h||z.defaultValue;w=r["if"];p=o.program(4,l,y);p.hash={};p.fn=p;p.inverse=o.program(6,j,y);x=w.call(z,x,p);if(x||x===0){v+=x}v+="\n ";return v}function l(y,x){var v="",w;v+="\n ";h=r.defaultValue;w=h||y.defaultValue;if(typeof w===e){w=w.call(y,{hash:{}})}else{if(w===c){w=q.call(y,"defaultValue",{hash:{}})}}v+=d(w)+"\n ";return v}function j(w,v){return"\n (empty)\n "}s+="";h=r.name;i=h||t.name;if(typeof i===e){i=i.call(t,{hash:{}})}else{if(i===c){i=q.call(t,"name",{hash:{}})}}s+=d(i)+" | \n\n ";h=r.isBody;i=h||t.isBody;f=r["if"];p=o.program(1,n,u);p.hash={};p.fn=p;p.inverse=o.program(3,m,u);i=f.call(t,i,p);if(i||i===0){s+=i}s+="\n | \n";h=r.description;i=h||t.description;if(typeof i===e){i=i.call(t,{hash:{}})}else{if(i===c){i=q.call(t,"description",{hash:{}})}}if(i||i===0){s+=i}s+=" | \n";h=r.paramType;i=h||t.paramType;if(typeof i===e){i=i.call(t,{hash:{}})}else{if(i===c){i=q.call(t,"paramType",{hash:{}})}}if(i||i===0){s+=i}s+=' | \n | \n';return s})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param_readonly_required=b(function(g,t,r,k,u){r=r||g.helpers;var s="",i,f,h,p,o=this,e="function",q=r.helperMissing,c=void 0,d=this.escapeExpression;function n(y,x){var v="",w;v+="\n \n ";return v}function m(z,y){var v="",x,w;v+="\n ";h=r.defaultValue;x=h||z.defaultValue;w=r["if"];p=o.program(4,l,y);p.hash={};p.fn=p;p.inverse=o.program(6,j,y);x=w.call(z,x,p);if(x||x===0){v+=x}v+="\n ";return v}function l(y,x){var v="",w;v+="\n ";h=r.defaultValue;w=h||y.defaultValue;if(typeof w===e){w=w.call(y,{hash:{}})}else{if(w===c){w=q.call(y,"defaultValue",{hash:{}})}}v+=d(w)+"\n ";return v}function j(w,v){return"\n (empty)\n "}s+="";h=r.name;i=h||t.name;if(typeof i===e){i=i.call(t,{hash:{}})}else{if(i===c){i=q.call(t,"name",{hash:{}})}}s+=d(i)+" | \n\n ";h=r.isBody;i=h||t.isBody;f=r["if"];p=o.program(1,n,u);p.hash={};p.fn=p;p.inverse=o.program(3,m,u);i=f.call(t,i,p);if(i||i===0){s+=i}s+="\n | \n";h=r.description;i=h||t.description;if(typeof i===e){i=i.call(t,{hash:{}})}else{if(i===c){i=q.call(t,"description",{hash:{}})}}if(i||i===0){s+=i}s+=" | \n";h=r.paramType;i=h||t.paramType;if(typeof i===e){i=i.call(t,{hash:{}})}else{if(i===c){i=q.call(t,"paramType",{hash:{}})}}if(i||i===0){s+=i}s+=' | \n | \n';return s})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param_required=b(function(h,v,t,m,A){t=t||h.helpers;var u="",j,g,i,r,q=this,e="function",s=t.helperMissing,c=void 0,d=this.escapeExpression;function p(F,E){var B="",D,C;B+="\n ";i=t.isFile;D=i||F.isFile;C=t["if"];r=q.program(2,o,E);r.hash={};r.fn=r;r.inverse=q.program(4,n,E);D=C.call(F,D,r);if(D||D===0){B+=D}B+="\n ";return B}function o(E,D){var B="",C;B+='\n \n ";return B}function n(F,E){var B="",D,C;B+="\n ";i=t.defaultValue;D=i||F.defaultValue;C=t["if"];r=q.program(5,l,E);r.hash={};r.fn=r;r.inverse=q.program(7,k,E);D=C.call(F,D,r);if(D||D===0){B+=D}B+="\n ";return B}function l(E,D){var B="",C;B+="\n \n ";return B}function k(E,D){var B="",C;B+="\n \n
\n \n ';return B}function f(F,E){var B="",D,C;B+="\n ";i=t.isFile;D=i||F.isFile;C=t["if"];r=q.program(10,z,E);r.hash={};r.fn=r;r.inverse=q.program(12,y,E);D=C.call(F,D,r);if(D||D===0){B+=D}B+="\n ";return B}function z(E,D){var B="",C;B+="\n \n ";return B}function y(F,E){var B="",D,C;B+="\n ";i=t.defaultValue;D=i||F.defaultValue;C=t["if"];r=q.program(13,x,E);r.hash={};r.fn=r;r.inverse=q.program(15,w,E);D=C.call(F,D,r);if(D||D===0){B+=D}B+="\n ";return B}function x(E,D){var B="",C;B+="\n \n ";return B}function w(E,D){var B="",C;B+="\n \n ";return B}u+="";i=t.name;j=i||v.name;if(typeof j===e){j=j.call(v,{hash:{}})}else{if(j===c){j=s.call(v,"name",{hash:{}})}}u+=d(j)+" | \n\n ";i=t.isBody;j=i||v.isBody;g=t["if"];r=q.program(1,p,A);r.hash={};r.fn=r;r.inverse=q.program(9,f,A);j=g.call(v,j,r);if(j||j===0){u+=j}u+="\n | \n\n ";i=t.description;j=i||v.description;if(typeof j===e){j=j.call(v,{hash:{}})}else{if(j===c){j=s.call(v,"description",{hash:{}})}}if(j||j===0){u+=j}u+="\n | \n";i=t.paramType;j=i||v.paramType;if(typeof j===e){j=j.call(v,{hash:{}})}else{if(j===c){j=s.call(v,"paramType",{hash:{}})}}if(j||j===0){u+=j}u+=' | \n | \n';return u})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.resource=b(function(e,n,d,l,k){d=d||e.helpers;var i="",c,h,o=this,f="function",m=d.helperMissing,g=void 0,j=this.escapeExpression;i+="\n\n";return i})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.signature=b(function(e,n,d,l,k){d=d||e.helpers;var i="",c,h,o=this,f="function",m=d.helperMissing,g=void 0,j=this.escapeExpression;i+='\n
\n
\n\n
\n
\n ';h=d.signature;c=h||n.signature;if(typeof c===f){c=c.call(n,{hash:{}})}else{if(c===g){c=m.call(n,"signature",{hash:{}})}}if(c||c===0){i+=c}i+='\n
\n\n
\n
';h=d.sampleJSON;c=h||n.sampleJSON;if(typeof c===f){c=c.call(n,{hash:{}})}else{if(c===g){c=m.call(n,"sampleJSON",{hash:{}})}}i+=j(c)+'
\n
\n
\n
\n\n';return i})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.status_code=b(function(e,n,d,l,k){d=d||e.helpers;var i="",c,h,o=this,f="function",m=d.helperMissing,g=void 0,j=this.escapeExpression;i+="
";h=d.code;c=h||n.code;if(typeof c===f){c=c.call(n,{hash:{}})}else{if(c===g){c=m.call(n,"code",{hash:{}})}}i+=j(c)+" | \n
";h=d.reason;c=h||n.reason;if(typeof c===f){c=c.call(n,{hash:{}})}else{if(c===g){c=m.call(n,"reason",{hash:{}})}}if(c||c===0){i+=c}i+=" | \n\n";return i})})();(function(){var f,b,h,c,e,j,k,i,a,g={}.hasOwnProperty,d=function(o,m){for(var l in m){if(g.call(m,l)){o[l]=m[l]}}function n(){this.constructor=o}n.prototype=m.prototype;o.prototype=new n();o.__super__=m.prototype;return o};a=(function(m){d(l,m);function l(){return l.__super__.constructor.apply(this,arguments)}l.prototype.dom_id="swagger_ui";l.prototype.options=null;l.prototype.api=null;l.prototype.headerView=null;l.prototype.mainView=null;l.prototype.initialize=function(n){var o=this;if(n==null){n={}}if(n.dom_id!=null){this.dom_id=n.dom_id;delete n.dom_id}if(!($("#"+this.dom_id)!=null)){$("body").append('
')}this.options=n;this.options.success=function(){return o.render()};this.options.progress=function(p){return o.showMessage(p)};this.options.failure=function(p){return o.onLoadFailure(p)};this.headerView=new b({el:$("#header")});return this.headerView.on("update-swagger-ui",function(p){return o.updateSwaggerUi(p)})};l.prototype.updateSwaggerUi=function(n){this.options.discoveryUrl=n.discoveryUrl;this.options.apiKey=n.apiKey;return this.load()};l.prototype.load=function(){var n;if((n=this.mainView)!=null){n.clear()}this.headerView.update(this.options.discoveryUrl,this.options.apiKey);return this.api=new SwaggerApi(this.options)};l.prototype.render=function(){var n=this;this.showMessage("Finished Loading Resource Information. Rendering Swagger UI...");this.mainView=new h({model:this.api,el:$("#"+this.dom_id)}).render();this.showMessage();switch(this.options.docExpansion){case"full":Docs.expandOperationsForResource("");break;case"list":Docs.collapseOperationsForResource("")}if(this.options.onComplete){this.options.onComplete(this.api,this)}return setTimeout(function(){return Docs.shebang()},400)};l.prototype.showMessage=function(n){if(n==null){n=""}$("#message-bar").removeClass("message-fail");$("#message-bar").addClass("message-success");return $("#message-bar").html(n)};l.prototype.onLoadFailure=function(n){var o;if(n==null){n=""}$("#message-bar").removeClass("message-success");$("#message-bar").addClass("message-fail");o=$("#message-bar").html(n);if(this.options.onFailure!=null){this.options.onFailure(n)}return o};return l})(Backbone.Router);window.SwaggerUi=a;b=(function(m){d(l,m);function l(){return l.__super__.constructor.apply(this,arguments)}l.prototype.events={"click #show-pet-store-icon":"showPetStore","click #show-wordnik-dev-icon":"showWordnikDev","click #explore":"showCustom","keyup #input_baseUrl":"showCustomOnKeyup","keyup #input_apiKey":"showCustomOnKeyup"};l.prototype.initialize=function(){};l.prototype.showPetStore=function(n){return this.trigger("update-swagger-ui",{discoveryUrl:"http://petstore.swagger.wordnik.com/api/api-docs.json",apiKey:"special-key"})};l.prototype.showWordnikDev=function(n){return this.trigger("update-swagger-ui",{discoveryUrl:"http://api.wordnik.com/v4/resources.json",apiKey:""})};l.prototype.showCustomOnKeyup=function(n){if(n.keyCode===13){return this.showCustom()}};l.prototype.showCustom=function(n){if(n!=null){n.preventDefault()}return this.trigger("update-swagger-ui",{discoveryUrl:$("#input_baseUrl").val(),apiKey:$("#input_apiKey").val()})};l.prototype.update=function(o,p,n){if(n==null){n=false}$("#input_baseUrl").val(o);$("#input_apiKey").val(p);if(n){return this.trigger("update-swagger-ui",{discoveryUrl:o,apiKey:p})}};return l})(Backbone.View);h=(function(l){d(m,l);function m(){return m.__super__.constructor.apply(this,arguments)}m.prototype.initialize=function(){};m.prototype.render=function(){var q,p,n,o;$(this.el).html(Handlebars.templates.main(this.model));o=this.model.apisArray;for(p=0,n=o.length;p
=0;if(!y){this.model.isReadOnly=true}$(this.el).html(Handlebars.templates.operation(this.model));if(this.model.responseClassSignature&&this.model.responseClassSignature!=="string"){z={sampleJSON:this.model.responseSampleJSON,isParam:false,signature:this.model.responseClassSignature};u=new k({model:z,tagName:"div"});$(".model-signature",$(this.el)).append(u.render().el)}else{$(".model-signature",$(this.el)).html(this.model.responseClass)}n={isParam:false};if(this.model.supportedContentTypes){n.produces=this.model.supportedContentTypes}if(this.model.produces){n.produces=this.model.produces}x=new f({model:n});$(".content-type",$(this.el)).append(x.render().el);t=this.model.parameters;for(s=0,w=t.length;s0){Q[H.name]=H.value}}P=v.children().find('input[type~="file"]').size()!==0;J=false;L="application/json";if(this.model.consumes&&this.model.consumes.length>0){L=this.model.consumes[0]}else{z=this.model.parameters;for(u=0,S=z.length;u"+A+"");$(".response_throbber",$(this.el)).show();D={type:this.model.httpMethod,url:A,headers:q,data:F,contentType:L,dataType:"json",processData:false,error:function(T,U,o){return I.showErrorStatus(T,U,o)},success:function(o){return I.showResponse(o)},complete:function(o){return I.showCompleteStatus(o)}};G=$("td select[name=contentType]",$(this.el)).val();if(G){D.contentType=G}log("content type = "+D.contentType);if(!(D.data||(D.type==="GET"||D.type==="DELETE"))&&D.contentType===!"application/x-www-form-urlencoded"){D.contentType=false}log("content type is now = "+D.contentType);s=$(".content > .content-type > div > select[name=contentType]",$(this.el)).val();if(s){D.headers=D.headers!=null?D.headers:{};D.headers.accept=s}jQuery.ajax(D);return false}};l.prototype.hideResponse=function(n){if(n!=null){n.preventDefault()}$(".response",$(this.el)).slideUp();return $(".response_hider",$(this.el)).fadeOut()};l.prototype.showResponse=function(n){var o;o=JSON.stringify(n,null,"\t").replace(/\n/g,"
");return $(".response_body",$(this.el)).html(escape(o))};l.prototype.showErrorStatus=function(n){return this.showStatus(n)};l.prototype.showCompleteStatus=function(n){return this.showStatus(n)};l.prototype.formatXml=function(u){var q,t,o,v,A,w,p,n,y,z,s,r,x;n=/(>)(<)(\/*)/g;z=/[ ]*(.*)[ ]+\n/g;q=/(<.+>)(.+\n)/g;u=u.replace(n,"$1\n$2$3").replace(z,"$1\n").replace(q,"$1\n$2");p=0;t="";A=u.split("\n");o=0;v="other";y={"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};s=function(G){var C,B,E,I,F,D,H;D={single:Boolean(G.match(/<.+\/>/)),closing:Boolean(G.match(/<\/.+>/)),opening:Boolean(G.match(/<[^!?].*>/))};F=((function(){var J;J=[];for(E in D){H=D[E];if(H){J.push(E)}}return J})())[0];F=F===void 0?"other":F;C=v+"->"+F;v=F;I="";o+=y[C];I=((function(){var K,L,J;J=[];for(B=K=0,L=o;0<=L?KL;B=0<=L?++K:--K){J.push(" ")}return J})()).join("");if(C==="opening->closing"){return t=t.substr(0,t.length-1)+G+"\n"}else{return t+=I+G+"\n"}};for(r=0,x=A.length;r").text(JSON.stringify(JSON.parse(q.responseText),null,2));r=$('').append(p)}catch(n){p=$("").text(this.formatXml(q.responseText));r=$('').append(p)}o=r;$(".response_code",$(this.el)).html(""+q.status+"
");$(".response_body",$(this.el)).html(o);$(".response_headers",$(this.el)).html(""+q.getAllResponseHeaders()+"
");$(".response",$(this.el)).slideDown();$(".response_hider",$(this.el)).show();$(".response_throbber",$(this.el)).hide();return hljs.highlightBlock($(".response_body",$(this.el))[0])};l.prototype.toggleOperationContent=function(){var n;n=$("#"+Docs.escapeResourceName(this.model.resourceName)+"_"+this.model.nickname+"_"+this.model.httpMethod+"_"+this.model.number+"_content");if(n.is(":visible")){return Docs.collapseOperation(n)}else{return Docs.expandOperation(n)}};return l})(Backbone.View);i=(function(m){d(l,m);function l(){return l.__super__.constructor.apply(this,arguments)}l.prototype.initialize=function(){};l.prototype.render=function(){var n;n=this.template();$(this.el).html(n(this.model));return this};l.prototype.template=function(){return Handlebars.templates.status_code};return l})(Backbone.View);e=(function(m){d(l,m);function l(){return l.__super__.constructor.apply(this,arguments)}l.prototype.initialize=function(){};l.prototype.render=function(){var q,o,n,r,p;if(this.model.paramType==="body"){this.model.isBody=true}if(this.model.dataType==="file"){this.model.isFile=true}p=this.template();$(this.el).html(p(this.model));n={sampleJSON:this.model.sampleJSON,isParam:true,signature:this.model.signature};if(this.model.sampleJSON){r=new k({model:n,tagName:"div"});$(".model-signature",$(this.el)).append(r.render().el)}else{$(".model-signature",$(this.el)).html(this.model.signature)}q={isParam:false};if(this.model.supportedContentTypes){q.produces=this.model.supportedContentTypes}if(this.model.produces){q.produces=this.model.produces}o=new f({model:q});$(".content-type",$(this.el)).append(o.render().el);return this};l.prototype.template=function(){if(this.model.isList){return Handlebars.templates.param_list}else{if(this.options.readOnly){if(this.model.required){return Handlebars.templates.param_readonly_required}else{return Handlebars.templates.param_readonly}}else{if(this.model.required){return Handlebars.templates.param_required}else{return Handlebars.templates.param}}}};return l})(Backbone.View);k=(function(m){d(l,m);function l(){return l.__super__.constructor.apply(this,arguments)}l.prototype.events={"click a.description-link":"switchToDescription","click a.snippet-link":"switchToSnippet","mousedown .snippet":"snippetToTextArea"};l.prototype.initialize=function(){};l.prototype.render=function(){var n;n=this.template();$(this.el).html(n(this.model));this.switchToDescription();this.isParam=this.model.isParam;if(this.isParam){$(".notice",$(this.el)).text("Click to set as parameter value")}return this};l.prototype.template=function(){return Handlebars.templates.signature};l.prototype.switchToDescription=function(n){if(n!=null){n.preventDefault()}$(".snippet",$(this.el)).hide();$(".description",$(this.el)).show();$(".description-link",$(this.el)).addClass("selected");return $(".snippet-link",$(this.el)).removeClass("selected")};l.prototype.switchToSnippet=function(n){if(n!=null){n.preventDefault()}$(".description",$(this.el)).hide();$(".snippet",$(this.el)).show();$(".snippet-link",$(this.el)).addClass("selected");return $(".description-link",$(this.el)).removeClass("selected")};l.prototype.snippetToTextArea=function(n){var o;if(this.isParam){if(n!=null){n.preventDefault()}o=$("textarea",$(this.el.parentNode.parentNode.parentNode));if($.trim(o.val())===""){return o.val(this.model.sampleJSON)}}};return l})(Backbone.View);f=(function(l){d(m,l);function m(){return m.__super__.constructor.apply(this,arguments)}m.prototype.initialize=function(){};m.prototype.render=function(){var n;n=this.template();$(this.el).html(n(this.model));this.isParam=this.model.isParam;if(this.isParam){$("label[for=contentType]",$(this.el)).text("Parameter content type:")}else{$("label[for=contentType]",$(this.el)).text("Response Content Type")}return this};m.prototype.template=function(){return Handlebars.templates.content_type};return m})(Backbone.View)}).call(this);
\ No newline at end of file
+$(function(){$.fn.vAlign=function(){return this.each(function(c){var a=$(this).height();var d=$(this).parent().height();var b=(d-a)/2;$(this).css("margin-top",b)})};$.fn.stretchFormtasticInputWidthToParent=function(){return this.each(function(b){var d=$(this).closest("form").innerWidth();var c=parseInt($(this).closest("form").css("padding-left"),10)+parseInt($(this).closest("form").css("padding-right"),10);var a=parseInt($(this).css("padding-left"),10)+parseInt($(this).css("padding-right"),10);$(this).css("width",d-c-a)})};$("form.formtastic li.string input, form.formtastic textarea").stretchFormtasticInputWidthToParent();$("ul.downplayed li div.content p").vAlign();$("form.sandbox").submit(function(){var a=true;$(this).find("input.required").each(function(){$(this).removeClass("error");if($(this).val()==""){$(this).addClass("error");$(this).wiggle();a=false}});return a})});function clippyCopiedCallback(b){$("#api_key_copied").fadeIn().delay(1000).fadeOut()}function log(){if(window.console){console.log.apply(console,arguments)}}if(Function.prototype.bind&&console&&typeof console.log=="object"){["log","info","warn","error","assert","dir","clear","profile","profileEnd"].forEach(function(a){console[a]=this.bind(console[a],console)},Function.prototype.call)}var Docs={shebang:function(){var b=$.param.fragment().split("/");b.shift();switch(b.length){case 1:var d="resource_"+b[0];Docs.expandEndpointListForResource(b[0]);$("#"+d).slideto({highlight:false});break;case 2:Docs.expandEndpointListForResource(b[0]);$("#"+d).slideto({highlight:false});var c=b.join("_");var a=c+"_content";Docs.expandOperation($("#"+a));$("#"+c).slideto({highlight:false});break}},toggleEndpointListForResource:function(b){var a=$("li#resource_"+Docs.escapeResourceName(b)+" ul.endpoints");if(a.is(":visible")){Docs.collapseEndpointListForResource(b)}else{Docs.expandEndpointListForResource(b)}},expandEndpointListForResource:function(b){var b=Docs.escapeResourceName(b);if(b==""){$(".resource ul.endpoints").slideDown();return}$("li#resource_"+b).addClass("active");var a=$("li#resource_"+b+" ul.endpoints");a.slideDown()},collapseEndpointListForResource:function(b){var b=Docs.escapeResourceName(b);$("li#resource_"+b).removeClass("active");var a=$("li#resource_"+b+" ul.endpoints");a.slideUp()},expandOperationsForResource:function(a){Docs.expandEndpointListForResource(a);if(a==""){$(".resource ul.endpoints li.operation div.content").slideDown();return}$("li#resource_"+Docs.escapeResourceName(a)+" li.operation div.content").each(function(){Docs.expandOperation($(this))})},collapseOperationsForResource:function(a){Docs.expandEndpointListForResource(a);$("li#resource_"+Docs.escapeResourceName(a)+" li.operation div.content").each(function(){Docs.collapseOperation($(this))})},escapeResourceName:function(a){return a.replace(/[!"#$%&'()*+,.\/:;<=>?@\[\\\]\^`{|}~]/g,"\\$&")},expandOperation:function(a){a.slideDown()},collapseOperation:function(a){a.slideUp()}};(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.content_type=b(function(g,p,f,n,m){f=f||g.helpers;var l="",c,s,k,j,q=this,h="function",o=f.helperMissing,i=void 0;function e(x,w){var t="",v,u;t+="\n ";k=f.produces;v=k||x.produces;u=f.each;j=q.program(2,d,w);j.hash={};j.fn=j;j.inverse=q.noop;v=u.call(x,v,j);if(v||v===0){t+=v}t+="\n";return t}function d(w,v){var t="",u;t+='\n \n ";return t}function r(u,t){return'\n \n'}l+='\n\n";return l})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.main=b(function(f,p,e,n,m){e=e||f.helpers;var k="",c,r,j,i,q=this,g="function",o=e.helperMissing,h=void 0,l=this.escapeExpression;function d(v,u){var s="",t;s+='\n , api version: ';j=e.apiVersion;t=j||v.apiVersion;if(typeof t===g){t=t.call(v,{hash:{}})}else{if(t===h){t=o.call(v,"apiVersion",{hash:{}})}}s+=l(t)+"\n ";return s}k+="\n\n";return k})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.operation=b(function(h,u,s,m,w){s=s||h.helpers;var t="",j,g,i,q,p=this,e="function",r=s.helperMissing,c=void 0,d=this.escapeExpression;function o(A,z){var x="",y;x+="\n Implementation Notes
\n ";i=s.notes;y=i||A.notes;if(typeof y===e){y=y.call(A,{hash:{}})}else{if(y===c){y=r.call(A,"notes",{hash:{}})}}if(y||y===0){x+=y}x+="
\n ";return x}function n(y,x){return'\n Response Class
\n
\n
\n \n '}function l(y,x){return'\n Parameters
\n \n \n \n | Parameter | \n Value | \n Description | \n Parameter Type | \n Data Type | \n
\n \n \n\n \n
\n '}function k(y,x){return"\n \n Error Status Codes
\n \n \n \n | HTTP Status Code | \n Reason | \n
\n \n \n \n \n
\n "}function f(y,x){return"\n "}function v(y,x){return"\n \n "}t+="\n \n - \n \n
\n ";i=s.notes;j=i||u.notes;g=s["if"];q=p.program(1,o,w);q.hash={};q.fn=q;q.inverse=p.noop;j=g.call(u,j,q);if(j||j===0){t+=j}t+="\n ";i=s.responseClass;j=i||u.responseClass;g=s["if"];q=p.program(3,n,w);q.hash={};q.fn=q;q.inverse=p.noop;j=g.call(u,j,q);if(j||j===0){t+=j}t+="\n
\n
\n
Request URL
\n
\n
Response Body
\n
\n
Response Code
\n
\n
Response Headers
\n \n
\n
\n \n
\n";return t})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param=b(function(h,v,t,m,y){t=t||h.helpers;var u="",j,g,i,r,q=this,e="function",s=t.helperMissing,c=void 0,d=this.escapeExpression;function p(D,C){var z="",B,A;z+="\n ";i=t.isFile;B=i||D.isFile;A=t["if"];r=q.program(2,o,C);r.hash={};r.fn=r;r.inverse=q.program(4,n,C);B=A.call(D,B,r);if(B||B===0){z+=B}z+="\n ";return z}function o(C,B){var z="",A;z+='\n \n ";return z}function n(D,C){var z="",B,A;z+="\n ";i=t.defaultValue;B=i||D.defaultValue;A=t["if"];r=q.program(5,l,C);r.hash={};r.fn=r;r.inverse=q.program(7,k,C);B=A.call(D,B,r);if(B||B===0){z+=B}z+="\n ";return z}function l(C,B){var z="",A;z+="\n \n ";return z}function k(C,B){var z="",A;z+="\n \n
\n \n ';return z}function f(D,C){var z="",B,A;z+="\n ";i=t.defaultValue;B=i||D.defaultValue;A=t["if"];r=q.program(10,x,C);r.hash={};r.fn=r;r.inverse=q.program(12,w,C);B=A.call(D,B,r);if(B||B===0){z+=B}z+="\n ";return z}function x(C,B){var z="",A;z+="\n \n ";return z}function w(C,B){var z="",A;z+="\n \n ";return z}u+="";i=t.name;j=i||v.name;if(typeof j===e){j=j.call(v,{hash:{}})}else{if(j===c){j=s.call(v,"name",{hash:{}})}}u+=d(j)+" | \n\n\n ";i=t.isBody;j=i||v.isBody;g=t["if"];r=q.program(1,p,y);r.hash={};r.fn=r;r.inverse=q.program(9,f,y);j=g.call(v,j,r);if(j||j===0){u+=j}u+="\n\n | \n";i=t.description;j=i||v.description;if(typeof j===e){j=j.call(v,{hash:{}})}else{if(j===c){j=s.call(v,"description",{hash:{}})}}if(j||j===0){u+=j}u+=" | \n";i=t.paramType;j=i||v.paramType;if(typeof j===e){j=j.call(v,{hash:{}})}else{if(j===c){j=s.call(v,"paramType",{hash:{}})}}if(j||j===0){u+=j}u+=' | \n\n \n | \n';return u})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param_list=b(function(h,v,t,m,x){t=t||h.helpers;var u="",k,g,j,r,q=this,e="function",s=t.helperMissing,c=void 0,d=this.escapeExpression;function p(z,y){return"\n "}function o(C,B){var y="",A,z;y+="\n ";j=t.defaultValue;A=j||C.defaultValue;z=t["if"];r=q.program(4,n,B);r.hash={};r.fn=r;r.inverse=q.program(6,l,B);A=z.call(C,A,r);if(A||A===0){y+=A}y+="\n ";return y}function n(z,y){return"\n "}function l(z,y){return"\n \n "}function i(C,B){var y="",A,z;y+="\n ";j=t.isDefault;A=j||C.isDefault;z=t["if"];r=q.program(9,f,B);r.hash={};r.fn=r;r.inverse=q.program(11,w,B);A=z.call(C,A,r);if(A||A===0){y+=A}y+="\n ";return y}function f(B,A){var y="",z;y+="\n \n ";return y}function w(B,A){var y="",z;y+="\n \n ";return y}u+="";j=t.name;k=j||v.name;if(typeof k===e){k=k.call(v,{hash:{}})}else{if(k===c){k=s.call(v,"name",{hash:{}})}}u+=d(k)+" | \n\n \n | \n";j=t.description;k=j||v.description;if(typeof k===e){k=k.call(v,{hash:{}})}else{if(k===c){k=s.call(v,"description",{hash:{}})}}if(k||k===0){u+=k}u+=" | \n";j=t.paramType;k=j||v.paramType;if(typeof k===e){k=k.call(v,{hash:{}})}else{if(k===c){k=s.call(v,"paramType",{hash:{}})}}if(k||k===0){u+=k}u+=' | \n | \n';return u})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param_readonly=b(function(g,t,r,k,u){r=r||g.helpers;var s="",i,f,h,p,o=this,e="function",q=r.helperMissing,c=void 0,d=this.escapeExpression;function n(y,x){var v="",w;v+="\n \n ";return v}function m(z,y){var v="",x,w;v+="\n ";h=r.defaultValue;x=h||z.defaultValue;w=r["if"];p=o.program(4,l,y);p.hash={};p.fn=p;p.inverse=o.program(6,j,y);x=w.call(z,x,p);if(x||x===0){v+=x}v+="\n ";return v}function l(y,x){var v="",w;v+="\n ";h=r.defaultValue;w=h||y.defaultValue;if(typeof w===e){w=w.call(y,{hash:{}})}else{if(w===c){w=q.call(y,"defaultValue",{hash:{}})}}v+=d(w)+"\n ";return v}function j(w,v){return"\n (empty)\n "}s+="";h=r.name;i=h||t.name;if(typeof i===e){i=i.call(t,{hash:{}})}else{if(i===c){i=q.call(t,"name",{hash:{}})}}s+=d(i)+" | \n\n ";h=r.isBody;i=h||t.isBody;f=r["if"];p=o.program(1,n,u);p.hash={};p.fn=p;p.inverse=o.program(3,m,u);i=f.call(t,i,p);if(i||i===0){s+=i}s+="\n | \n";h=r.description;i=h||t.description;if(typeof i===e){i=i.call(t,{hash:{}})}else{if(i===c){i=q.call(t,"description",{hash:{}})}}if(i||i===0){s+=i}s+=" | \n";h=r.paramType;i=h||t.paramType;if(typeof i===e){i=i.call(t,{hash:{}})}else{if(i===c){i=q.call(t,"paramType",{hash:{}})}}if(i||i===0){s+=i}s+=' | \n | \n';return s})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param_readonly_required=b(function(g,t,r,k,u){r=r||g.helpers;var s="",i,f,h,p,o=this,e="function",q=r.helperMissing,c=void 0,d=this.escapeExpression;function n(y,x){var v="",w;v+="\n \n ";return v}function m(z,y){var v="",x,w;v+="\n ";h=r.defaultValue;x=h||z.defaultValue;w=r["if"];p=o.program(4,l,y);p.hash={};p.fn=p;p.inverse=o.program(6,j,y);x=w.call(z,x,p);if(x||x===0){v+=x}v+="\n ";return v}function l(y,x){var v="",w;v+="\n ";h=r.defaultValue;w=h||y.defaultValue;if(typeof w===e){w=w.call(y,{hash:{}})}else{if(w===c){w=q.call(y,"defaultValue",{hash:{}})}}v+=d(w)+"\n ";return v}function j(w,v){return"\n (empty)\n "}s+="";h=r.name;i=h||t.name;if(typeof i===e){i=i.call(t,{hash:{}})}else{if(i===c){i=q.call(t,"name",{hash:{}})}}s+=d(i)+" | \n\n ";h=r.isBody;i=h||t.isBody;f=r["if"];p=o.program(1,n,u);p.hash={};p.fn=p;p.inverse=o.program(3,m,u);i=f.call(t,i,p);if(i||i===0){s+=i}s+="\n | \n";h=r.description;i=h||t.description;if(typeof i===e){i=i.call(t,{hash:{}})}else{if(i===c){i=q.call(t,"description",{hash:{}})}}if(i||i===0){s+=i}s+=" | \n";h=r.paramType;i=h||t.paramType;if(typeof i===e){i=i.call(t,{hash:{}})}else{if(i===c){i=q.call(t,"paramType",{hash:{}})}}if(i||i===0){s+=i}s+=' | \n | \n';return s})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param_required=b(function(h,v,t,m,A){t=t||h.helpers;var u="",j,g,i,r,q=this,e="function",s=t.helperMissing,c=void 0,d=this.escapeExpression;function p(F,E){var B="",D,C;B+="\n ";i=t.isFile;D=i||F.isFile;C=t["if"];r=q.program(2,o,E);r.hash={};r.fn=r;r.inverse=q.program(4,n,E);D=C.call(F,D,r);if(D||D===0){B+=D}B+="\n ";return B}function o(E,D){var B="",C;B+='\n \n ";return B}function n(F,E){var B="",D,C;B+="\n ";i=t.defaultValue;D=i||F.defaultValue;C=t["if"];r=q.program(5,l,E);r.hash={};r.fn=r;r.inverse=q.program(7,k,E);D=C.call(F,D,r);if(D||D===0){B+=D}B+="\n ";return B}function l(E,D){var B="",C;B+="\n \n ";return B}function k(E,D){var B="",C;B+="\n \n
\n \n ';return B}function f(F,E){var B="",D,C;B+="\n ";i=t.isFile;D=i||F.isFile;C=t["if"];r=q.program(10,z,E);r.hash={};r.fn=r;r.inverse=q.program(12,y,E);D=C.call(F,D,r);if(D||D===0){B+=D}B+="\n ";return B}function z(E,D){var B="",C;B+="\n \n ";return B}function y(F,E){var B="",D,C;B+="\n ";i=t.defaultValue;D=i||F.defaultValue;C=t["if"];r=q.program(13,x,E);r.hash={};r.fn=r;r.inverse=q.program(15,w,E);D=C.call(F,D,r);if(D||D===0){B+=D}B+="\n ";return B}function x(E,D){var B="",C;B+="\n \n ";return B}function w(E,D){var B="",C;B+="\n \n ";return B}u+="";i=t.name;j=i||v.name;if(typeof j===e){j=j.call(v,{hash:{}})}else{if(j===c){j=s.call(v,"name",{hash:{}})}}u+=d(j)+" | \n\n ";i=t.isBody;j=i||v.isBody;g=t["if"];r=q.program(1,p,A);r.hash={};r.fn=r;r.inverse=q.program(9,f,A);j=g.call(v,j,r);if(j||j===0){u+=j}u+="\n | \n\n ";i=t.description;j=i||v.description;if(typeof j===e){j=j.call(v,{hash:{}})}else{if(j===c){j=s.call(v,"description",{hash:{}})}}if(j||j===0){u+=j}u+="\n | \n";i=t.paramType;j=i||v.paramType;if(typeof j===e){j=j.call(v,{hash:{}})}else{if(j===c){j=s.call(v,"paramType",{hash:{}})}}if(j||j===0){u+=j}u+=' | \n | \n';return u})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.parameter_content_type=b(function(g,p,f,n,m){f=f||g.helpers;var l="",c,s,k,j,q=this,h="function",o=f.helperMissing,i=void 0;function e(x,w){var t="",v,u;t+="\n ";k=f.consumes;v=k||x.consumes;u=f.each;j=q.program(2,d,w);j.hash={};j.fn=j;j.inverse=q.noop;v=u.call(x,v,j);if(v||v===0){t+=v}t+="\n";return t}function d(w,v){var t="",u;t+='\n \n ";return t}function r(u,t){return'\n \n'}l+='\n\n";return l})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.resource=b(function(e,n,d,l,k){d=d||e.helpers;var i="",c,h,o=this,f="function",m=d.helperMissing,g=void 0,j=this.escapeExpression;i+="\n\n";return i})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.response_content_type=b(function(g,p,f,n,m){f=f||g.helpers;var l="",c,s,k,j,q=this,h="function",o=f.helperMissing,i=void 0;function e(x,w){var t="",v,u;t+="\n ";k=f.produces;v=k||x.produces;u=f.each;j=q.program(2,d,w);j.hash={};j.fn=j;j.inverse=q.noop;v=u.call(x,v,j);if(v||v===0){t+=v}t+="\n";return t}function d(w,v){var t="",u;t+='\n \n ";return t}function r(u,t){return'\n \n'}l+='\n\n";return l})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.signature=b(function(e,n,d,l,k){d=d||e.helpers;var i="",c,h,o=this,f="function",m=d.helperMissing,g=void 0,j=this.escapeExpression;i+='\n
\n
\n\n
\n
\n ';h=d.signature;c=h||n.signature;if(typeof c===f){c=c.call(n,{hash:{}})}else{if(c===g){c=m.call(n,"signature",{hash:{}})}}if(c||c===0){i+=c}i+='\n
\n\n
\n
';h=d.sampleJSON;c=h||n.sampleJSON;if(typeof c===f){c=c.call(n,{hash:{}})}else{if(c===g){c=m.call(n,"sampleJSON",{hash:{}})}}i+=j(c)+'
\n
\n
\n
\n\n';return i})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.status_code=b(function(e,n,d,l,k){d=d||e.helpers;var i="",c,h,o=this,f="function",m=d.helperMissing,g=void 0,j=this.escapeExpression;i+="
";h=d.code;c=h||n.code;if(typeof c===f){c=c.call(n,{hash:{}})}else{if(c===g){c=m.call(n,"code",{hash:{}})}}i+=j(c)+" | \n
";h=d.reason;c=h||n.reason;if(typeof c===f){c=c.call(n,{hash:{}})}else{if(c===g){c=m.call(n,"reason",{hash:{}})}}if(c||c===0){i+=c}i+=" | \n\n";return i})})();(function(){var g,c,i,d,m,f,k,a,l,j,b,h={}.hasOwnProperty,e=function(q,o){for(var n in o){if(h.call(o,n)){q[n]=o[n]}}function p(){this.constructor=q}p.prototype=o.prototype;q.prototype=new p();q.__super__=o.prototype;return q};b=(function(o){e(n,o);function n(){return n.__super__.constructor.apply(this,arguments)}n.prototype.dom_id="swagger_ui";n.prototype.options=null;n.prototype.api=null;n.prototype.headerView=null;n.prototype.mainView=null;n.prototype.initialize=function(p){var q=this;if(p==null){p={}}if(p.dom_id!=null){this.dom_id=p.dom_id;delete p.dom_id}if(!($("#"+this.dom_id)!=null)){$("body").append('
')}this.options=p;this.options.success=function(){return q.render()};this.options.progress=function(r){return q.showMessage(r)};this.options.failure=function(r){return q.onLoadFailure(r)};this.headerView=new c({el:$("#header")});return this.headerView.on("update-swagger-ui",function(r){return q.updateSwaggerUi(r)})};n.prototype.updateSwaggerUi=function(p){this.options.discoveryUrl=p.discoveryUrl;this.options.apiKey=p.apiKey;return this.load()};n.prototype.load=function(){var p;if((p=this.mainView)!=null){p.clear()}this.headerView.update(this.options.discoveryUrl,this.options.apiKey);return this.api=new SwaggerApi(this.options)};n.prototype.render=function(){var p=this;this.showMessage("Finished Loading Resource Information. Rendering Swagger UI...");this.mainView=new i({model:this.api,el:$("#"+this.dom_id)}).render();this.showMessage();switch(this.options.docExpansion){case"full":Docs.expandOperationsForResource("");break;case"list":Docs.collapseOperationsForResource("")}if(this.options.onComplete){this.options.onComplete(this.api,this)}return setTimeout(function(){return Docs.shebang()},400)};n.prototype.showMessage=function(p){if(p==null){p=""}$("#message-bar").removeClass("message-fail");$("#message-bar").addClass("message-success");return $("#message-bar").html(p)};n.prototype.onLoadFailure=function(p){var q;if(p==null){p=""}$("#message-bar").removeClass("message-success");$("#message-bar").addClass("message-fail");q=$("#message-bar").html(p);if(this.options.onFailure!=null){this.options.onFailure(p)}return q};return n})(Backbone.Router);window.SwaggerUi=b;c=(function(o){e(n,o);function n(){return n.__super__.constructor.apply(this,arguments)}n.prototype.events={"click #show-pet-store-icon":"showPetStore","click #show-wordnik-dev-icon":"showWordnikDev","click #explore":"showCustom","keyup #input_baseUrl":"showCustomOnKeyup","keyup #input_apiKey":"showCustomOnKeyup"};n.prototype.initialize=function(){};n.prototype.showPetStore=function(p){return this.trigger("update-swagger-ui",{discoveryUrl:"http://petstore.swagger.wordnik.com/api/api-docs.json",apiKey:"special-key"})};n.prototype.showWordnikDev=function(p){return this.trigger("update-swagger-ui",{discoveryUrl:"http://api.wordnik.com/v4/resources.json",apiKey:""})};n.prototype.showCustomOnKeyup=function(p){if(p.keyCode===13){return this.showCustom()}};n.prototype.showCustom=function(p){if(p!=null){p.preventDefault()}return this.trigger("update-swagger-ui",{discoveryUrl:$("#input_baseUrl").val(),apiKey:$("#input_apiKey").val()})};n.prototype.update=function(q,r,p){if(p==null){p=false}$("#input_baseUrl").val(q);$("#input_apiKey").val(r);if(p){return this.trigger("update-swagger-ui",{discoveryUrl:q,apiKey:r})}};return n})(Backbone.View);i=(function(n){e(o,n);function o(){return o.__super__.constructor.apply(this,arguments)}o.prototype.initialize=function(){};o.prototype.render=function(){var s,r,p,q;$(this.el).html(Handlebars.templates.main(this.model));q=this.model.apisArray;for(r=0,p=q.length;r
0){u[w.name]=w.value}}console.log(u);u.responseContentType=$("div select[name=responseContentType]",$(this.el)).val();u.requestContentType=$("div select[name=parameterContentType]",$(this.el)).val();return this.model["do"](u,this.showCompleteStatus,this.showErrorStatus,this)}};n.prototype.success=function(p,q){return q.showCompleteStatus(p)};n.prototype.hideResponse=function(p){if(p!=null){p.preventDefault()}$(".response",$(this.el)).slideUp();return $(".response_hider",$(this.el)).fadeOut()};n.prototype.showResponse=function(p){var q;q=JSON.stringify(p,null,"\t").replace(/\n/g,"
");return $(".response_body",$(this.el)).html(escape(q))};n.prototype.showErrorStatus=function(q,p){return p.showStatus(q)};n.prototype.showCompleteStatus=function(q,p){return p.showStatus(q)};n.prototype.formatXml=function(w){var s,v,q,x,C,y,r,p,A,B,u,t,z;p=/(>)(<)(\/*)/g;B=/[ ]*(.*)[ ]+\n/g;s=/(<.+>)(.+\n)/g;w=w.replace(p,"$1\n$2$3").replace(B,"$1\n").replace(s,"$1\n$2");r=0;v="";C=w.split("\n");q=0;x="other";A={"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};u=function(I){var E,D,G,K,H,F,J;F={single:Boolean(I.match(/<.+\/>/)),closing:Boolean(I.match(/<\/.+>/)),opening:Boolean(I.match(/<[^!?].*>/))};H=((function(){var L;L=[];for(G in F){J=F[G];if(J){L.push(G)}}return L})())[0];H=H===void 0?"other":H;E=x+"->"+H;x=H;K="";q+=A[E];K=((function(){var M,N,L;L=[];for(D=M=0,N=q;0<=N?MN;D=0<=N?++M:--M){L.push(" ")}return L})()).join("");if(E==="opening->closing"){return v=v.substr(0,v.length-1)+I+"\n"}else{return v+=K+I+"\n"}};for(t=0,z=C.length;t").text("no content");t=$('').append(r)}else{if(v.indexOf("application/json")===0){r=$("").text(JSON.stringify(JSON.parse(q),null,2));t=$('').append(r)}else{if(v.indexOf("application/xml")===0){r=$("").text(this.formatXml(q));t=$('').append(r)}else{if(v.indexOf("text/html")===0){r=$("").html(q);t=$('').append(r)}else{r=$("").text(q);t=$('').append(r)}}}}p=t;$(".request_url").html(""+s.request.url+"
");$(".response_code",$(this.el)).html(""+s.status+"
");$(".response_body",$(this.el)).html(p);$(".response_headers",$(this.el)).html(""+JSON.stringify(s.getHeaders())+"
");$(".response",$(this.el)).slideDown();$(".response_hider",$(this.el)).show();$(".response_throbber",$(this.el)).hide();return hljs.highlightBlock($(".response_body",$(this.el))[0])};n.prototype.toggleOperationContent=function(){var p;p=$("#"+Docs.escapeResourceName(this.model.resourceName)+"_"+this.model.nickname+"_"+this.model.method+"_"+this.model.number+"_content");if(p.is(":visible")){return Docs.collapseOperation(p)}else{return Docs.expandOperation(p)}};return n})(Backbone.View);j=(function(o){e(n,o);function n(){return n.__super__.constructor.apply(this,arguments)}n.prototype.initialize=function(){};n.prototype.render=function(){var p;p=this.template();$(this.el).html(p(this.model));return this};n.prototype.template=function(){return Handlebars.templates.status_code};return n})(Backbone.View);f=(function(o){e(n,o);function n(){return n.__super__.constructor.apply(this,arguments)}n.prototype.initialize=function(){};n.prototype.render=function(){var u,p,r,t,q,v,s;if(this.model.paramType==="body"){this.model.isBody=true}if(this.model.dataType==="file"){this.model.isFile=true}s=this.template();$(this.el).html(s(this.model));q={sampleJSON:this.model.sampleJSON,isParam:true,signature:this.model.signature};if(this.model.sampleJSON){v=new l({model:q,tagName:"div"});$(".model-signature",$(this.el)).append(v.render().el)}else{$(".model-signature",$(this.el)).html(this.model.signature)}p=false;if(this.model.isBody){p=true}u={isParam:p};u.consumes=this.model.consumes;if(p){r=new m({model:u});$(".parameter-content-type",$(this.el)).append(r.render().el)}else{t=new a({model:u});$(".response-content-type",$(this.el)).append(t.render().el)}return this};n.prototype.template=function(){if(this.model.isList){return Handlebars.templates.param_list}else{if(this.options.readOnly){if(this.model.required){return Handlebars.templates.param_readonly_required}else{return Handlebars.templates.param_readonly}}else{if(this.model.required){return Handlebars.templates.param_required}else{return Handlebars.templates.param}}}};return n})(Backbone.View);l=(function(o){e(n,o);function n(){return n.__super__.constructor.apply(this,arguments)}n.prototype.events={"click a.description-link":"switchToDescription","click a.snippet-link":"switchToSnippet","mousedown .snippet":"snippetToTextArea"};n.prototype.initialize=function(){};n.prototype.render=function(){var p;p=this.template();$(this.el).html(p(this.model));this.switchToDescription();this.isParam=this.model.isParam;if(this.isParam){$(".notice",$(this.el)).text("Click to set as parameter value")}return this};n.prototype.template=function(){return Handlebars.templates.signature};n.prototype.switchToDescription=function(p){if(p!=null){p.preventDefault()}$(".snippet",$(this.el)).hide();$(".description",$(this.el)).show();$(".description-link",$(this.el)).addClass("selected");return $(".snippet-link",$(this.el)).removeClass("selected")};n.prototype.switchToSnippet=function(p){if(p!=null){p.preventDefault()}$(".description",$(this.el)).hide();$(".snippet",$(this.el)).show();$(".snippet-link",$(this.el)).addClass("selected");return $(".description-link",$(this.el)).removeClass("selected")};n.prototype.snippetToTextArea=function(p){var q;if(this.isParam){if(p!=null){p.preventDefault()}q=$("textarea",$(this.el.parentNode.parentNode.parentNode));if($.trim(q.val())===""){return q.val(this.model.sampleJSON)}}};return n})(Backbone.View);g=(function(n){e(o,n);function o(){return o.__super__.constructor.apply(this,arguments)}o.prototype.initialize=function(){};o.prototype.render=function(){var p;p=this.template();$(this.el).html(p(this.model));$("label[for=contentType]",$(this.el)).text("Response Content Type");return this};o.prototype.template=function(){return Handlebars.templates.content_type};return o})(Backbone.View);a=(function(n){e(o,n);function o(){return o.__super__.constructor.apply(this,arguments)}o.prototype.initialize=function(){};o.prototype.render=function(){var p;p=this.template();$(this.el).html(p(this.model));$("label[for=responseContentType]",$(this.el)).text("Response Content Type");return this};o.prototype.template=function(){return Handlebars.templates.response_content_type};return o})(Backbone.View);m=(function(o){e(n,o);function n(){return n.__super__.constructor.apply(this,arguments)}n.prototype.initialize=function(){};n.prototype.render=function(){var p;p=this.template();$(this.el).html(p(this.model));$("label[for=parameterContentType]",$(this.el)).text("Parameter content type:");return this};n.prototype.template=function(){return Handlebars.templates.parameter_content_type};return n})(Backbone.View)}).call(this);
\ No newline at end of file
diff --git a/src/main/coffeescript/view/ContentTypeView.coffee b/src/main/coffeescript/view/ContentTypeView.coffee
index 4f113810..1c7a6515 100644
--- a/src/main/coffeescript/view/ContentTypeView.coffee
+++ b/src/main/coffeescript/view/ContentTypeView.coffee
@@ -5,12 +5,7 @@ class ContentTypeView extends Backbone.View
template = @template()
$(@el).html(template(@model))
- @isParam = @model.isParam
-
- if @isParam
- $('label[for=contentType]', $(@el)).text('Parameter content type:')
- else
- $('label[for=contentType]', $(@el)).text('Response Content Type')
+ $('label[for=contentType]', $(@el)).text('Response Content Type')
@
diff --git a/src/main/coffeescript/view/OperationView.coffee b/src/main/coffeescript/view/OperationView.coffee
index 44f794e3..a0d4e19b 100644
--- a/src/main/coffeescript/view/OperationView.coffee
+++ b/src/main/coffeescript/view/OperationView.coffee
@@ -9,7 +9,7 @@ class OperationView extends Backbone.View
initialize: ->
render: ->
- isMethodSubmissionSupported = jQuery.inArray(@model.httpMethod, @model.supportedSubmitMethods()) >= 0
+ isMethodSubmissionSupported = true #jQuery.inArray(@model.method, @model.supportedSubmitMethods) >= 0
@model.isReadOnly = true unless isMethodSubmissionSupported
$(@el).html(Handlebars.templates.operation(@model))
@@ -28,26 +28,23 @@ class OperationView extends Backbone.View
contentTypeModel =
isParam: false
- # support old syntax
- if @model.supportedContentTypes
- contentTypeModel.produces = @model.supportedContentTypes
+ contentTypeModel.consumes = @model.consumes
+ contentTypeModel.produces = @model.produces
- if @model.produces
- contentTypeModel.produces = @model.produces
-
- contentTypeView = new ContentTypeView({model: contentTypeModel})
- $('.content-type', $(@el)).append contentTypeView.render().el
+ responseContentTypeView = new ResponseContentTypeView({model: contentTypeModel})
+ $('.response-content-type', $(@el)).append responseContentTypeView.render().el
# Render each parameter
- @addParameter param for param in @model.parameters
+ @addParameter param, contentTypeModel.consumes for param in @model.parameters
# Render each response code
- @addStatusCode statusCode for statusCode in @model.errorResponses
+ @addStatusCode statusCode for statusCode in @model.responseMessages
@
- addParameter: (param) ->
+ addParameter: (param, consumes) ->
# Render a parameter
+ param.consumes = consumes
paramView = new ParameterView({model: param, tagName: 'tr', readOnly: @model.isReadOnly})
$('.operation-params', $(@el)).append paramView.render().el
@@ -71,104 +68,21 @@ class OperationView extends Backbone.View
# if error free submit it
if error_free
- map = {}
+ map = {parent: @}
for o in form.serializeArray()
if(o.value? && jQuery.trim(o.value).length > 0)
map[o.name] = o.value
- isFileUpload = form.children().find('input[type~="file"]').size() != 0
+ console.log map
- isFormPost = false
- consumes = "application/json"
- if @model.consumes and @model.consumes.length > 0
- # honor the consumes setting above everything else
- consumes = @model.consumes[0]
- else
- for o in @model.parameters
- if o.paramType == 'form'
- isFormPost = true
- consumes = false
+ map["responseContentType"] = $("div select[name=responseContentType]", $(@el)).val()
+ map["requestContentType"] = $("div select[name=parameterContentType]", $(@el)).val()
- if isFileUpload
- consumes = false
- else if @model.httpMethod.toLowerCase() == "post" and isFormPost is false
- consumes = "application/json"
+ @model.do(map, @showCompleteStatus, @showErrorStatus, @)
- if isFileUpload
- # requires HTML5 compatible browser
- bodyParam = new FormData()
+ success: (response, parent) ->
+ parent.showCompleteStatus response
- # add params except file
- for param in @model.parameters
- if (param.paramType is 'body' or 'form') and param.name isnt 'file' and param.name isnt 'File' and map[param.name]?
- bodyParam.append(param.name, map[param.name])
-
- # add files
- $.each form.children().find('input[type~="file"]'), (i, el) ->
- bodyParam.append($(el).attr('name'), el.files[0])
-
- console.log(bodyParam)
- else if isFormPost
- bodyParam = new FormData()
- for param in @model.parameters
- if map[param.name]?
- bodyParam.append(param.name, map[param.name])
- else
- bodyParam = null
- for param in @model.parameters
- if param.paramType is 'body'
- bodyParam = map[param.name]
-
- log "bodyParam = " + bodyParam
-
- headerParams = null
- invocationUrl =
- if @model.supportHeaderParams()
- headerParams = @model.getHeaderParams(map)
- @model.urlify(map, false)
- else
- @model.urlify(map, true)
-
- log 'submitting ' + invocationUrl
-
-
- $(".request_url", $(@el)).html "" + invocationUrl + "
"
- $(".response_throbber", $(@el)).show()
-
- obj =
- type: @model.httpMethod
- url: invocationUrl
- headers: headerParams
- data: bodyParam
- contentType: consumes
- dataType: 'json'
- processData: false
- error: (xhr, textStatus, error) =>
- @showErrorStatus(xhr, textStatus, error)
- success: (data) =>
- @showResponse(data)
- complete: (data) =>
- @showCompleteStatus(data)
-
- paramContentTypeField = $("td select[name=contentType]", $(@el)).val()
- if paramContentTypeField
- obj.contentType = paramContentTypeField
-
- log 'content type = ' + obj.contentType
-
- if not (obj.data or (obj.type is 'GET' or obj.type is 'DELETE')) and obj.contentType is not "application/x-www-form-urlencoded"
- obj.contentType = false
-
- log 'content type is now = ' + obj.contentType
-
- responseContentTypeField = $('.content > .content-type > div > select[name=contentType]', $(@el)).val()
- if responseContentTypeField
- obj.headers = if obj.headers? then obj.headers else {}
- obj.headers.accept = responseContentTypeField
-
- jQuery.ajax(obj)
- false
- # $.getJSON(invocationUrl, (r) => @showResponse(r)).complete((r) => @showCompleteStatus(r)).error (r) => @showErrorStatus(r)
# handler for hide response link
hideResponse: (e) ->
@@ -182,14 +96,13 @@ class OperationView extends Backbone.View
prettyJson = JSON.stringify(response, null, "\t").replace(/\n/g, "
")
$(".response_body", $(@el)).html escape(prettyJson)
-
# Show error from server
- showErrorStatus: (data) ->
- @showStatus data
+ showErrorStatus: (data, parent) ->
+ parent.showStatus data
# show the status codes
- showCompleteStatus: (data) ->
- @showStatus data
+ showCompleteStatus: (data, parent) ->
+ parent.showStatus data
# Adapted from http://stackoverflow.com/a/2893259/454004
formatXml: (xml) ->
@@ -252,21 +165,39 @@ class OperationView extends Backbone.View
# puts the response data in UI
showStatus: (data) ->
- try
- code = $('').text(JSON.stringify(JSON.parse(data.responseText), null, 2))
+ content = data.content.data
+ headers = data.getHeaders()
+
+ # if server is nice, and sends content-type back, we can use it
+ contentType = headers["Content-Type"]
+
+ if content == undefined
+ code = $('').text("no content")
pre = $('').append(code)
- catch error
- code = $('').text(@formatXml(data.responseText))
+ else if contentType.indexOf("application/json") == 0
+ code = $('').text(JSON.stringify(JSON.parse(content), null, 2))
+ pre = $('').append(code)
+ else if contentType.indexOf("application/xml") == 0
+ code = $('').text(@formatXml(content))
pre = $('').append(code)
+ else if contentType.indexOf("text/html") == 0
+ code = $('').html(content)
+ pre = $('').append(code)
+ else
+ # don't know what to render!
+ code = $('').text(content)
+ pre = $('').append(code)
+
response_body = pre
+ $(".request_url").html "" + data.request.url + "
"
$(".response_code", $(@el)).html "" + data.status + "
"
$(".response_body", $(@el)).html response_body
- $(".response_headers", $(@el)).html "" + data.getAllResponseHeaders() + "
"
+ $(".response_headers", $(@el)).html "" + JSON.stringify(data.getHeaders()) + "
"
$(".response", $(@el)).slideDown()
$(".response_hider", $(@el)).show()
$(".response_throbber", $(@el)).hide()
hljs.highlightBlock($('.response_body', $(@el))[0])
toggleOperationContent: ->
- elem = $('#' + Docs.escapeResourceName(@model.resourceName) + "_" + @model.nickname + "_" + @model.httpMethod + "_" + @model.number + "_content")
+ elem = $('#' + Docs.escapeResourceName(@model.resourceName) + "_" + @model.nickname + "_" + @model.method + "_" + @model.number + "_content")
if elem.is(':visible') then Docs.collapseOperation(elem) else Docs.expandOperation(elem)
diff --git a/src/main/coffeescript/view/ParameterView.coffee b/src/main/coffeescript/view/ParameterView.coffee
index 37c1eb4f..e31f05b8 100644
--- a/src/main/coffeescript/view/ParameterView.coffee
+++ b/src/main/coffeescript/view/ParameterView.coffee
@@ -19,18 +19,23 @@ class ParameterView extends Backbone.View
else
$('.model-signature', $(@el)).html(@model.signature)
+ isParam = false
+
+ if @model.isBody
+ isParam = true
+
contentTypeModel =
- isParam: false
+ isParam: isParam
- # support old syntax
- if @model.supportedContentTypes
- contentTypeModel.produces = @model.supportedContentTypes
+ contentTypeModel.consumes = @model.consumes
- if @model.produces
- contentTypeModel.produces = @model.produces
+ if isParam
+ parameterContentTypeView = new ParameterContentTypeView({model: contentTypeModel})
+ $('.parameter-content-type', $(@el)).append parameterContentTypeView.render().el
- contentTypeView = new ContentTypeView({model: contentTypeModel})
- $('.content-type', $(@el)).append contentTypeView.render().el
+ else
+ responseContentTypeView = new ResponseContentTypeView({model: contentTypeModel})
+ $('.response-content-type', $(@el)).append responseContentTypeView.render().el
@
diff --git a/src/main/html/index.html b/src/main/html/index.html
index 1abf4612..5f9d8523 100644
--- a/src/main/html/index.html
+++ b/src/main/html/index.html
@@ -1,74 +1,80 @@
- Swagger UI
-
-
-
-
-
-
-
-
-
-
-
-
-
+ Swagger UI
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
diff --git a/src/main/template/content_type.handlebars b/src/main/template/content_type.handlebars
index dca2a827..063f6a6e 100644
--- a/src/main/template/content_type.handlebars
+++ b/src/main/template/content_type.handlebars
@@ -1,10 +1,10 @@
diff --git a/src/main/template/operation.handlebars b/src/main/template/operation.handlebars
index 2d1c2b0c..d33c0bcf 100644
--- a/src/main/template/operation.handlebars
+++ b/src/main/template/operation.handlebars
@@ -1,49 +1,49 @@
- -
+
-
-
+
{{#if notes}}
Implementation Notes
{{{notes}}}
{{/if}}
{{#if responseClass}}
-
Response Class
-
-
-
+
Response Class
+
+
+
{{/if}}