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

[ base url: ";if(c=f.basePath){c=c.call(m,{hash:{},data:k})}else{c=m.basePath;c=typeof c===h?c.apply(m):c}i+=j(c)+"\n ";c=f["if"].call(m,m.apiVersion,{hash:{},inverse:p.noop,fn:p.program(8,n,k),data:k});if(c||c===0){i+=c}i+="]

\n
\n
\n";return i})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.operation=b(function(g,s,q,m,y){this.compilerInfo=[4,">= 1.0.0"];q=this.merge(q,g.helpers);y=y||{};var r="",i,f,e="function",d=this.escapeExpression,p=this,c=q.blockHelperMissing;function o(C,B){var z="",A;z+="\n

Implementation Notes

\n

";if(A=q.description){A=A.call(C,{hash:{},data:B})}else{A=C.description;A=typeof A===e?A.apply(C):A}if(A||A===0){z+=A}z+="

\n ";return z}function n(A,z){return'\n
\n '}function l(C,B){var z="",A;z+='\n \n ";return z}function k(D,C){var z="",B,A;z+="\n
"+d(((B=D.scope),typeof B===e?B.apply(D):B))+"
\n ";return z}function h(A,z){return"
"}function x(A,z){return'\n
\n \n
\n '}function w(A,z){return'\n

Response Class

\n

\n
\n
\n '}function v(A,z){return'\n

Parameters

\n \n \n \n \n \n \n \n \n \n \n \n\n \n
ParameterValueDescriptionParameter TypeData Type
\n '}function u(A,z){return"\n
\n

Response Messages

\n \n \n \n \n \n \n \n \n \n \n \n
HTTP Status CodeReasonResponse Model
\n "}function t(A,z){return"\n "}function j(A,z){return"\n
\n \n \n \n
\n "}r+="\n
    \n
  • \n \n \n
  • \n
\n";return r})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param=b(function(f,q,o,j,t){this.compilerInfo=[4,">= 1.0.0"];o=this.merge(o,f.helpers);t=t||{};var p="",g,d="function",c=this.escapeExpression,n=this;function m(y,x){var v="",w;v+="\n ";w=o["if"].call(y,y.isFile,{hash:{},inverse:n.program(4,k,x),fn:n.program(2,l,x),data:x});if(w||w===0){v+=w}v+="\n ";return v}function l(y,x){var v="",w;v+='\n \n
\n ';return v}function k(y,x){var v="",w;v+="\n ";w=o["if"].call(y,y.defaultValue,{hash:{},inverse:n.program(7,h,x),fn:n.program(5,i,x),data:x});if(w||w===0){v+=w}v+="\n ";return v}function i(y,x){var v="",w;v+="\n \n ";return v}function h(y,x){var v="",w;v+="\n \n
\n
\n ';return v}function e(y,x){var v="",w;v+="\n ";w=o["if"].call(y,y.isFile,{hash:{},inverse:n.program(10,u,x),fn:n.program(2,l,x),data:x});if(w||w===0){v+=w}v+="\n ";return v}function u(y,x){var v="",w;v+="\n ";w=o["if"].call(y,y.defaultValue,{hash:{},inverse:n.program(13,r,x),fn:n.program(11,s,x),data:x});if(w||w===0){v+=w}v+="\n ";return v}function s(y,x){var v="",w;v+="\n \n ";return v}function r(y,x){var v="",w;v+="\n \n ";return v}p+="";if(g=o.name){g=g.call(q,{hash:{},data:t})}else{g=q.name;g=typeof g===d?g.apply(q):g}p+=c(g)+"\n\n\n ";g=o["if"].call(q,q.isBody,{hash:{},inverse:n.program(9,e,t),fn:n.program(1,m,t),data:t});if(g||g===0){p+=g}p+="\n\n\n";if(g=o.description){g=g.call(q,{hash:{},data:t})}else{g=q.description;g=typeof g===d?g.apply(q):g}if(g||g===0){p+=g}p+="\n";if(g=o.paramType){g=g.call(q,{hash:{},data:t})}else{g=q.paramType;g=typeof g===d?g.apply(q):g}if(g||g===0){p+=g}p+='\n\n \n\n';return p})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param_list=b(function(h,t,r,m,y){this.compilerInfo=[4,">= 1.0.0"];r=this.merge(r,h.helpers);y=y||{};var s="",j,g,e,p=this,q=r.helperMissing,d="function",c=this.escapeExpression;function o(A,z){return" multiple='multiple'"}function n(A,z){return"\n "}function l(C,B){var z="",A;z+="\n ";A=r["if"].call(C,C.defaultValue,{hash:{},inverse:p.program(8,i,B),fn:p.program(6,k,B),data:B});if(A||A===0){z+=A}z+="\n ";return z}function k(A,z){return"\n "}function i(E,D){var z="",C,B,A;z+="\n ";A={hash:{},inverse:p.program(11,x,D),fn:p.program(9,f,D),data:D};B=((C=r.isArray||E.isArray),C?C.call(E,E,A):q.call(E,"isArray",E,A));if(B||B===0){z+=B}z+="\n ";return z}function f(A,z){return"\n "}function x(A,z){return"\n \n "}function w(C,B){var z="",A;z+="\n ";A=r["if"].call(C,C.isDefault,{hash:{},inverse:p.program(16,u,B),fn:p.program(14,v,B),data:B});if(A||A===0){z+=A}z+="\n ";return z}function v(C,B){var z="",A;z+='\n \n ";return z}function u(C,B){var z="",A;z+="\n \n ";return z}s+="";if(j=r.name){j=j.call(t,{hash:{},data:y})}else{j=t.name;j=typeof j===d?j.apply(t):j}s+=c(j)+"\n\n \n\n";if(g=r.description){g=g.call(t,{hash:{},data:y})}else{g=t.description;g=typeof g===d?g.apply(t):g}if(g||g===0){s+=g}s+="\n";if(g=r.paramType){g=g.call(t,{hash:{},data:y})}else{g=t.paramType;g=typeof g===d?g.apply(t):g}if(g||g===0){s+=g}s+='\n';return s})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param_readonly=b(function(g,m,f,l,k){this.compilerInfo=[4,">= 1.0.0"];f=this.merge(f,g.helpers);k=k||{};var i="",d,h="function",j=this.escapeExpression,o=this;function e(t,s){var q="",r;q+="\n \n ";return q}function c(t,s){var q="",r;q+="\n ";r=f["if"].call(t,t.defaultValue,{hash:{},inverse:o.program(6,n,s),fn:o.program(4,p,s),data:s});if(r||r===0){q+=r}q+="\n ";return q}function p(t,s){var q="",r;q+="\n ";if(r=f.defaultValue){r=r.call(t,{hash:{},data:s})}else{r=t.defaultValue;r=typeof r===h?r.apply(t):r}q+=j(r)+"\n ";return q}function n(r,q){return"\n (empty)\n "}i+="";if(d=f.name){d=d.call(m,{hash:{},data:k})}else{d=m.name;d=typeof d===h?d.apply(m):d}i+=j(d)+"\n\n ";d=f["if"].call(m,m.isBody,{hash:{},inverse:o.program(3,c,k),fn:o.program(1,e,k),data:k});if(d||d===0){i+=d}i+="\n\n";if(d=f.description){d=d.call(m,{hash:{},data:k})}else{d=m.description;d=typeof d===h?d.apply(m):d}if(d||d===0){i+=d}i+="\n";if(d=f.paramType){d=d.call(m,{hash:{},data:k})}else{d=m.paramType;d=typeof d===h?d.apply(m):d}if(d||d===0){i+=d}i+='\n\n';return i})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param_readonly_required=b(function(g,m,f,l,k){this.compilerInfo=[4,">= 1.0.0"];f=this.merge(f,g.helpers);k=k||{};var i="",d,h="function",j=this.escapeExpression,o=this;function e(t,s){var q="",r;q+="\n \n ";return q}function c(t,s){var q="",r;q+="\n ";r=f["if"].call(t,t.defaultValue,{hash:{},inverse:o.program(6,n,s),fn:o.program(4,p,s),data:s});if(r||r===0){q+=r}q+="\n ";return q}function p(t,s){var q="",r;q+="\n ";if(r=f.defaultValue){r=r.call(t,{hash:{},data:s})}else{r=t.defaultValue;r=typeof r===h?r.apply(t):r}q+=j(r)+"\n ";return q}function n(r,q){return"\n (empty)\n "}i+="";if(d=f.name){d=d.call(m,{hash:{},data:k})}else{d=m.name;d=typeof d===h?d.apply(m):d}i+=j(d)+"\n\n ";d=f["if"].call(m,m.isBody,{hash:{},inverse:o.program(3,c,k),fn:o.program(1,e,k),data:k});if(d||d===0){i+=d}i+="\n\n";if(d=f.description){d=d.call(m,{hash:{},data:k})}else{d=m.description;d=typeof d===h?d.apply(m):d}if(d||d===0){i+=d}i+="\n";if(d=f.paramType){d=d.call(m,{hash:{},data:k})}else{d=m.paramType;d=typeof d===h?d.apply(m):d}if(d||d===0){i+=d}i+='\n\n';return i})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param_required=b(function(f,q,o,j,u){this.compilerInfo=[4,">= 1.0.0"];o=this.merge(o,f.helpers);u=u||{};var p="",g,d="function",c=this.escapeExpression,n=this;function m(z,y){var w="",x;w+="\n ";x=o["if"].call(z,z.isFile,{hash:{},inverse:n.program(4,k,y),fn:n.program(2,l,y),data:y});if(x||x===0){w+=x}w+="\n ";return w}function l(z,y){var w="",x;w+='\n \n ";return w}function k(z,y){var w="",x;w+="\n ";x=o["if"].call(z,z.defaultValue,{hash:{},inverse:n.program(7,h,y),fn:n.program(5,i,y),data:y});if(x||x===0){w+=x}w+="\n ";return w}function i(z,y){var w="",x;w+="\n \n ";return w}function h(z,y){var w="",x;w+="\n \n
\n
\n ';return w}function e(z,y){var w="",x;w+="\n ";x=o["if"].call(z,z.isFile,{hash:{},inverse:n.program(12,t,y),fn:n.program(10,v,y),data:y});if(x||x===0){w+=x}w+="\n ";return w}function v(z,y){var w="",x;w+="\n \n ";return w}function t(z,y){var w="",x;w+="\n ";x=o["if"].call(z,z.defaultValue,{hash:{},inverse:n.program(15,r,y),fn:n.program(13,s,y),data:y});if(x||x===0){w+=x}w+="\n ";return w}function s(z,y){var w="",x;w+="\n \n ";return w}function r(z,y){var w="",x;w+="\n \n ";return w}p+="";if(g=o.name){g=g.call(q,{hash:{},data:u})}else{g=q.name;g=typeof g===d?g.apply(q):g}p+=c(g)+"\n\n ";g=o["if"].call(q,q.isBody,{hash:{},inverse:n.program(9,e,u),fn:n.program(1,m,u),data:u});if(g||g===0){p+=g}p+="\n\n\n ";if(g=o.description){g=g.call(q,{hash:{},data:u})}else{g=q.description;g=typeof g===d?g.apply(q):g}if(g||g===0){p+=g}p+="\n\n";if(g=o.paramType){g=g.call(q,{hash:{},data:u})}else{g=q.paramType;g=typeof g===d?g.apply(q):g}if(g||g===0){p+=g}p+='\n\n';return p})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.parameter_content_type=b(function(g,l,f,k,j){this.compilerInfo=[4,">= 1.0.0"];f=this.merge(f,g.helpers);j=j||{};var i="",c,h="function",m=this;function e(r,q){var o="",p;o+="\n ";p=f.each.call(r,r.consumes,{hash:{},inverse:m.noop,fn:m.program(2,d,q),data:q});if(p||p===0){o+=p}o+="\n";return o}function d(r,q){var o="",p;o+='\n \n ";return o}function n(p,o){return'\n \n'}i+='\n\n";return i})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.resource=b(function(g,m,f,l,k){this.compilerInfo=[4,">= 1.0.0"];f=this.merge(f,g.helpers);k=k||{};var i="",d,p,h="function",j=this.escapeExpression,o=this,n=f.blockHelperMissing;function e(r,q){return" : "}function c(t,s){var q="",r;q+="
  • \n Raw\n
  • ";return q}i+="
    \n

    \n ';if(d=f.name){d=d.call(m,{hash:{},data:k})}else{d=m.name;d=typeof d===h?d.apply(m):d}i+=j(d)+" ";p={hash:{},inverse:o.noop,fn:o.program(1,e,k),data:k};if(d=f.summary){d=d.call(m,p)}else{d=m.summary;d=typeof d===h?d.apply(m):d}if(!f.summary){d=n.call(m,d,p)}if(d||d===0){i+=d}if(d=f.summary){d=d.call(m,{hash:{},data:k})}else{d=m.summary;d=typeof d===h?d.apply(m):d}if(d||d===0){i+=d}i+="\n

    \n
    \n
    \n\n
    \n
    \n ';if(c=d.signature){c=c.call(k,{hash:{},data:i})}else{c=k.signature;c=typeof c===f?c.apply(k):c}if(c||c===0){g+=c}g+='\n
    \n\n
    \n
    ';if(c=d.sampleJSON){c=c.call(k,{hash:{},data:i})}else{c=k.sampleJSON;c=typeof c===f?c.apply(k):c}g+=h(c)+'
    \n \n
    \n
    \n\n';return g})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.status_code=b(function(e,k,d,j,i){this.compilerInfo=[4,">= 1.0.0"];d=this.merge(d,e.helpers);i=i||{};var g="",c,f="function",h=this.escapeExpression;g+="";if(c=d.code){c=c.call(k,{hash:{},data:i})}else{c=k.code;c=typeof c===f?c.apply(k):c}g+=h(c)+"\n";if(c=d.message){c=c.call(k,{hash:{},data:i})}else{c=k.message;c=typeof c===f?c.apply(k):c}if(c||c===0){g+=c}g+="\n";return g})})();(function(){var j,r,u,o,l,k,n,m,i,p,s,q,h,c,g,f,e,d,b,a,x,w,t={}.hasOwnProperty,v=function(B,z){for(var y in z){if(t.call(z,y)){B[y]=z[y]}}function A(){this.constructor=B}A.prototype=z.prototype;B.prototype=new A();B.__super__=z.prototype;return B};s=(function(z){v(y,z);function y(){q=y.__super__.constructor.apply(this,arguments);return q}y.prototype.dom_id="swagger_ui";y.prototype.options=null;y.prototype.api=null;y.prototype.headerView=null;y.prototype.mainView=null;y.prototype.initialize=function(A){var B=this;if(A==null){A={}}if(A.dom_id!=null){this.dom_id=A.dom_id;delete A.dom_id}if($("#"+this.dom_id)==null){$("body").append('
    ')}this.options=A;this.options.success=function(){return B.render()};this.options.progress=function(C){return B.showMessage(C)};this.options.failure=function(C){if(B.api&&B.api.isValid===false){log("not a valid 2.0 spec, loading legacy client");B.api=new SwaggerApi(B.options);return B.api.build()}else{return B.onLoadFailure(C)}};this.headerView=new r({el:$("#header")});return this.headerView.on("update-swagger-ui",function(C){return B.updateSwaggerUi(C)})};y.prototype.updateSwaggerUi=function(A){this.options.url=A.url;return this.load()};y.prototype.load=function(){var B,A;if((A=this.mainView)!=null){A.clear()}B=this.options.url;if(B.indexOf("http")!==0){B=this.buildUrl(window.location.href.toString(),B)}this.options.url=B;this.headerView.update(B);this.api=new SwaggerClient(this.options);return this.api.build()};y.prototype.render=function(){var A=this;this.showMessage("Finished Loading Resource Information. Rendering Swagger UI...");this.mainView=new u({model:this.api,el:$("#"+this.dom_id),swaggerOptions:this.options}).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)};y.prototype.buildUrl=function(C,A){var B,D;log("base is "+C);if(A.indexOf("/")===0){D=C.split("/");C=D[0]+"//"+D[2];return C+A}else{B=C.length;if(C.indexOf("?")>-1){B=Math.min(B,C.indexOf("?"))}if(C.indexOf("#")>-1){B=Math.min(B,C.indexOf("#"))}C=C.substring(0,B);if(C.indexOf("/",C.length-1)!==-1){return C+A}return C+"/"+A}};y.prototype.showMessage=function(A){if(A==null){A=""}$("#message-bar").removeClass("message-fail");$("#message-bar").addClass("message-success");return $("#message-bar").html(A)};y.prototype.onLoadFailure=function(A){var B;if(A==null){A=""}$("#message-bar").removeClass("message-success");$("#message-bar").addClass("message-fail");B=$("#message-bar").html(A);if(this.options.onFailure!=null){this.options.onFailure(A)}return B};return y})(Backbone.Router);window.SwaggerUi=s;r=(function(z){v(y,z);function y(){h=y.__super__.constructor.apply(this,arguments);return h}y.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"};y.prototype.initialize=function(){};y.prototype.showPetStore=function(A){return this.trigger("update-swagger-ui",{url:"http://petstore.swagger.wordnik.com/api/api-docs"})};y.prototype.showWordnikDev=function(A){return this.trigger("update-swagger-ui",{url:"http://api.wordnik.com/v4/resources.json"})};y.prototype.showCustomOnKeyup=function(A){if(A.keyCode===13){return this.showCustom()}};y.prototype.showCustom=function(A){if(A!=null){A.preventDefault()}return this.trigger("update-swagger-ui",{url:$("#input_baseUrl").val(),apiKey:$("#input_apiKey").val()})};y.prototype.update=function(B,C,A){if(A==null){A=false}$("#input_baseUrl").val(B);if(A){return this.trigger("update-swagger-ui",{url:B})}};return y})(Backbone.View);u=(function(y){var z;v(A,y);function A(){g=A.__super__.constructor.apply(this,arguments);return g}z={alpha:function(C,B){return C.path.localeCompare(B.path)},method:function(C,B){return C.method.localeCompare(B.method)}};A.prototype.initialize=function(B){var C,I,J,E,D,G,H,F;if(B==null){B={}}if(B.swaggerOptions.sorter){E=B.swaggerOptions.sorter;J=z[E];if(this.model.apisArray){F=this.model.apisArray;for(G=0,H=F.length;GB){K=B-C}if(KA){H=A-E}if(H")}this.model.oauth=null;if(this.model.authorizations){E=this.model.authorizations;for(T in E){N=E[T];if(T==="oauth2"){if(this.model.oauth===null){this.model.oauth={}}if(this.model.oauth.scopes===void 0){this.model.oauth.scopes=[]}for(H=0,Y=N.length;H0){D[I.name]=I.value}if(I.type==="file"){N=true}}E=G.find("textarea");for(L=0,F=E.length;L0){D.body=I.value}}B=G.find("select");for(K=0,C=B.length;K0){D[I.name]=J}}A.responseContentType=$("div select[name=responseContentType]",$(this.el)).val();A.requestContentType=$("div select[name=parameterContentType]",$(this.el)).val();$(".response_throbber",$(this.el)).show();if(N){return this.handleFileUpload(D,G)}else{return this.model["do"](D,A,this.showCompleteStatus,this.showErrorStatus,this)}}};y.prototype.success=function(A,B){return B.showCompleteStatus(A)};y.prototype.handleFileUpload=function(R,I){var M,H,C,N,L,K,P,J,G,F,D,Q,U,T,S,E,B,A,V,O=this;E=I.serializeArray();for(J=0,Q=E.length;J0){R[N.name]=N.value}}M=new FormData();P=0;B=this.model.parameters;for(G=0,U=B.length;G");$(".request_url pre",$(this.el)).text(this.invocationUrl);L={type:this.model.method,url:this.invocationUrl,headers:C,data:M,dataType:"json",contentType:false,processData:false,error:function(X,Y,W){return O.showErrorStatus(O.wrap(X),O)},success:function(W){return O.showResponse(W,O)},complete:function(W){return O.showCompleteStatus(O.wrap(W),O)}};if(window.authorizations){window.authorizations.apply(L)}if(P===0){L.data.append("fake","true")}jQuery.ajax(L);return false};y.prototype.wrap=function(E){var C,F,H,B,G,D,A;H={};F=E.getAllResponseHeaders().split("\r");for(D=0,A=F.length;D0){return C.join(",")}else{return null}}};y.prototype.hideResponse=function(A){if(A!=null){A.preventDefault()}$(".response",$(this.el)).slideUp();return $(".response_hider",$(this.el)).fadeOut()};y.prototype.showResponse=function(A){var B;B=JSON.stringify(A,null,"\t").replace(/\n/g,"
    ");return $(".response_body",$(this.el)).html(escape(B))};y.prototype.showErrorStatus=function(B,A){return A.showStatus(B)};y.prototype.showCompleteStatus=function(B,A){return A.showStatus(B)};y.prototype.formatXml=function(H){var D,G,B,I,N,J,C,A,L,M,F,E,K;A=/(>)(<)(\/*)/g;M=/[ ]*(.*)[ ]+\n/g;D=/(<.+>)(.+\n)/g;H=H.replace(A,"$1\n$2$3").replace(M,"$1\n").replace(D,"$1\n$2");C=0;G="";N=H.split("\n");B=0;I="other";L={"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};F=function(T){var P,O,R,V,S,Q,U;Q={single:Boolean(T.match(/<.+\/>/)),closing:Boolean(T.match(/<\/.+>/)),opening:Boolean(T.match(/<[^!?].*>/))};S=((function(){var W;W=[];for(R in Q){U=Q[R];if(U){W.push(R)}}return W})())[0];S=S===void 0?"other":S;P=I+"->"+S;I=S;V="";B+=L[P];V=((function(){var X,Y,W;W=[];for(O=X=0,Y=B;0<=Y?XY;O=0<=Y?++X:--X){W.push(" ")}return W})()).join("");if(P==="opening->closing"){return G=G.substr(0,G.length-1)+T+"\n"}else{return G+=V+T+"\n"}};for(E=0,K=N.length;E").text("no content");E=$('
    ').append(C)}else{if(J==="application/json"||/\+json$/.test(J)){C=$("").text(JSON.stringify(JSON.parse(H),null,"  "));E=$('
    ').append(C)}else{if(J==="application/xml"||/\+xml$/.test(J)){C=$("").text(this.formatXml(H));E=$('
    ').append(C)}else{if(J==="text/html"){C=$("").html(_.escape(H));E=$('
    ').append(C)}else{if(/^image\//.test(J)){E=$("").attr("src",B)}else{C=$("").text(H);E=$('
    ').append(C)}}}}}I=E;$(".request_url",$(this.el)).html("
    ");$(".request_url pre",$(this.el)).text(B);$(".response_code",$(this.el)).html("
    "+F.status+"
    ");$(".response_body",$(this.el)).html(I);$(".response_headers",$(this.el)).html("
    "+_.escape(JSON.stringify(F.headers,null,"  ")).replace(/\n/g,"
    ")+"
    ");$(".response",$(this.el)).slideDown();$(".response_hider",$(this.el)).show();$(".response_throbber",$(this.el)).hide();G=$(".response_body",$(this.el))[0];A=this.options.swaggerOptions;if(A.highlightSizeThreshold&&F.data.length>A.highlightSizeThreshold){return G}else{return hljs.highlightBlock(G)}};y.prototype.toggleOperationContent=function(){var A;A=$("#"+Docs.escapeResourceName(this.model.parentId)+"_"+this.model.nickname+"_content");if(A.is(":visible")){return Docs.collapseOperation(A)}else{return Docs.expandOperation(A)}};return y})(Backbone.View);p=(function(z){v(y,z);function y(){d=y.__super__.constructor.apply(this,arguments);return d}y.prototype.initialize=function(){};y.prototype.render=function(){var B,A,C;C=this.template();$(this.el).html(C(this.model));if(swaggerUi.api.models.hasOwnProperty(this.model.responseModel)){B={sampleJSON:JSON.stringify(swaggerUi.api.models[this.model.responseModel].createJSONSample(),null,2),isParam:false,signature:swaggerUi.api.models[this.model.responseModel].getMockSignature()};A=new i({model:B,tagName:"div"});$(".model-signature",this.$el).append(A.render().el)}else{$(".model-signature",this.$el).html("")}return this};y.prototype.template=function(){return Handlebars.templates.status_code};return y})(Backbone.View);k=(function(z){v(y,z);function y(){b=y.__super__.constructor.apply(this,arguments);return b}y.prototype.initialize=function(){return Handlebars.registerHelper("isArray",function(B,A){if(B.type.toLowerCase()==="array"||B.allowMultiple){return A.fn(this)}else{return A.inverse(this)}})};y.prototype.render=function(){var A,B,E,C,F,D,I,J,H,G;G=this.model.type||this.model.dataType;if(typeof G==="undefined"){D=this.model.schema;if(D["$ref"]){C=D["$ref"];if(C.indexOf("#/definitions/")===0){G=C.substring("#/definitions/".length)}else{G=C}}}this.model.type=G;this.model.paramType=this.model["in"]||this.model.paramType;if(this.model.paramType==="body"){this.model.isBody=true}if(G&&G.toLowerCase()==="file"){this.model.isFile=true}H=this.template();$(this.el).html(H(this.model));I={sampleJSON:this.model.sampleJSON,isParam:true,signature:this.model.signature};if(this.model.sampleJSON){J=new i({model:I,tagName:"div"});$(".model-signature",$(this.el)).append(J.render().el)}else{$(".model-signature",$(this.el)).html(this.model.signature)}B=false;if(this.model.isBody){B=true}A={isParam:B};A.consumes=this.model.consumes;if(B){E=new l({model:A});$(".parameter-content-type",$(this.el)).append(E.render().el)}else{F=new m({model:A});$(".response-content-type",$(this.el)).append(F.render().el)}return this};y.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 y})(Backbone.View);i=(function(z){v(y,z);function y(){a=y.__super__.constructor.apply(this,arguments);return a}y.prototype.events={"click a.description-link":"switchToDescription","click a.snippet-link":"switchToSnippet","mousedown .snippet":"snippetToTextArea"};y.prototype.initialize=function(){};y.prototype.render=function(){var A;A=this.template();$(this.el).html(A(this.model));this.switchToSnippet();this.isParam=this.model.isParam;if(this.isParam){$(".notice",$(this.el)).text("Click to set as parameter value")}return this};y.prototype.template=function(){return Handlebars.templates.signature};y.prototype.switchToDescription=function(A){if(A!=null){A.preventDefault()}$(".snippet",$(this.el)).hide();$(".description",$(this.el)).show();$(".description-link",$(this.el)).addClass("selected");return $(".snippet-link",$(this.el)).removeClass("selected")};y.prototype.switchToSnippet=function(A){if(A!=null){A.preventDefault()}$(".description",$(this.el)).hide();$(".snippet",$(this.el)).show();$(".snippet-link",$(this.el)).addClass("selected");return $(".description-link",$(this.el)).removeClass("selected")};y.prototype.snippetToTextArea=function(A){var B;if(this.isParam){if(A!=null){A.preventDefault()}B=$("textarea",$(this.el.parentNode.parentNode.parentNode));if($.trim(B.val())===""){return B.val(this.model.sampleJSON)}}};return y})(Backbone.View);j=(function(y){v(z,y);function z(){x=z.__super__.constructor.apply(this,arguments);return x}z.prototype.initialize=function(){};z.prototype.render=function(){var A;A=this.template();$(this.el).html(A(this.model));$("label[for=contentType]",$(this.el)).text("Response Content Type");return this};z.prototype.template=function(){return Handlebars.templates.content_type};return z})(Backbone.View);m=(function(y){v(z,y);function z(){w=z.__super__.constructor.apply(this,arguments);return w}z.prototype.initialize=function(){};z.prototype.render=function(){var A;A=this.template();$(this.el).html(A(this.model));$("label[for=responseContentType]",$(this.el)).text("Response Content Type");return this};z.prototype.template=function(){return Handlebars.templates.response_content_type};return z})(Backbone.View);l=(function(z){v(y,z);function y(){c=y.__super__.constructor.apply(this,arguments);return c}y.prototype.initialize=function(){};y.prototype.render=function(){var A;A=this.template();$(this.el).html(A(this.model));$("label[for=parameterContentType]",$(this.el)).text("Parameter content type:");return this};y.prototype.template=function(){return Handlebars.templates.parameter_content_type};return y})(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()}log=function(){log.history=log.history||[];log.history.push(arguments);if(this.console){console.log(Array.prototype.slice.call(arguments)[0])}};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,l,f,k,j){this.compilerInfo=[4,">= 1.0.0"];f=this.merge(f,g.helpers);j=j||{};var i="",c,h="function",m=this;function e(r,q){var o="",p;o+="\n ";p=f.each.call(r,r.produces,{hash:{},inverse:m.noop,fn:m.program(2,d,q),data:q});if(p||p===0){o+=p}o+="\n";return o}function d(r,q){var o="",p;o+='\n \n ";return o}function n(p,o){return'\n \n'}i+='\n\n";return i})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.main=b(function(h,n,g,m,l){this.compilerInfo=[4,">= 1.0.0"];g=this.merge(g,h.helpers);l=l||{};var j="",c,i="function",k=this.escapeExpression,q=this;function f(w,v){var s="",u,t;s+='\n
    '+k(((u=((u=w.info),u==null||u===false?u:u.title)),typeof u===i?u.apply(w):u))+'
    \n
    ';t=((u=((u=w.info),u==null||u===false?u:u.description)),typeof u===i?u.apply(w):u);if(t||t===0){s+=t}s+="
    \n ";t=g["if"].call(w,((u=w.info),u==null||u===false?u:u.termsOfServiceUrl),{hash:{},inverse:q.noop,fn:q.program(2,d,v),data:v});if(t||t===0){s+=t}s+="\n ";t=g["if"].call(w,((u=w.info),u==null||u===false?u:u.contact),{hash:{},inverse:q.noop,fn:q.program(4,r,v),data:v});if(t||t===0){s+=t}s+="\n ";t=g["if"].call(w,((u=w.info),u==null||u===false?u:u.license),{hash:{},inverse:q.noop,fn:q.program(6,p,v),data:v});if(t||t===0){s+=t}s+="\n ";return s}function d(v,u){var s="",t;s+='';return s}function r(v,u){var s="",t;s+="';return s}function p(v,u){var s="",t;s+="";return s}function o(v,u){var s="",t;s+='\n , api version: ';if(t=g.apiVersion){t=t.call(v,{hash:{},data:u})}else{t=v.apiVersion;t=typeof t===i?t.apply(v):t}s+=k(t)+"\n ";return s}function e(v,u){var s="",t;s+='\n \n \n ';return s}j+="
    \n ";c=g["if"].call(n,n.info,{hash:{},inverse:q.noop,fn:q.program(1,f,l),data:l});if(c||c===0){j+=c}j+="\n
    \n
    \n
      \n
    \n\n
    \n
    \n
    \n

    [ base url: ";if(c=g.basePath){c=c.call(n,{hash:{},data:l})}else{c=n.basePath;c=typeof c===i?c.apply(n):c}j+=k(c)+"\n ";c=g["if"].call(n,n.apiVersion,{hash:{},inverse:q.noop,fn:q.program(8,o,l),data:l});if(c||c===0){j+=c}j+="]\n ";c=g["if"].call(n,n.validatorUrl,{hash:{},inverse:q.noop,fn:q.program(10,e,l),data:l});if(c||c===0){j+=c}j+="\n

    \n
    \n
    \n";return j})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.operation=b(function(g,s,q,m,y){this.compilerInfo=[4,">= 1.0.0"];q=this.merge(q,g.helpers);y=y||{};var r="",i,f,e="function",d=this.escapeExpression,p=this,c=q.blockHelperMissing;function o(C,B){var z="",A;z+="\n

    Implementation Notes

    \n

    ";if(A=q.description){A=A.call(C,{hash:{},data:B})}else{A=C.description;A=typeof A===e?A.apply(C):A}if(A||A===0){z+=A}z+="

    \n ";return z}function n(A,z){return'\n
    \n '}function l(C,B){var z="",A;z+='\n \n ";return z}function k(D,C){var z="",B,A;z+="\n
    "+d(((B=D.scope),typeof B===e?B.apply(D):B))+"
    \n ";return z}function h(A,z){return"
    "}function x(A,z){return'\n
    \n \n
    \n '}function w(A,z){return'\n

    Response Class

    \n

    \n
    \n
    \n '}function v(A,z){return'\n

    Parameters

    \n \n \n \n \n \n \n \n \n \n \n \n\n \n
    ParameterValueDescriptionParameter TypeData Type
    \n '}function u(A,z){return"\n
    \n

    Response Messages

    \n \n \n \n \n \n \n \n \n \n \n \n
    HTTP Status CodeReasonResponse Model
    \n "}function t(A,z){return"\n "}function j(A,z){return"\n
    \n \n \n \n
    \n "}r+="\n
      \n
    • \n \n \n
    • \n
    \n";return r})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param=b(function(f,q,o,j,t){this.compilerInfo=[4,">= 1.0.0"];o=this.merge(o,f.helpers);t=t||{};var p="",g,d="function",c=this.escapeExpression,n=this;function m(y,x){var v="",w;v+="\n ";w=o["if"].call(y,y.isFile,{hash:{},inverse:n.program(4,k,x),fn:n.program(2,l,x),data:x});if(w||w===0){v+=w}v+="\n ";return v}function l(y,x){var v="",w;v+='\n \n
    \n ';return v}function k(y,x){var v="",w;v+="\n ";w=o["if"].call(y,y.defaultValue,{hash:{},inverse:n.program(7,h,x),fn:n.program(5,i,x),data:x});if(w||w===0){v+=w}v+="\n ";return v}function i(y,x){var v="",w;v+="\n \n ";return v}function h(y,x){var v="",w;v+="\n \n
    \n
    \n ';return v}function e(y,x){var v="",w;v+="\n ";w=o["if"].call(y,y.isFile,{hash:{},inverse:n.program(10,u,x),fn:n.program(2,l,x),data:x});if(w||w===0){v+=w}v+="\n ";return v}function u(y,x){var v="",w;v+="\n ";w=o["if"].call(y,y.defaultValue,{hash:{},inverse:n.program(13,r,x),fn:n.program(11,s,x),data:x});if(w||w===0){v+=w}v+="\n ";return v}function s(y,x){var v="",w;v+="\n \n ";return v}function r(y,x){var v="",w;v+="\n \n ";return v}p+="";if(g=o.name){g=g.call(q,{hash:{},data:t})}else{g=q.name;g=typeof g===d?g.apply(q):g}p+=c(g)+"\n\n\n ";g=o["if"].call(q,q.isBody,{hash:{},inverse:n.program(9,e,t),fn:n.program(1,m,t),data:t});if(g||g===0){p+=g}p+="\n\n\n";if(g=o.description){g=g.call(q,{hash:{},data:t})}else{g=q.description;g=typeof g===d?g.apply(q):g}if(g||g===0){p+=g}p+="\n";if(g=o.paramType){g=g.call(q,{hash:{},data:t})}else{g=q.paramType;g=typeof g===d?g.apply(q):g}if(g||g===0){p+=g}p+='\n\n \n\n';return p})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param_list=b(function(h,t,r,m,y){this.compilerInfo=[4,">= 1.0.0"];r=this.merge(r,h.helpers);y=y||{};var s="",j,g,e,p=this,q=r.helperMissing,d="function",c=this.escapeExpression;function o(A,z){return" multiple='multiple'"}function n(A,z){return"\n "}function l(C,B){var z="",A;z+="\n ";A=r["if"].call(C,C.defaultValue,{hash:{},inverse:p.program(8,i,B),fn:p.program(6,k,B),data:B});if(A||A===0){z+=A}z+="\n ";return z}function k(A,z){return"\n "}function i(E,D){var z="",C,B,A;z+="\n ";A={hash:{},inverse:p.program(11,x,D),fn:p.program(9,f,D),data:D};B=((C=r.isArray||E.isArray),C?C.call(E,E,A):q.call(E,"isArray",E,A));if(B||B===0){z+=B}z+="\n ";return z}function f(A,z){return"\n "}function x(A,z){return"\n \n "}function w(C,B){var z="",A;z+="\n ";A=r["if"].call(C,C.isDefault,{hash:{},inverse:p.program(16,u,B),fn:p.program(14,v,B),data:B});if(A||A===0){z+=A}z+="\n ";return z}function v(C,B){var z="",A;z+='\n \n ";return z}function u(C,B){var z="",A;z+="\n \n ";return z}s+="";if(j=r.name){j=j.call(t,{hash:{},data:y})}else{j=t.name;j=typeof j===d?j.apply(t):j}s+=c(j)+"\n\n \n\n";if(g=r.description){g=g.call(t,{hash:{},data:y})}else{g=t.description;g=typeof g===d?g.apply(t):g}if(g||g===0){s+=g}s+="\n";if(g=r.paramType){g=g.call(t,{hash:{},data:y})}else{g=t.paramType;g=typeof g===d?g.apply(t):g}if(g||g===0){s+=g}s+='\n';return s})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param_readonly=b(function(g,m,f,l,k){this.compilerInfo=[4,">= 1.0.0"];f=this.merge(f,g.helpers);k=k||{};var i="",d,h="function",j=this.escapeExpression,o=this;function e(t,s){var q="",r;q+="\n \n ";return q}function c(t,s){var q="",r;q+="\n ";r=f["if"].call(t,t.defaultValue,{hash:{},inverse:o.program(6,n,s),fn:o.program(4,p,s),data:s});if(r||r===0){q+=r}q+="\n ";return q}function p(t,s){var q="",r;q+="\n ";if(r=f.defaultValue){r=r.call(t,{hash:{},data:s})}else{r=t.defaultValue;r=typeof r===h?r.apply(t):r}q+=j(r)+"\n ";return q}function n(r,q){return"\n (empty)\n "}i+="";if(d=f.name){d=d.call(m,{hash:{},data:k})}else{d=m.name;d=typeof d===h?d.apply(m):d}i+=j(d)+"\n\n ";d=f["if"].call(m,m.isBody,{hash:{},inverse:o.program(3,c,k),fn:o.program(1,e,k),data:k});if(d||d===0){i+=d}i+="\n\n";if(d=f.description){d=d.call(m,{hash:{},data:k})}else{d=m.description;d=typeof d===h?d.apply(m):d}if(d||d===0){i+=d}i+="\n";if(d=f.paramType){d=d.call(m,{hash:{},data:k})}else{d=m.paramType;d=typeof d===h?d.apply(m):d}if(d||d===0){i+=d}i+='\n\n';return i})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param_readonly_required=b(function(g,m,f,l,k){this.compilerInfo=[4,">= 1.0.0"];f=this.merge(f,g.helpers);k=k||{};var i="",d,h="function",j=this.escapeExpression,o=this;function e(t,s){var q="",r;q+="\n \n ";return q}function c(t,s){var q="",r;q+="\n ";r=f["if"].call(t,t.defaultValue,{hash:{},inverse:o.program(6,n,s),fn:o.program(4,p,s),data:s});if(r||r===0){q+=r}q+="\n ";return q}function p(t,s){var q="",r;q+="\n ";if(r=f.defaultValue){r=r.call(t,{hash:{},data:s})}else{r=t.defaultValue;r=typeof r===h?r.apply(t):r}q+=j(r)+"\n ";return q}function n(r,q){return"\n (empty)\n "}i+="";if(d=f.name){d=d.call(m,{hash:{},data:k})}else{d=m.name;d=typeof d===h?d.apply(m):d}i+=j(d)+"\n\n ";d=f["if"].call(m,m.isBody,{hash:{},inverse:o.program(3,c,k),fn:o.program(1,e,k),data:k});if(d||d===0){i+=d}i+="\n\n";if(d=f.description){d=d.call(m,{hash:{},data:k})}else{d=m.description;d=typeof d===h?d.apply(m):d}if(d||d===0){i+=d}i+="\n";if(d=f.paramType){d=d.call(m,{hash:{},data:k})}else{d=m.paramType;d=typeof d===h?d.apply(m):d}if(d||d===0){i+=d}i+='\n\n';return i})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param_required=b(function(f,q,o,j,u){this.compilerInfo=[4,">= 1.0.0"];o=this.merge(o,f.helpers);u=u||{};var p="",g,d="function",c=this.escapeExpression,n=this;function m(z,y){var w="",x;w+="\n ";x=o["if"].call(z,z.isFile,{hash:{},inverse:n.program(4,k,y),fn:n.program(2,l,y),data:y});if(x||x===0){w+=x}w+="\n ";return w}function l(z,y){var w="",x;w+='\n \n ";return w}function k(z,y){var w="",x;w+="\n ";x=o["if"].call(z,z.defaultValue,{hash:{},inverse:n.program(7,h,y),fn:n.program(5,i,y),data:y});if(x||x===0){w+=x}w+="\n ";return w}function i(z,y){var w="",x;w+="\n \n ";return w}function h(z,y){var w="",x;w+="\n \n
    \n
    \n ';return w}function e(z,y){var w="",x;w+="\n ";x=o["if"].call(z,z.isFile,{hash:{},inverse:n.program(12,t,y),fn:n.program(10,v,y),data:y});if(x||x===0){w+=x}w+="\n ";return w}function v(z,y){var w="",x;w+="\n \n ";return w}function t(z,y){var w="",x;w+="\n ";x=o["if"].call(z,z.defaultValue,{hash:{},inverse:n.program(15,r,y),fn:n.program(13,s,y),data:y});if(x||x===0){w+=x}w+="\n ";return w}function s(z,y){var w="",x;w+="\n \n ";return w}function r(z,y){var w="",x;w+="\n \n ";return w}p+="";if(g=o.name){g=g.call(q,{hash:{},data:u})}else{g=q.name;g=typeof g===d?g.apply(q):g}p+=c(g)+"\n\n ";g=o["if"].call(q,q.isBody,{hash:{},inverse:n.program(9,e,u),fn:n.program(1,m,u),data:u});if(g||g===0){p+=g}p+="\n\n\n ";if(g=o.description){g=g.call(q,{hash:{},data:u})}else{g=q.description;g=typeof g===d?g.apply(q):g}if(g||g===0){p+=g}p+="\n\n";if(g=o.paramType){g=g.call(q,{hash:{},data:u})}else{g=q.paramType;g=typeof g===d?g.apply(q):g}if(g||g===0){p+=g}p+='\n\n';return p})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.parameter_content_type=b(function(g,l,f,k,j){this.compilerInfo=[4,">= 1.0.0"];f=this.merge(f,g.helpers);j=j||{};var i="",c,h="function",m=this;function e(r,q){var o="",p;o+="\n ";p=f.each.call(r,r.consumes,{hash:{},inverse:m.noop,fn:m.program(2,d,q),data:q});if(p||p===0){o+=p}o+="\n";return o}function d(r,q){var o="",p;o+='\n \n ";return o}function n(p,o){return'\n \n'}i+='\n\n";return i})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.resource=b(function(g,m,f,l,k){this.compilerInfo=[4,">= 1.0.0"];f=this.merge(f,g.helpers);k=k||{};var i="",d,p,h="function",j=this.escapeExpression,o=this,n=f.blockHelperMissing;function e(r,q){return" : "}function c(t,s){var q="",r;q+="
  • \n Raw\n
  • ";return q}i+="
    \n

    \n ';if(d=f.name){d=d.call(m,{hash:{},data:k})}else{d=m.name;d=typeof d===h?d.apply(m):d}i+=j(d)+" ";p={hash:{},inverse:o.noop,fn:o.program(1,e,k),data:k};if(d=f.summary){d=d.call(m,p)}else{d=m.summary;d=typeof d===h?d.apply(m):d}if(!f.summary){d=n.call(m,d,p)}if(d||d===0){i+=d}if(d=f.summary){d=d.call(m,{hash:{},data:k})}else{d=m.summary;d=typeof d===h?d.apply(m):d}if(d||d===0){i+=d}i+="\n

    \n
    \n
    \n\n
    \n
    \n ';if(c=d.signature){c=c.call(k,{hash:{},data:i})}else{c=k.signature;c=typeof c===f?c.apply(k):c}if(c||c===0){g+=c}g+='\n
    \n\n
    \n
    ';if(c=d.sampleJSON){c=c.call(k,{hash:{},data:i})}else{c=k.sampleJSON;c=typeof c===f?c.apply(k):c}g+=h(c)+'
    \n \n
    \n
    \n\n';return g})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.status_code=b(function(e,k,d,j,i){this.compilerInfo=[4,">= 1.0.0"];d=this.merge(d,e.helpers);i=i||{};var g="",c,f="function",h=this.escapeExpression;g+="";if(c=d.code){c=c.call(k,{hash:{},data:i})}else{c=k.code;c=typeof c===f?c.apply(k):c}g+=h(c)+"\n";if(c=d.message){c=c.call(k,{hash:{},data:i})}else{c=k.message;c=typeof c===f?c.apply(k):c}if(c||c===0){g+=c}g+="\n";return g})})();(function(){var j,r,u,o,l,k,n,m,i,p,s,q,h,c,g,f,e,d,b,a,x,w,t={}.hasOwnProperty,v=function(B,z){for(var y in z){if(t.call(z,y)){B[y]=z[y]}}function A(){this.constructor=B}A.prototype=z.prototype;B.prototype=new A();B.__super__=z.prototype;return B};s=(function(z){v(y,z);function y(){q=y.__super__.constructor.apply(this,arguments);return q}y.prototype.dom_id="swagger_ui";y.prototype.options=null;y.prototype.api=null;y.prototype.headerView=null;y.prototype.mainView=null;y.prototype.initialize=function(A){var B=this;if(A==null){A={}}if(A.dom_id!=null){this.dom_id=A.dom_id;delete A.dom_id}if($("#"+this.dom_id)==null){$("body").append('
    ')}this.options=A;this.options.success=function(){return B.render()};this.options.progress=function(C){return B.showMessage(C)};this.options.failure=function(C){if(B.api&&B.api.isValid===false){log("not a valid 2.0 spec, loading legacy client");B.api=new SwaggerApi(B.options);return B.api.build()}else{return B.onLoadFailure(C)}};this.headerView=new r({el:$("#header")});return this.headerView.on("update-swagger-ui",function(C){return B.updateSwaggerUi(C)})};y.prototype.updateSwaggerUi=function(A){this.options.url=A.url;return this.load()};y.prototype.load=function(){var B,A;if((A=this.mainView)!=null){A.clear()}B=this.options.url;if(B.indexOf("http")!==0){B=this.buildUrl(window.location.href.toString(),B)}this.options.url=B;this.headerView.update(B);this.api=new SwaggerClient(this.options);return this.api.build()};y.prototype.render=function(){var A=this;this.showMessage("Finished Loading Resource Information. Rendering Swagger UI...");this.mainView=new u({model:this.api,el:$("#"+this.dom_id),swaggerOptions:this.options}).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)};y.prototype.buildUrl=function(C,A){var B,D;log("base is "+C);if(A.indexOf("/")===0){D=C.split("/");C=D[0]+"//"+D[2];return C+A}else{B=C.length;if(C.indexOf("?")>-1){B=Math.min(B,C.indexOf("?"))}if(C.indexOf("#")>-1){B=Math.min(B,C.indexOf("#"))}C=C.substring(0,B);if(C.indexOf("/",C.length-1)!==-1){return C+A}return C+"/"+A}};y.prototype.showMessage=function(A){if(A==null){A=""}$("#message-bar").removeClass("message-fail");$("#message-bar").addClass("message-success");return $("#message-bar").html(A)};y.prototype.onLoadFailure=function(A){var B;if(A==null){A=""}$("#message-bar").removeClass("message-success");$("#message-bar").addClass("message-fail");B=$("#message-bar").html(A);if(this.options.onFailure!=null){this.options.onFailure(A)}return B};return y})(Backbone.Router);window.SwaggerUi=s;r=(function(z){v(y,z);function y(){h=y.__super__.constructor.apply(this,arguments);return h}y.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"};y.prototype.initialize=function(){};y.prototype.showPetStore=function(A){return this.trigger("update-swagger-ui",{url:"http://petstore.swagger.wordnik.com/api/api-docs"})};y.prototype.showWordnikDev=function(A){return this.trigger("update-swagger-ui",{url:"http://api.wordnik.com/v4/resources.json"})};y.prototype.showCustomOnKeyup=function(A){if(A.keyCode===13){return this.showCustom()}};y.prototype.showCustom=function(A){if(A!=null){A.preventDefault()}return this.trigger("update-swagger-ui",{url:$("#input_baseUrl").val(),apiKey:$("#input_apiKey").val()})};y.prototype.update=function(B,C,A){if(A==null){A=false}$("#input_baseUrl").val(B);if(A){return this.trigger("update-swagger-ui",{url:B})}};return y})(Backbone.View);u=(function(y){var z;v(A,y);function A(){g=A.__super__.constructor.apply(this,arguments);return g}z={alpha:function(C,B){return C.path.localeCompare(B.path)},method:function(C,B){return C.method.localeCompare(B.method)}};A.prototype.initialize=function(B){var C,I,J,E,D,G,H,F;if(B==null){B={}}if(B.swaggerOptions.sorter){E=B.swaggerOptions.sorter;J=z[E];if(this.model.apisArray){F=this.model.apisArray;for(G=0,H=F.length;GB){K=B-C}if(KA){H=A-E}if(H")}this.model.oauth=null;if(this.model.authorizations){E=this.model.authorizations;for(T in E){N=E[T];if(T==="oauth2"){if(this.model.oauth===null){this.model.oauth={}}if(this.model.oauth.scopes===void 0){this.model.oauth.scopes=[]}for(H=0,Y=N.length;H0){D[I.name]=I.value}if(I.type==="file"){N=true}}E=G.find("textarea");for(L=0,F=E.length;L0){D.body=I.value}}B=G.find("select");for(K=0,C=B.length;K0){D[I.name]=J}}A.responseContentType=$("div select[name=responseContentType]",$(this.el)).val();A.requestContentType=$("div select[name=parameterContentType]",$(this.el)).val();$(".response_throbber",$(this.el)).show();if(N){return this.handleFileUpload(D,G)}else{return this.model["do"](D,A,this.showCompleteStatus,this.showErrorStatus,this)}}};y.prototype.success=function(A,B){return B.showCompleteStatus(A)};y.prototype.handleFileUpload=function(R,I){var M,H,C,N,L,K,P,J,G,F,D,Q,U,T,S,E,B,A,V,O=this;E=I.serializeArray();for(J=0,Q=E.length;J0){R[N.name]=N.value}}M=new FormData();P=0;B=this.model.parameters;for(G=0,U=B.length;G
    ");$(".request_url pre",$(this.el)).text(this.invocationUrl);L={type:this.model.method,url:this.invocationUrl,headers:C,data:M,dataType:"json",contentType:false,processData:false,error:function(X,Y,W){return O.showErrorStatus(O.wrap(X),O)},success:function(W){return O.showResponse(W,O)},complete:function(W){return O.showCompleteStatus(O.wrap(W),O)}};if(window.authorizations){window.authorizations.apply(L)}if(P===0){L.data.append("fake","true")}jQuery.ajax(L);return false};y.prototype.wrap=function(E){var C,F,H,B,G,D,A;H={};F=E.getAllResponseHeaders().split("\r");for(D=0,A=F.length;D0){return C.join(",")}else{return null}}};y.prototype.hideResponse=function(A){if(A!=null){A.preventDefault()}$(".response",$(this.el)).slideUp();return $(".response_hider",$(this.el)).fadeOut()};y.prototype.showResponse=function(A){var B;B=JSON.stringify(A,null,"\t").replace(/\n/g,"
    ");return $(".response_body",$(this.el)).html(escape(B))};y.prototype.showErrorStatus=function(B,A){return A.showStatus(B)};y.prototype.showCompleteStatus=function(B,A){return A.showStatus(B)};y.prototype.formatXml=function(H){var D,G,B,I,N,J,C,A,L,M,F,E,K;A=/(>)(<)(\/*)/g;M=/[ ]*(.*)[ ]+\n/g;D=/(<.+>)(.+\n)/g;H=H.replace(A,"$1\n$2$3").replace(M,"$1\n").replace(D,"$1\n$2");C=0;G="";N=H.split("\n");B=0;I="other";L={"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};F=function(T){var P,O,R,V,S,Q,U;Q={single:Boolean(T.match(/<.+\/>/)),closing:Boolean(T.match(/<\/.+>/)),opening:Boolean(T.match(/<[^!?].*>/))};S=((function(){var W;W=[];for(R in Q){U=Q[R];if(U){W.push(R)}}return W})())[0];S=S===void 0?"other":S;P=I+"->"+S;I=S;V="";B+=L[P];V=((function(){var X,Y,W;W=[];for(O=X=0,Y=B;0<=Y?XY;O=0<=Y?++X:--X){W.push(" ")}return W})()).join("");if(P==="opening->closing"){return G=G.substr(0,G.length-1)+T+"\n"}else{return G+=V+T+"\n"}};for(E=0,K=N.length;E").text("no content");E=$('
    ').append(C)}else{if(J==="application/json"||/\+json$/.test(J)){C=$("").text(JSON.stringify(JSON.parse(H),null,"  "));E=$('
    ').append(C)}else{if(J==="application/xml"||/\+xml$/.test(J)){C=$("").text(this.formatXml(H));E=$('
    ').append(C)}else{if(J==="text/html"){C=$("").html(_.escape(H));E=$('
    ').append(C)}else{if(/^image\//.test(J)){E=$("").attr("src",B)}else{C=$("").text(H);E=$('
    ').append(C)}}}}}I=E;$(".request_url",$(this.el)).html("
    ");$(".request_url pre",$(this.el)).text(B);$(".response_code",$(this.el)).html("
    "+F.status+"
    ");$(".response_body",$(this.el)).html(I);$(".response_headers",$(this.el)).html("
    "+_.escape(JSON.stringify(F.headers,null,"  ")).replace(/\n/g,"
    ")+"
    ");$(".response",$(this.el)).slideDown();$(".response_hider",$(this.el)).show();$(".response_throbber",$(this.el)).hide();G=$(".response_body",$(this.el))[0];A=this.options.swaggerOptions;if(A.highlightSizeThreshold&&F.data.length>A.highlightSizeThreshold){return G}else{return hljs.highlightBlock(G)}};y.prototype.toggleOperationContent=function(){var A;A=$("#"+Docs.escapeResourceName(this.model.parentId)+"_"+this.model.nickname+"_content");if(A.is(":visible")){return Docs.collapseOperation(A)}else{return Docs.expandOperation(A)}};return y})(Backbone.View);p=(function(z){v(y,z);function y(){d=y.__super__.constructor.apply(this,arguments);return d}y.prototype.initialize=function(){};y.prototype.render=function(){var B,A,C;C=this.template();$(this.el).html(C(this.model));if(swaggerUi.api.models.hasOwnProperty(this.model.responseModel)){B={sampleJSON:JSON.stringify(swaggerUi.api.models[this.model.responseModel].createJSONSample(),null,2),isParam:false,signature:swaggerUi.api.models[this.model.responseModel].getMockSignature()};A=new i({model:B,tagName:"div"});$(".model-signature",this.$el).append(A.render().el)}else{$(".model-signature",this.$el).html("")}return this};y.prototype.template=function(){return Handlebars.templates.status_code};return y})(Backbone.View);k=(function(z){v(y,z);function y(){b=y.__super__.constructor.apply(this,arguments);return b}y.prototype.initialize=function(){return Handlebars.registerHelper("isArray",function(B,A){if(B.type.toLowerCase()==="array"||B.allowMultiple){return A.fn(this)}else{return A.inverse(this)}})};y.prototype.render=function(){var A,B,E,C,F,D,I,J,H,G;G=this.model.type||this.model.dataType;if(typeof G==="undefined"){D=this.model.schema;if(D["$ref"]){C=D["$ref"];if(C.indexOf("#/definitions/")===0){G=C.substring("#/definitions/".length)}else{G=C}}}this.model.type=G;this.model.paramType=this.model["in"]||this.model.paramType;if(this.model.paramType==="body"){this.model.isBody=true}if(G&&G.toLowerCase()==="file"){this.model.isFile=true}H=this.template();$(this.el).html(H(this.model));I={sampleJSON:this.model.sampleJSON,isParam:true,signature:this.model.signature};if(this.model.sampleJSON){J=new i({model:I,tagName:"div"});$(".model-signature",$(this.el)).append(J.render().el)}else{$(".model-signature",$(this.el)).html(this.model.signature)}B=false;if(this.model.isBody){B=true}A={isParam:B};A.consumes=this.model.consumes;if(B){E=new l({model:A});$(".parameter-content-type",$(this.el)).append(E.render().el)}else{F=new m({model:A});$(".response-content-type",$(this.el)).append(F.render().el)}return this};y.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 y})(Backbone.View);i=(function(z){v(y,z);function y(){a=y.__super__.constructor.apply(this,arguments);return a}y.prototype.events={"click a.description-link":"switchToDescription","click a.snippet-link":"switchToSnippet","mousedown .snippet":"snippetToTextArea"};y.prototype.initialize=function(){};y.prototype.render=function(){var A;A=this.template();$(this.el).html(A(this.model));this.switchToSnippet();this.isParam=this.model.isParam;if(this.isParam){$(".notice",$(this.el)).text("Click to set as parameter value")}return this};y.prototype.template=function(){return Handlebars.templates.signature};y.prototype.switchToDescription=function(A){if(A!=null){A.preventDefault()}$(".snippet",$(this.el)).hide();$(".description",$(this.el)).show();$(".description-link",$(this.el)).addClass("selected");return $(".snippet-link",$(this.el)).removeClass("selected")};y.prototype.switchToSnippet=function(A){if(A!=null){A.preventDefault()}$(".description",$(this.el)).hide();$(".snippet",$(this.el)).show();$(".snippet-link",$(this.el)).addClass("selected");return $(".description-link",$(this.el)).removeClass("selected")};y.prototype.snippetToTextArea=function(A){var B;if(this.isParam){if(A!=null){A.preventDefault()}B=$("textarea",$(this.el.parentNode.parentNode.parentNode));if($.trim(B.val())===""){return B.val(this.model.sampleJSON)}}};return y})(Backbone.View);j=(function(y){v(z,y);function z(){x=z.__super__.constructor.apply(this,arguments);return x}z.prototype.initialize=function(){};z.prototype.render=function(){var A;A=this.template();$(this.el).html(A(this.model));$("label[for=contentType]",$(this.el)).text("Response Content Type");return this};z.prototype.template=function(){return Handlebars.templates.content_type};return z})(Backbone.View);m=(function(y){v(z,y);function z(){w=z.__super__.constructor.apply(this,arguments);return w}z.prototype.initialize=function(){};z.prototype.render=function(){var A;A=this.template();$(this.el).html(A(this.model));$("label[for=responseContentType]",$(this.el)).text("Response Content Type");return this};z.prototype.template=function(){return Handlebars.templates.response_content_type};return z})(Backbone.View);l=(function(z){v(y,z);function y(){c=y.__super__.constructor.apply(this,arguments);return c}y.prototype.initialize=function(){};y.prototype.render=function(){var A;A=this.template();$(this.el).html(A(this.model));$("label[for=parameterContentType]",$(this.el)).text("Parameter content type:");return this};y.prototype.template=function(){return Handlebars.templates.parameter_content_type};return y})(Backbone.View)}).call(this); \ No newline at end of file diff --git a/src/main/coffeescript/view/MainView.coffee b/src/main/coffeescript/view/MainView.coffee index b55b2b22..5be6d1a1 100644 --- a/src/main/coffeescript/view/MainView.coffee +++ b/src/main/coffeescript/view/MainView.coffee @@ -14,13 +14,15 @@ class MainView extends Backbone.View if (sorterName == "alpha") # sort top level paths if alpha @model.apisArray.sort sorter - log @model if @model.info and @model.info.license and typeof @model.info.license is 'string' name = @model.info.license url = @model.info.licenseUrl @model.info.license = {} @model.info.license.name = name @model.info.license.url = url + + if @model.url.indexOf('http://localhost') is -1 and @model.swaggerVersion is 2 + @model.validatorUrl = @model.url render: -> # Render the outer container for resources diff --git a/src/main/template/main.handlebars b/src/main/template/main.handlebars index 052c9c3f..8399267a 100644 --- a/src/main/template/main.handlebars +++ b/src/main/template/main.handlebars @@ -17,6 +17,11 @@

    [ base url: {{basePath}} {{#if apiVersion}} , api version: {{apiVersion}} - {{/if}}]

    + {{/if}}] + {{#if validatorUrl}} + + + {{/if}} +