From cf1060ce23bf88c63f485222d0037996419fa0f4 Mon Sep 17 00:00:00 2001 From: Tony Tam Date: Tue, 6 Jan 2015 17:45:06 -0800 Subject: [PATCH] fixed headers, file upload per #662 --- lib/swagger-client.js | 309 +++++++++++++++++--------- lib/swagger.js | 496 ++++++++++++++++++++++-------------------- swagger-ui.js | 6 +- swagger-ui.min.js | 2 +- 4 files changed, 471 insertions(+), 342 deletions(-) diff --git a/lib/swagger-client.js b/lib/swagger-client.js index 1f9ee683125..cd40c01c57b 100644 --- a/lib/swagger-client.js +++ b/lib/swagger-client.js @@ -1,5 +1,5 @@ // swagger-client.js -// version 2.1.0-alpha.4 +// version 2.1.0-alpha.5 /** * Array Model **/ @@ -538,18 +538,21 @@ var OperationGroup = function(tag, operation) { var Operation = function(parent, operationId, httpMethod, path, args, definitions) { var errors = []; + parent = parent||{}; + args = args||{}; + this.operation = args; this.deprecated = args.deprecated; this.consumes = args.consumes; this.produces = args.produces; this.parent = parent; - this.host = parent.host; + this.host = parent.host || 'localhost'; this.schemes = parent.schemes; this.scheme = parent.scheme || 'http'; - this.basePath = parent.basePath; + this.basePath = parent.basePath || '/'; this.nickname = (operationId||errors.push('Operations must have a nickname.')); this.method = (httpMethod||errors.push('Operation ' + operationId + ' is missing method.')); - this.path = (path||errors.push('Operation ' + nickname + ' is missing path.')); + this.path = (path||errors.push('Operation ' + this.nickname + ' is missing path.')); this.parameters = args != null ? (args.parameters||[]) : {}; this.summary = args.summary || ''; this.responses = (args.responses||{}); @@ -643,8 +646,10 @@ var Operation = function(parent, operationId, httpMethod, path, args, definition } } - if (errors.length > 0) - this.resource.api.fail(errors); + if (errors.length > 0) { + if(this.resource && this.resource.api && this.resource.api.fail) + this.resource.api.fail(errors); + } return this; } @@ -719,12 +724,16 @@ Operation.prototype.resolveModel = function (schema, definitions) { return null; } -Operation.prototype.help = function() { - log(this.nickname + ': ' + this.operation.summary); +Operation.prototype.help = function(dontPrint) { + var out = this.nickname + ': ' + this.summary + '\n'; for(var i = 0; i < this.parameters.length; i++) { var param = this.parameters[i]; - log(' * ' + param.name + ': ' + param.description); + var typeInfo = typeFromJsonSchema(param.type, param.format); + out += '\n * ' + param.name + ' (' + typeInfo + '): ' + param.description; } + if(typeof dontPrint === 'undefined') + log(out); + return out; } Operation.prototype.getSignature = function(type, models) { @@ -749,6 +758,121 @@ Operation.prototype.getSignature = function(type, models) { } }; +Operation.prototype.supportHeaderParams = function () { + return true; +}; + +Operation.prototype.supportedSubmitMethods = function () { + return this.resource.api.supportedSubmitMethods; +}; + +Operation.prototype.getHeaderParams = function (args) { + var headers = this.setContentTypes(args, {}); + for(var i = 0; i < this.parameters.length; i++) { + var param = this.parameters[i]; + if(typeof args[param.name] !== 'undefined') { + if (param.in === 'header') { + var value = args[param.name]; + if(Array.isArray(value)) + value = this.encodePathCollection(param.collectionFormat, param.name, value); + else + value = this.encodePathParam(value); + headers[param.name] = value; + } + } + } + return headers; +} + +Operation.prototype.urlify = function (args) { + var formParams = {}; + var requestUrl = this.path; + + // grab params from the args, build the querystring along the way + var querystring = ''; + for(var i = 0; i < this.parameters.length; i++) { + var param = this.parameters[i]; + if(typeof args[param.name] !== 'undefined') { + if(param.in === 'path') { + var reg = new RegExp('\{' + param.name + '[^\}]*\}', 'gi'); + var value = args[param.name]; + if(Array.isArray(value)) + value = this.encodePathCollection(param.collectionFormat, param.name, value); + else + value = this.encodePathParam(value); + requestUrl = requestUrl.replace(reg, value); + } + else if (param.in === 'query' && typeof args[param.name] !== 'undefined') { + if(querystring === '') + querystring += '?'; + else + querystring += '&'; + if(typeof param.collectionFormat !== 'undefined') { + var qp = args[param.name]; + if(Array.isArray(qp)) + querystring += this.encodeQueryCollection(param.collectionFormat, param.name, qp); + else + querystring += this.encodeQueryParam(param.name) + '=' + this.encodeQueryParam(args[param.name]); + } + else + querystring += this.encodeQueryParam(param.name) + '=' + this.encodeQueryParam(args[param.name]); + } + else if (param.in === 'formData') + formParams[param.name] = args[param.name]; + } + } + var url = this.scheme + '://' + this.host; + + if(this.basePath !== '/') + url += this.basePath; + + return url + requestUrl + querystring; +} + +Operation.prototype.getMissingParams = function(args) { + var missingParams = []; + // check required params, track the ones that are missing + var i; + for(i = 0; i < this.parameters.length; i++) { + var param = this.parameters[i]; + if(param.required === true) { + if(typeof args[param.name] === 'undefined') + missingParams = param.name; + } + } + return missingParams; +} + +Operation.prototype.getBody = function(headers, args) { + var formParams = {}; + var body; + + for(var i = 0; i < this.parameters.length; i++) { + var param = this.parameters[i]; + if(typeof args[param.name] !== 'undefined') { + if (param.in === 'body') + body = args[param.name]; + } + } + + // handle form params + if(headers['Content-Type'] === 'application/x-www-form-urlencoded') { + var encoded = ""; + var key; + for(key in formParams) { + value = formParams[key]; + if(typeof value !== 'undefined'){ + if(encoded !== "") + encoded += "&"; + encoded += encodeURIComponent(key) + '=' + encodeURIComponent(value); + } + } + body = encoded; + } + + return body; +} + /** * gets sample response for a single operation **/ @@ -778,7 +902,7 @@ Operation.prototype.getSampleJSON = function(type, models) { else return sampleJson; } -}; +} /** * legacy binding @@ -787,112 +911,42 @@ Operation.prototype["do"] = function(args, opts, callback, error, parent) { return this.execute(args, opts, callback, error, parent); } + /** * executes an operation **/ Operation.prototype.execute = function(arg1, arg2, arg3, arg4, parent) { - var args = (arg1||{}); + var args = arg1 || {}; var opts = {}, success, error; if(typeof arg2 === 'object') { opts = arg2; success = arg3; error = arg4; } + if(typeof arg2 === 'function') { success = arg2; error = arg3; } - var formParams = {}; - var headers = {}; - var requestUrl = this.path; - success = (success||log) error = (error||log) - var requiredParams = []; - var missingParams = []; - // check required params, track the ones that are missing - var i; - for(i = 0; i < this.parameters.length; i++) { - var param = this.parameters[i]; - if(param.required === true) { - requiredParams.push(param.name); - if(typeof args[param.name] === 'undefined') - missingParams = param.name; - } - } - + var missingParams = this.getMissingParams(args); if(missingParams.length > 0) { var message = 'missing required params: ' + missingParams; fail(message); return; } - // set content type negotiation - var consumes = this.consumes || this.parent.consumes || [ 'application/json' ]; - var produces = this.produces || this.parent.produces || [ 'application/json' ]; - - headers = this.setContentTypes(args, opts); - - // grab params from the args, build the querystring along the way - var querystring = ""; - for(var i = 0; i < this.parameters.length; i++) { - var param = this.parameters[i]; - if(typeof args[param.name] !== 'undefined') { - if(param.in === 'path') { - var reg = new RegExp('\{' + param.name + '[^\}]*\}', 'gi'); - requestUrl = requestUrl.replace(reg, this.encodePathParam(args[param.name])); - } - else if (param.in === 'query' && typeof args[param.name] !== 'undefined') { - if(querystring === '') - querystring += '?'; - else - querystring += '&'; - if(typeof param.collectionFormat !== 'undefined') { - var qp = args[param.name]; - if(Array.isArray(qp)) - querystring += this.encodeCollection(param.collectionFormat, param.name, qp); - else - querystring += this.encodeQueryParam(param.name) + '=' + this.encodeQueryParam(args[param.name]); - } - else - querystring += this.encodeQueryParam(param.name) + '=' + this.encodeQueryParam(args[param.name]); - } - else if (param.in === 'header') - headers[param.name] = args[param.name]; - else if (param.in === 'formData') - formParams[param.name] = args[param.name]; - else if (param.in === 'body') - args.body = args[param.name]; - } - } - // handle form params - if(headers['Content-Type'] === 'application/x-www-form-urlencoded') { - var encoded = ""; - var key; - for(key in formParams) { - value = formParams[key]; - if(typeof value !== 'undefined'){ - if(encoded !== "") - encoded += "&"; - encoded += encodeURIComponent(key) + '=' + encodeURIComponent(value); - } - } - // todo append? - args.body = encoded; - } - var url = this.scheme + '://' + this.host; - - if(this.basePath !== '/') - url += this.basePath; - - url += requestUrl + querystring; + var headers = this.getHeaderParams(args); + var body = this.getBody(headers, args); + var url = this.urlify(args) var obj = { url: url, method: this.method, - body: args.body, + body: body, useJQuery: this.useJQuery, headers: headers, on: { @@ -911,46 +965,53 @@ Operation.prototype.execute = function(arg1, arg2, arg3, arg4, parent) { Operation.prototype.setContentTypes = function(args, opts) { // default type var accepts = 'application/json'; - var consumes = 'application/json'; + var consumes = args.parameterContentType || 'application/json'; var allDefinedParams = this.parameters; var definedFormParams = []; var definedFileParams = []; - var body = args.body; + var 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.in === 'formData') - definedFormParams.push(param); - else if(param.in === 'file') - definedFileParams.push(param); + if(param.in === 'formData') { + if(param.type === 'file') + definedFileParams.push(param); + else + definedFormParams.push(param); + } else if(param.in === 'header' && this.headers) { var key = param.name; var headerValue = this.headers[param.name]; if(typeof this.headers[param.name] !== 'undefined') headers[key] = headerValue; } + else if(param.in === 'body' && typeof args[param.name] !== 'undefined') { + body = args[param.name]; + } } - // if there's a body, need to set the accepts header via requestContentType + // if there's a body, need to set the consumes header via requestContentType if (body && (this.method === 'post' || this.method === 'put' || this.method === 'patch' || this.method === 'delete')) { if (opts.requestContentType) consumes = opts.requestContentType; } else { // if any form params, content type must be set if(definedFormParams.length > 0) { - if(definedFileParams.length > 0) + if(opts.requestContentType) // override if set + consumes = opts.requestContentType; + else if(definedFileParams.length > 0) // if a file, must be multipart/form-data consumes = 'multipart/form-data'; - else + else // default to x-www-from-urlencoded consumes = 'application/x-www-form-urlencoded'; } else if (this.type == 'DELETE') body = '{}'; else if (this.type != 'DELETE') - accepts = null; + consumes = null; } if (consumes && this.consumes) { @@ -979,7 +1040,40 @@ Operation.prototype.setContentTypes = function(args, opts) { return headers; } -Operation.prototype.encodeCollection = function(type, name, value) { +Operation.prototype.asCurl = function (args) { + var results = []; + var headers = this.getHeaderParams(args); + if (headers) { + var key; + for (key in headers) + results.push("--header \"" + key + ": " + headers[key] + "\""); + } + return "curl " + (results.join(" ")) + " " + this.urlify(args); +} + +Operation.prototype.encodePathCollection = function(type, name, value) { + var encoded = ''; + var i; + var separator = ''; + if(type === 'ssv') + separator = '%20'; + else if(type === 'tsv') + separator = '\\t'; + else if(type === 'pipes') + separator = '|'; + else + separator = ','; + + for(i = 0; i < value.length; i++) { + if(i == 0) + encoded = this.encodeQueryParam(value[i]); + else + encoded += separator + this.encodeQueryParam(value[i]); + } + return encoded; +} + +Operation.prototype.encodeQueryCollection = function(type, name, value) { var encoded = ''; var i; if(type === 'default' || type === 'multi') { @@ -998,6 +1092,13 @@ Operation.prototype.encodeCollection = function(type, name, value) { separator = '\\t'; else if(type === 'pipes') separator = '|'; + else if(type === 'brackets') { + for(i = 0; i < value.length; i++) { + if(i !== 0) + encoded += '&'; + encoded += this.encodeQueryParam(name) + '[]=' + this.encodeQueryParam(value[i]); + } + } if(separator !== '') { for(i = 0; i < value.length; i++) { if(i == 0) @@ -1007,7 +1108,6 @@ Operation.prototype.encodeCollection = function(type, name, value) { } } } - // TODO: support the different encoding schemes here return encoded; } @@ -1022,16 +1122,15 @@ Operation.prototype.encodeQueryParam = function(arg) { * TODO revisit, might not want to leave '/' **/ Operation.prototype.encodePathParam = function(pathParam) { - var encParts, part, parts, _i, _len; + 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)); + for (i = 0, len = parts.length; i < len; i++) { + encParts.push(encodeURIComponent(parts[i])); } return encParts.join('/'); } @@ -1278,7 +1377,7 @@ e.ApiKeyAuthorization = ApiKeyAuthorization; e.PasswordAuthorization = PasswordAuthorization; e.CookieAuthorization = CookieAuthorization; e.SwaggerClient = SwaggerClient; - +e.Operation = Operation; /** * SwaggerHttp is a wrapper for executing requests */ diff --git a/lib/swagger.js b/lib/swagger.js index 37854cda879..214bbca3e04 100644 --- a/lib/swagger.js +++ b/lib/swagger.js @@ -1,8 +1,7 @@ // swagger.js -// version 2.0.47 +// version 2.0.48 (function () { - var __bind = function (fn, me) { return function () { return fn.apply(me, arguments); @@ -17,14 +16,27 @@ } }; - // if you want to apply conditional formatting of parameter values - var parameterMacro = function (value) { - return value; + /** + * allows override of the default value based on the parameter being + * supplied + **/ + var applyParameterMacro = function (model, parameter) { + var e = (typeof window !== 'undefined' ? window : exports); + if(e.parameterMacro) + return e.parameterMacro(model, parameter); + else + return parameter.defaultValue; } - // if you want to apply conditional formatting of model property values - var modelPropertyMacro = function (value) { - return value; + /** + * allows overriding the default value of an operation + **/ + var applyModelPropertyMacro = function (operation, property) { + var e = (typeof window !== 'undefined' ? window : exports); + if(e.modelPropertyMacro) + return e.modelPropertyMacro(operation, property); + else + return property.defaultValue; } if (!Array.prototype.indexOf) { @@ -58,21 +70,21 @@ Object.keys = Object.keys || (function () { var hasOwnProperty = Object.prototype.hasOwnProperty, - hasDontEnumBug = !{ toString: null }.propertyIsEnumerable("toString"), + hasDontEnumBug = !{ toString: null }.propertyIsEnumerable('toString'), DontEnums = [ - 'toString', - 'toLocaleString', - 'valueOf', - 'hasOwnProperty', - 'isPrototypeOf', - 'propertyIsEnumerable', - 'constructor' + 'toString', + 'toLocaleString', + 'valueOf', + 'hasOwnProperty', + 'isPrototypeOf', + 'propertyIsEnumerable', + 'constructor' ], - DontEnumsLength = DontEnums.length; + DontEnumsLength = DontEnums.length; return function (o) { - if (typeof o != "object" && typeof o != "function" || o === null) - throw new TypeError("Object.keys called on a non-object"); + if (typeof o != 'object' && typeof o != 'function' || o === null) + throw new TypeError('Object.keys called on a non-object'); var result = []; for (var name in o) { @@ -115,21 +127,32 @@ if (options.url != null) this.url = options.url; + this.swaggerRequstHeaders = options.swaggerRequstHeaders || 'application/json,application/json;charset=utf-8,*/*'; + this.defaultSuccessCallback = options.defaultSuccessCallback || null; + this.defaultErrorCallback = options.defaultErrorCallback || null; + if (options.success != null) this.success = options.success; if (typeof options.useJQuery === 'boolean') this.useJQuery = options.useJQuery; + if (options.authorizations) { + this.clientAuthorizations = options.authorizations; + } else { + var e = (typeof window !== 'undefined' ? window : exports); + this.clientAuthorizations = e.authorizations; + } + this.failure = options.failure != null ? options.failure : function () { }; this.progress = options.progress != null ? options.progress : function () { }; if (options.success != null) { this.build(); this.isBuilt = true; } - } + }; - SwaggerApi.prototype.build = function () { + SwaggerApi.prototype.build = function (mock) { if (this.isBuilt) return this; var _this = this; @@ -137,9 +160,9 @@ var obj = { useJQuery: this.useJQuery, url: this.url, - method: "get", + method: 'GET', headers: { - accept: "application/json,application/json;charset=utf-8,*/*" + accept: _this.swaggerRequstHeaders }, on: { error: function (response) { @@ -156,7 +179,7 @@ response: function (resp) { var responseObj = resp.obj || JSON.parse(resp.data); _this.swaggerVersion = responseObj.swaggerVersion; - if (_this.swaggerVersion === "1.2") { + if (_this.swaggerVersion === '1.2') { return _this.buildFromSpec(responseObj); } else { return _this.buildFrom1_1Spec(responseObj); @@ -166,6 +189,9 @@ }; var e = (typeof window !== 'undefined' ? window : exports); e.authorizations.apply(obj); + if (mock === true) + return obj; + new SwaggerHttp().execute(obj); return this; }; @@ -224,7 +250,7 @@ }; 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"); + 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 = {}; @@ -272,13 +298,13 @@ }; SwaggerApi.prototype.selfReflect = function () { - var resource, resource_name, _ref; + var resource, resource_name, ref; if (this.apis == null) { return false; } - _ref = this.apis; - for (resource_name in _ref) { - resource = _ref[resource_name]; + ref = this.apis; + for (resource_name in ref) { + resource = ref[resource_name]; if (resource.ready == null) { return false; } @@ -326,11 +352,11 @@ _ref1 = resource.operations; for (operation_name in _ref1) { operation = _ref1[operation_name]; - log(" " + operation.nickname); + 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); + log(' ' + parameter.name + (parameter.required ? ' (required)' : '') + ' - ' + parameter.description); } } } @@ -340,13 +366,12 @@ var SwaggerResource = function (resourceObj, api) { var _this = this; this.api = api; - this.api = this.api; - var consumes = (this.consumes | []); - var produces = (this.produces | []); + this.swaggerRequstHeaders = api.swaggerRequstHeaders; this.path = this.api.resourcePath != null ? this.api.resourcePath : resourceObj.path; this.description = resourceObj.description; + this.authorizations = (resourceObj.authorizations || {}); - var parts = this.path.split("/"); + var parts = this.path.split('/'); this.name = parts[parts.length - 1].replace('.{format}', ''); this.basePath = this.api.basePath; this.operations = {}; @@ -360,7 +385,7 @@ this.addApiDeclaration(resourceObj); } else { if (this.path == null) { - this.api.fail("SwaggerResources must have a path."); + this.api.fail('SwaggerResources must have a path.'); } if (this.path.substring(0, 4) === 'http') { this.url = this.path.replace('{format}', 'json'); @@ -370,10 +395,10 @@ this.api.progress('fetching resource ' + this.name + ': ' + this.url); var obj = { url: this.url, - method: "get", + method: 'GET', useJQuery: this.useJQuery, headers: { - accept: "application/json,application/json;charset=utf-8,*/*" + accept: this.swaggerRequstHeaders }, on: { response: function (resp) { @@ -381,8 +406,8 @@ 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 _this.api.fail('Unable to read api \'' + + _this.name + '\' from path ' + _this.url + ' (server returned ' + response.statusText + ')'); } } }; @@ -396,24 +421,24 @@ var pos, url; url = this.api.basePath; pos = url.lastIndexOf(relativeBasePath); - var parts = url.split("/"); - var rootUrl = parts[0] + "//" + parts[2]; + var parts = url.split('/'); + var rootUrl = parts[0] + '//' + parts[2]; - if (relativeBasePath.indexOf("http") === 0) + if (relativeBasePath.indexOf('http') === 0) return relativeBasePath; - if (relativeBasePath === "/") + if (relativeBasePath === '/') return rootUrl; - if (relativeBasePath.substring(0, 1) == "/") { + if (relativeBasePath.substring(0, 1) == '/') { // use root + relative return rootUrl + relativeBasePath; } else { - var pos = this.basePath.lastIndexOf("/"); + var pos = this.basePath.lastIndexOf('/'); var base = this.basePath.substring(0, pos); - if (base.substring(base.length - 1) == "/") + if (base.substring(base.length - 1) == '/') return base + relativeBasePath; else - return base + "/" + relativeBasePath; + return base + '/' + relativeBasePath; } }; @@ -423,7 +448,7 @@ 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.basePath = response.basePath.indexOf('http') === -1 ? this.getAbsoluteBasePath(response.basePath) : response.basePath; this.addModels(response.models); if (response.apis) { @@ -475,11 +500,11 @@ produces = this.produces; var type = (o.type || o.responseClass); - if (type === "array") { + if (type === 'array') { ref = null; if (o.items) - ref = o.items["type"] || o.items["$ref"]; - type = "array[" + ref + "]"; + ref = o.items['type'] || o.items['$ref']; + type = 'array[' + ref + ']'; } var responseMessages = o.responseMessages; var method = o.method; @@ -515,22 +540,6 @@ 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 = []; @@ -544,7 +553,7 @@ } } } - var prop = new SwaggerModelProperty(propertyName, obj.properties[propertyName]); + var prop = new SwaggerModelProperty(propertyName, obj.properties[propertyName], this); this.properties.push(prop); } } @@ -572,7 +581,6 @@ } var strong = ''; - var stronger = ''; var strongClose = ''; var classOpen = strong + this.name + ' {' + strongClose; var classClose = strong + '}' + strongClose; @@ -607,13 +615,13 @@ } }; - var SwaggerModelProperty = function (name, obj) { + var SwaggerModelProperty = function (name, obj, model) { this.name = name; - this.dataType = obj.type || obj.dataType || obj["$ref"]; + 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); + this.defaultValue = applyModelPropertyMacro(obj, model); if (obj.items != null) { if (obj.items.type != null) { this.refDataType = obj.items.type; @@ -627,14 +635,14 @@ this.valueType = obj.allowableValues.valueType; this.values = obj.allowableValues.values; if (this.values != null) { - this.valuesString = "'" + this.values.join("' or '") + "'"; + this.valuesString = '\'' + this.values.join('\' or \'') + '\''; } } - if (obj["enum"] != null) { - this.valueType = "string"; - this.values = obj["enum"]; + if (obj['enum'] != null) { + this.valueType = 'string'; + this.values = obj['enum']; if (this.values != null) { - this.valueString = "'" + this.values.join("' or '") + "'"; + this.valueString = '\'' + this.values.join('\' or \'') + '\''; } } } @@ -661,14 +669,14 @@ var result; if ((typeof this.defaultValue !== 'undefined') && this.defaultValue !== null) { result = this.defaultValue; - } else if (value === "integer") { + } else if (value === 'integer') { result = 0; - } else if (value === "boolean") { + } else if (value === 'boolean') { result = false; - } else if (value === "double" || value === "number") { + } else if (value === 'double' || value === 'number') { result = 0.0; - } else if (value === "string") { - result = ""; + } else if (value === 'string') { + result = ''; } else { result = value; } @@ -683,7 +691,7 @@ } str += ')'; if (this.values != null) { - str += " = ['" + this.values.join("' or '") + "']"; + str += ' = ["' + this.values.join('\' or \'') + '\']'; } if (this.descr != null) { str += ': ' + this.descr + ''; @@ -695,20 +703,20 @@ 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.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.resource = (resource || errors.push('Resource is required')); this.consumes = consumes; this.produces = produces; - this.authorizations = authorizations; + this.authorizations = typeof authorizations !== 'undefined' ? authorizations : resource.authorizations; this.deprecated = deprecated; - this["do"] = __bind(this["do"], this); + this['do'] = __bind(this['do'], this); if (errors.length > 0) { console.error('SwaggerOperation errors', errors, arguments); @@ -717,7 +725,7 @@ this.path = this.path.replace('{format}', 'json'); this.method = this.method.toLowerCase(); - this.isGetMethod = this.method === "get"; + this.isGetMethod = this.method === 'GET'; this.resourceName = this.resource.name; if (typeof this.type !== 'undefined' && this.type === 'void') @@ -741,12 +749,12 @@ if (type && type.toLowerCase() === 'boolean') { param.allowableValues = {}; - param.allowableValues.values = ["true", "false"]; + 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"]; + var enumValue = param['enum']; if (enumValue != null) { param.isList = true; param.allowableValues = {}; @@ -769,7 +777,7 @@ } } else if (param.allowableValues != null) { - if (param.allowableValues.valueType === "RANGE") + if (param.allowableValues.valueType === 'RANGE') param.isRange = true; else param.isList = true; @@ -794,14 +802,29 @@ } } } - param.defaultValue = parameterMacro(param.defaultValue); - } - this.resource[this.nickname] = function (args, callback, error) { - return _this["do"](args, callback, error); + param.defaultValue = applyParameterMacro(param, this); + } + var defaultSuccessCallback = this.resource.api.defaultSuccessCallback || null; + var defaultErrorCallback = this.resource.api.defaultErrorCallback || null; + + this.resource[this.nickname] = function (args, opts, callback, error) { + var arg1 = args, + arg2 = opts, + arg3 = callback || defaultSuccessCallback, + arg4 = error || defaultErrorCallback; + if(typeof opts === 'function') { + arg2 = {}; + arg3 = opts; + arg4 = error; + } + return _this['do'](arg1, arg2, arg3, arg4); }; this.resource[this.nickname].help = function () { return _this.help(); }; + this.resource[this.nickname].asCurl = function (args) { + return _this.asCurl(args); + }; } SwaggerOperation.prototype.isListType = function (type) { @@ -834,9 +857,9 @@ val = isPrimitive ? void 0 : (listType != null ? models[listType].createJSONSample() : models[type].createJSONSample()); if (val) { val = listType ? [val] : val; - if (typeof val == "string") + if (typeof val == 'string') return val; - else if (typeof val === "object") { + else if (typeof val === 'object') { var t = val; if (val instanceof Array && val.length > 0) { t = val[0]; @@ -853,22 +876,17 @@ } }; - 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") { + SwaggerOperation.prototype['do'] = function (args, opts, callback, error) { + var key, param, params, possibleParams, req, value; + args = args || {}; + opts = opts || {}; + + if ((typeof args) === 'function') { error = opts; callback = args; args = {}; } - if ((typeof opts) === "function") { + if ((typeof opts) === 'function') { error = callback; callback = opts; } @@ -884,9 +902,9 @@ if (response != null) { content = response.data; } else { - content = "no data"; + content = 'no data'; } - return log("default callback: " + content); + return log('default callback: ' + content); }; } params = {}; @@ -895,19 +913,26 @@ params.headers = args.headers; delete args.headers; } + // allow override from the opts + if(opts && opts.responseContentType) { + params.headers['Content-Type'] = opts.responseContentType; + } + if(opts && opts.requestContentType) { + params.headers['Accept'] = opts.requestContentType; + } var possibleParams = []; for (var i = 0; i < this.parameters.length; i++) { var param = this.parameters[i]; if (param.paramType === 'header') { - if (args[param.name]) + if (typeof args[param.name] !== 'undefined') params.headers[param.name] = args[param.name]; } else if (param.paramType === 'form' || param.paramType.toLowerCase() === 'file') possibleParams.push(param); - else if (param.paramType === 'body' && param.name !== 'body') { + else if (param.paramType === 'body' && param.name !== 'body' && typeof args[param.name] !== 'undefined') { if (args.body) { - throw new Error("Saw two body params in an API listing; expecting a max of one."); + throw new Error('Saw two body params in an API listing; expecting a max of one.'); } args.body = args[param.name]; } @@ -927,7 +952,6 @@ } } } - req = new SwaggerRequest(this.method, this.urlify(args), params, opts, callback, error, this); if (opts.mock != null) { return req; @@ -937,26 +961,26 @@ }; SwaggerOperation.prototype.pathJson = function () { - return this.path.replace("{format}", "json"); + return this.path.replace('{format}', 'json'); }; SwaggerOperation.prototype.pathXml = function () { - return this.path.replace("{format}", "xml"); + return this.path.replace('{format}', 'xml'); }; SwaggerOperation.prototype.encodePathParam = function (pathParam) { var encParts, part, parts, _i, _len; pathParam = pathParam.toString(); - if (pathParam.indexOf("/") === -1) { + if (pathParam.indexOf('/') === -1) { return encodeURIComponent(pathParam); } else { - parts = pathParam.split("/"); + parts = pathParam.split('/'); encParts = []; for (_i = 0, _len = parts.length; _i < _len; _i++) { part = parts[_i]; encParts.push(encodeURIComponent(part)); } - return encParts.join("/"); + return encParts.join('/'); } }; @@ -966,18 +990,18 @@ for (var i = 0; i < params.length; i++) { var param = params[i]; if (param.paramType === 'path') { - if (args[param.name]) { + if (typeof args[param.name] !== 'undefined') { // 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."; + throw '' + param.name + ' is a required path param.'; } } - var queryParams = ""; + var queryParams = ''; for (var i = 0; i < params.length; i++) { var param = params[i]; if(param.paramType === 'query') { @@ -994,11 +1018,11 @@ queryParams += encodeURIComponent(param.name) + '=' + output; } else { - if (args[param.name]) { + if (typeof args[param.name] !== 'undefined') { queryParams += encodeURIComponent(param.name) + '=' + encodeURIComponent(args[param.name]); } else { if (param.required) - throw "" + param.name + " is a required query param."; + throw '' + param.name + ' is a required query param.'; } } } @@ -1042,17 +1066,35 @@ }; SwaggerOperation.prototype.help = function () { - var msg = ""; + 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; + if (msg !== '') + msg += '\n'; + msg += '* ' + param.name + (param.required ? ' (required)' : '') + " - " + param.description; } return msg; }; + SwaggerOperation.prototype.asCurl = function (args) { + var results = []; + var i; + + var headers = SwaggerRequest.prototype.setHeaders(args, {}, this); + for(i = 0; i < this.parameters.length; i++) { + var param = this.parameters[i]; + if(param.paramType && param.paramType === 'header' && args[param.name]) { + headers[param.name] = args[param.name]; + } + } + + var key; + for (key in headers) { + results.push('--header "' + key + ': ' + headers[key] + '"'); + } + return 'curl ' + (results.join(' ')) + ' ' + this.urlify(args); + }; SwaggerOperation.prototype.formatXml = function (xml) { var contexp, formatted, indent, lastType, lines, ln, pad, reg, transitions, wsexp, _fn, _i, _len; @@ -1131,13 +1173,13 @@ 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.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.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 || {}); @@ -1148,37 +1190,37 @@ this.type = this.type.toUpperCase(); // set request, response content type headers - var headers = this.setHeaders(params, this.operation); + var headers = this.setHeaders(params, opts, this.operation); var body = params.body; // encode the body for form submits - if (headers["Content-Type"]) { + 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") + if (param.paramType === 'form') values[param.name] = param; } - if (headers["Content-Type"].indexOf("application/x-www-form-urlencoded") === 0) { - var encoded = ""; + 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 += "&"; + if (encoded !== '') + encoded += '&'; encoded += encodeURIComponent(key) + '=' + encodeURIComponent(value); } } body = encoded; } - else if (headers["Content-Type"].indexOf("multipart/form-data") === 0) { + else if (headers['Content-Type'].indexOf('multipart/form-data') === 0) { // encode the body for form submits - var data = ""; - var boundary = "----SwaggerFormBoundary" + Date.now(); + var data = ''; + var boundary = '----SwaggerFormBoundary' + Date.now(); var key, value; for (key in values) { value = this.params[key]; @@ -1186,11 +1228,11 @@ data += '--' + boundary + '\n'; data += 'Content-Disposition: form-data; name="' + key + '"'; data += '\n\n'; - data += value + "\n"; + data += value + '\n'; } } - data += "--" + boundary + "--\n"; - headers["Content-Type"] = "multipart/form-data; boundary=" + boundary; + data += '--' + boundary + '--\n'; + headers['Content-Type'] = 'multipart/form-data; boundary=' + boundary; body = data; } } @@ -1218,13 +1260,22 @@ } } }; - var e; - if (typeof window !== 'undefined') { - e = window; + + var status = false; + if (this.operation.resource && this.operation.resource.api && this.operation.resource.api.clientAuthorizations) { + // Get the client authorizations from the resource declaration + status = this.operation.resource.api.clientAuthorizations.apply(obj, this.operation.authorizations); } else { - e = exports; + // Get the client authorization from the default authorization declaration + var e; + if (typeof window !== 'undefined') { + e = window; + } else { + e = exports; + } + status = e.authorizations.apply(obj, this.operation.authorizations); } - var status = e.authorizations.apply(obj, this.operation.authorizations); + if (opts.mock == null) { if (status !== false) { new SwaggerHttp().execute(obj); @@ -1238,12 +1289,12 @@ return obj; }; - SwaggerRequest.prototype.setHeaders = function (params, operation) { + SwaggerRequest.prototype.setHeaders = function (params, opts, operation) { // default type - var accepts = "application/json"; - var consumes = "application/json"; + var accepts = opts.responseContentType || 'application/json'; + var consumes = opts.requestContentType || 'application/json'; - var allDefinedParams = this.operation.parameters; + var allDefinedParams = operation.parameters; var definedFormParams = []; var definedFileParams = []; var body = params.body; @@ -1253,11 +1304,11 @@ var i; for (i = 0; i < allDefinedParams.length; i++) { var param = allDefinedParams[i]; - if (param.paramType === "form") + if (param.paramType === 'form') definedFormParams.push(param); - else if (param.paramType === "file") + else if (param.paramType === 'file') definedFileParams.push(param); - else if (param.paramType === "header" && this.params.headers) { + 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') @@ -1266,60 +1317,47 @@ } // 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 (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"; + consumes = 'multipart/form-data'; else - consumes = "application/x-www-form-urlencoded"; + consumes = 'application/x-www-form-urlencoded'; } - else if (this.type === "DELETE") - body = "{}"; - else if (this.type != "DELETE") + else if (this.type === 'DELETE') + body = '{}'; + else if (this.type != 'DELETE') consumes = null; } if (consumes && this.operation.consumes) { if (this.operation.consumes.indexOf(consumes) === -1) { - log("server doesn't consume " + consumes + ", try " + JSON.stringify(this.operation.consumes)); - consumes = this.operation.consumes[0]; + log('server doesn\'t consume ' + consumes + ', try ' + JSON.stringify(this.operation.consumes)); } } - if (this.opts.responseContentType) { + if (this.opts && this.opts.responseContentType) { accepts = this.opts.responseContentType; } else { - accepts = "application/json"; + 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 (accepts && operation.produces) { + if (operation.produces.indexOf(accepts) === -1) { + log('server can\'t produce ' + accepts); } } - if ((consumes && body !== "") || (consumes === "application/x-www-form-urlencoded")) - headers["Content-Type"] = consumes; + if ((consumes && body !== '') || (consumes === 'application/x-www-form-urlencoded')) + headers['Content-Type'] = consumes; if (accepts) - headers["Accept"] = accepts; + headers['Accept'] = accepts; return headers; } - SwaggerRequest.prototype.asCurl = function () { - var results = []; - if (this.headers) { - var key; - for (key in this.headers) { - results.push("--header \"" + key + ": " + this.headers[v] + "\""); - } - } - return "curl " + (results.join(" ")) + " " + this.url; - }; - /** * SwaggerHttp is a wrapper for executing requests */ @@ -1357,7 +1395,7 @@ * Since we are using closures here we need to alias it for internal use. */ var JQueryHttpClient = function (options) { - "use strict"; + this.options = options || {}; if (!jQuery) { var jQuery = window.jQuery; } @@ -1376,9 +1414,9 @@ results = []; var key; for (key in obj.headers) { - if (key.toLowerCase() === "content-type") { + if (key.toLowerCase() === 'content-type') { results.push(obj.contentType = obj.headers[key]); - } else if (key.toLowerCase() === "accept") { + } else if (key.toLowerCase() === 'accept') { results.push(obj.accepts = obj.headers[key]); } else { results.push(xhr.setRequestHeader(key, obj.headers[key])); @@ -1389,22 +1427,22 @@ }; obj.data = obj.body; - obj.complete = function (response, textStatus, opts) { + obj.complete = function (response) { var headers = {}, - headerArray = response.getAllResponseHeaders().split("\n"); + 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(":"); + 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(); + value = toSplit.substring(separator + 1).trim(); headers[name] = value; } @@ -1416,11 +1454,11 @@ headers: headers }; - var contentType = (headers["content-type"] || headers["Content-Type"] || null) + 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 !== "") + if (contentType.indexOf('application/json') == 0 || contentType.indexOf('+json') > 0) { + if (response.responseText && response.responseText !== '') out.obj = JSON.parse(response.responseText); else out.obj = {} @@ -1446,14 +1484,12 @@ this.options = (options || {}); this.isInitialized = false; - var identity, toString; - if (typeof window !== 'undefined') { - this.Shred = require("./shred"); - this.content = require("./shred/content"); + this.Shred = require('./shred'); + this.content = require('./shred/content'); } else - this.Shred = require("shred"); + this.Shred = require('shred'); this.shred = new this.Shred(); } @@ -1462,7 +1498,7 @@ this.registerProcessors(this.shred); } - ShredHttpClient.prototype.registerProcessors = function (shred) { + ShredHttpClient.prototype.registerProcessors = function () { var identity = function (x) { return x; }; @@ -1471,12 +1507,12 @@ }; if (typeof window !== 'undefined') { - this.content.registerProcessor(["application/json; charset=utf-8", "application/json", "json"], { + 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"], { + this.Shred.registerProcessor(['application/json; charset=utf-8', 'application/json', 'json'], { parser: identity, stringify: toString }); @@ -1499,16 +1535,16 @@ }; var headers = response._headers.normalized || response._headers; - var contentType = (headers["content-type"] || headers["Content-Type"] || null) + var contentType = (headers['content-type'] || headers['Content-Type'] || null) if (contentType != null) { - if (contentType.indexOf("application/json") == 0 || contentType.indexOf("+json") > 0) { - if (response.content.data && response.content.data !== "") + if (contentType.indexOf('application/json') == 0 || contentType.indexOf('+json') > 0) { + if (response.content.data && response.content.data !== '') try { out.obj = JSON.parse(response.content.data); } catch (ex) { // do not set out.obj - log ("unable to parse JSON content"); + log('unable to parse JSON content'); } else out.obj = {} @@ -1547,14 +1583,6 @@ 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)); @@ -1569,8 +1597,11 @@ /** * SwaggerAuthorizations applys the correct authorization to an operation being executed */ - var SwaggerAuthorizations = function () { + var SwaggerAuthorizations = function (name, auth) { this.authz = {}; + if(name && auth) { + this.authz[name] = auth; + } }; SwaggerAuthorizations.prototype.add = function (name, auth) { @@ -1621,14 +1652,14 @@ this.delimiter = delimiter; }; - ApiKeyAuthorization.prototype.apply = function (obj, authorizations) { - if (this.type === "query") { + ApiKeyAuthorization.prototype.apply = function (obj) { + if (this.type === 'query') { if (obj.url.indexOf('?') > 0) - obj.url = obj.url + "&" + this.name + "=" + this.value; + obj.url = obj.url + '&' + this.name + '=' + this.value; else - obj.url = obj.url + "?" + this.name + "=" + this.value; + obj.url = obj.url + '?' + this.name + '=' + this.value; return true; - } else if (this.type === "header") { + } 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; @@ -1643,7 +1674,7 @@ this.cookie = cookie; } - CookieAuthorization.prototype.apply = function (obj, authorizations) { + CookieAuthorization.prototype.apply = function (obj) { obj.cookieJar = obj.cookieJar || CookieJar(); obj.cookieJar.setCookie(this.cookie); return true; @@ -1660,25 +1691,23 @@ if (typeof window !== 'undefined') this._btoa = btoa; else - this._btoa = require("btoa"); + this._btoa = require('btoa'); }; - PasswordAuthorization.prototype.apply = function (obj, authorizations) { + PasswordAuthorization.prototype.apply = function (obj) { var base64encoder = this._btoa; - obj.headers["Authorization"] = "Basic " + base64encoder(this.username + ":" + this.password); + obj.headers['Authorization'] = 'Basic ' + base64encoder(this.username + ':' + this.password); return true; }; var e = (typeof window !== 'undefined' ? window : exports); var sampleModels = {}; - var cookies = {}; - e.parameterMacro = parameterMacro; - e.modelPropertyMacro = modelPropertyMacro; e.SampleModels = sampleModels; e.SwaggerHttp = SwaggerHttp; e.SwaggerRequest = SwaggerRequest; + e.SwaggerAuthorizations = SwaggerAuthorizations; e.authorizations = new SwaggerAuthorizations(); e.ApiKeyAuthorization = ApiKeyAuthorization; e.PasswordAuthorization = PasswordAuthorization; @@ -1690,6 +1719,7 @@ e.SwaggerModelProperty = SwaggerModelProperty; e.SwaggerResource = SwaggerResource; e.SwaggerApi = SwaggerApi; + e.log = log; })(); diff --git a/swagger-ui.js b/swagger-ui.js index 66d84af1cb2..b052b4352ae 100644 --- a/swagger-ui.js +++ b/swagger-ui.js @@ -1192,11 +1192,11 @@ function program3(depth0,data) { if (stack1 = helpers.id) { stack1 = stack1.call(depth0, {hash:{},data:data}); } else { stack1 = depth0.id; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } buffer += escapeExpression(stack1) - + "\">\n List Operations\n \n \n
  • \n \n List Operations\n \n
  • \n
  • \n \n Expand Operations\n \n
  • \n "; + + "\">\n Expand Operations\n \n \n "; options = {hash:{},inverse:self.noop,fn:self.program(3, program3, data),data:data}; if (stack1 = helpers.url) { stack1 = stack1.call(depth0, options); } else { stack1 = depth0.url; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } @@ -2057,7 +2057,7 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {}; params += 1; } } - this.invocationUrl = this.model.supportHeaderParams() ? (headerParams = this.model.getHeaderParams(map), this.model.urlify(map, false)) : this.model.urlify(map, true); + this.invocationUrl = this.model.supportHeaderParams() ? (headerParams = this.model.getHeaderParams(map), delete headerParams['Content-Type'], this.model.urlify(map, false)) : this.model.urlify(map, true); $(".request_url", $(this.el)).html("
    ");
           $(".request_url pre", $(this.el)).text(this.invocationUrl);
           obj = {
    diff --git a/swagger-ui.min.js b/swagger-ui.min.js
    index 951baf24767..330262f1513 100644
    --- a/swagger-ui.min.js
    +++ b/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.apikey_button_view=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+="
    apply api key
    \n
    \n
    \n
    ";if(c=d.keyName){c=c.call(k,{hash:{},data:i})}else{c=k.keyName;c=typeof c===f?c.apply(k):c}g+=h(c)+'
    \n \n \n
    \n
    \n\n';return g})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.basic_auth_button_view=b(function(f,g,d,c,e){this.compilerInfo=[4,">= 1.0.0"];d=this.merge(d,f.helpers);e=e||{};return'
    \n
    \n
    \n
    Username
    \n \n
    Password
    \n \n \n
    \n
    \n\n'})})();(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,s,i="function",k=this.escapeExpression,q=this;function f(x,w){var t="",v,u;t+='\n
    '+k(((v=((v=x.info),v==null||v===false?v:v.title)),typeof v===i?v.apply(x):v))+'
    \n
    ';u=((v=((v=x.info),v==null||v===false?v:v.description)),typeof v===i?v.apply(x):v);if(u||u===0){t+=u}t+="
    \n ";u=g["if"].call(x,((v=x.info),v==null||v===false?v:v.termsOfServiceUrl),{hash:{},inverse:q.noop,fn:q.program(2,d,w),data:w});if(u||u===0){t+=u}t+="\n ";u=g["if"].call(x,((v=x.info),v==null||v===false?v:v.contact),{hash:{},inverse:q.noop,fn:q.program(4,r,w),data:w});if(u||u===0){t+=u}t+="\n ";u=g["if"].call(x,((v=x.info),v==null||v===false?v:v.license),{hash:{},inverse:q.noop,fn:q.program(6,p,w),data:w});if(u||u===0){t+=u}t+="\n ";return t}function d(w,v){var t="",u;t+='';return t}function r(w,v){var t="",u;t+="';return t}function p(w,v){var t="",u;t+="";return t}function o(w,v){var t="",u;t+='\n , api version: '+k(((u=((u=w.info),u==null||u===false?u:u.version)),typeof u===i?u.apply(w):u))+"\n ";return t}function e(w,v){var t="",u;t+='\n \n \n ';return t}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

      [ 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 ";s=g["if"].call(n,((c=n.info),c==null||c===false?c:c.version),{hash:{},inverse:q.noop,fn:q.program(8,o,l),data:l});if(s||s===0){j+=s}j+="]\n ";s=g["if"].call(n,n.validatorUrl,{hash:{},inverse:q.noop,fn:q.program(10,e,l),data:l});if(s||s===0){j+=s}j+="\n

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

      Warning: Deprecated

      \n "}function n(E,D){var B="",C;B+="\n

      Implementation Notes

      \n

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

      \n ";return B}function m(C,B){return'\n
      \n '}function i(E,D){var B="",C;B+='\n \n ";return B}function z(F,E){var B="",D,C;B+="\n
      "+d(((D=F.scope),typeof D===e?D.apply(F):D))+"
      \n ";return B}function y(C,B){return"
      "}function x(C,B){return'\n
      \n \n
      \n '}function w(C,B){return'\n

      Response Class

      \n

      \n
      \n
      \n '}function v(C,B){return'\n

      Parameters

      \n \n \n \n \n \n \n \n \n \n \n \n\n \n
      ParameterValueDescriptionParameter TypeData Type
      \n '}function l(C,B){return"\n
      \n

      Response Messages

      \n \n \n \n \n \n \n \n \n \n \n \n
      HTTP Status CodeReasonResponse Model
      \n "}function h(C,B){return"\n "}function g(C,B){return"\n
      \n \n \n \n
      \n "}t+="\n
        \n
      • \n \n \n
      • \n
      \n";return t})})();(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["default"],{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["default"],{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["default"],{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["default"],{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["default"]){r=r.call(t,{hash:{},data:s})}else{r=t["default"];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["default"],{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["default"]){r=r.call(t,{hash:{},data:s})}else{r=t["default"];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["default"],{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["default"],{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 t,k,l,u,x,q,n,m,p,o,j,r,v,s,i,d,b,B,h,g,f,e,c,a,A,z,w={}.hasOwnProperty,y=function(F,D){for(var C in D){if(w.call(D,C)){F[C]=D[C]}}function E(){this.constructor=F}E.prototype=D.prototype;F.prototype=new E();F.__super__=D.prototype;return F};v=(function(D){y(C,D);function C(){s=C.__super__.constructor.apply(this,arguments);return s}C.prototype.dom_id="swagger_ui";C.prototype.options=null;C.prototype.api=null;C.prototype.headerView=null;C.prototype.mainView=null;C.prototype.initialize=function(E){var F=this;if(E==null){E={}}if(E.dom_id!=null){this.dom_id=E.dom_id;delete E.dom_id}if($("#"+this.dom_id)==null){$("body").append('
      ')}this.options=E;this.options.success=function(){return F.render()};this.options.progress=function(G){return F.showMessage(G)};this.options.failure=function(G){if(F.api&&F.api.isValid===false){log("not a valid 2.0 spec, loading legacy client");F.api=new SwaggerApi(F.options);return F.api.build()}else{return F.onLoadFailure(G)}};this.headerView=new u({el:$("#header")});return this.headerView.on("update-swagger-ui",function(G){return F.updateSwaggerUi(G)})};C.prototype.setOption=function(E,F){return this.options[E]=F};C.prototype.getOption=function(E){return this.options[E]};C.prototype.updateSwaggerUi=function(E){this.options.url=E.url;return this.load()};C.prototype.load=function(){var F,E;if((E=this.mainView)!=null){E.clear()}F=this.options.url;if(F.indexOf("http")!==0){F=this.buildUrl(window.location.href.toString(),F)}this.options.url=F;this.headerView.update(F);this.api=new SwaggerClient(this.options);return this.api.build()};C.prototype.collapseAll=function(){return Docs.collapseEndpointListForResource("")};C.prototype.listAll=function(){return Docs.collapseOperationsForResource("")};C.prototype.expandAll=function(){return Docs.expandOperationsForResource("")};C.prototype.render=function(){var E=this;this.showMessage("Finished Loading Resource Information. Rendering Swagger UI...");this.mainView=new x({model:this.api,el:$("#"+this.dom_id),swaggerOptions:this.options}).render();this.showMessage();switch(this.options.docExpansion){case"full":this.expandAll();break;case"list":this.listAll()}if(this.options.onComplete){this.options.onComplete(this.api,this)}return setTimeout(function(){return Docs.shebang()},400)};C.prototype.buildUrl=function(G,E){var F,H;log("base is "+G);if(E.indexOf("/")===0){H=G.split("/");G=H[0]+"//"+H[2];return G+E}else{F=G.length;if(G.indexOf("?")>-1){F=Math.min(F,G.indexOf("?"))}if(G.indexOf("#")>-1){F=Math.min(F,G.indexOf("#"))}G=G.substring(0,F);if(G.indexOf("/",G.length-1)!==-1){return G+E}return G+"/"+E}};C.prototype.showMessage=function(E){if(E==null){E=""}$("#message-bar").removeClass("message-fail");$("#message-bar").addClass("message-success");return $("#message-bar").html(E)};C.prototype.onLoadFailure=function(E){var F;if(E==null){E=""}$("#message-bar").removeClass("message-success");$("#message-bar").addClass("message-fail");F=$("#message-bar").html(E);if(this.options.onFailure!=null){this.options.onFailure(E)}return F};return C})(Backbone.Router);window.SwaggerUi=v;u=(function(D){y(C,D);function C(){i=C.__super__.constructor.apply(this,arguments);return i}C.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"};C.prototype.initialize=function(){};C.prototype.showPetStore=function(E){return this.trigger("update-swagger-ui",{url:"http://petstore.swagger.wordnik.com/api/api-docs"})};C.prototype.showWordnikDev=function(E){return this.trigger("update-swagger-ui",{url:"http://api.wordnik.com/v4/resources.json"})};C.prototype.showCustomOnKeyup=function(E){if(E.keyCode===13){return this.showCustom()}};C.prototype.showCustom=function(E){if(E!=null){E.preventDefault()}return this.trigger("update-swagger-ui",{url:$("#input_baseUrl").val(),apiKey:$("#input_apiKey").val()})};C.prototype.update=function(F,G,E){if(E==null){E=false}$("#input_baseUrl").val(F);if(E){return this.trigger("update-swagger-ui",{url:F})}};return C})(Backbone.View);x=(function(C){var D;y(E,C);function E(){h=E.__super__.constructor.apply(this,arguments);return h}D={alpha:function(G,F){return G.path.localeCompare(F.path)},method:function(G,F){return G.method.localeCompare(F.method)}};E.prototype.initialize=function(J){var I,H,G,F,K,L;if(J==null){J={}}this.model.auths=[];L=this.model.securityDefinitions;for(H in L){K=L[H];I={name:H,type:K.type,value:K};this.model.auths.push(I)}if(this.model.info&&this.model.info.license&&typeof this.model.info.license==="string"){G=this.model.info.license;F=this.model.info.licenseUrl;this.model.info.license={};this.model.info.license.name=G;this.model.info.license.url=F}if(!this.model.info){this.model.info={}}if(!this.model.info.version){this.model.info.version=this.model.apiVersion}if(this.model.swaggerVersion==="2.0"){if("validatorUrl" in J.swaggerOptions){return this.model.validatorUrl=J.swaggerOptions.validatorUrl}else{if(this.model.url.indexOf("localhost")>0){return this.model.validatorUrl=null}else{return this.model.validatorUrl="http://online.swagger.io/validator"}}}};E.prototype.render=function(){var K,N,F,H,G,L,I,M,O,J;if(this.model.securityDefinitions){for(G in this.model.securityDefinitions){K=this.model.securityDefinitions[G];if(K.type==="apiKey"&&$("#apikey_button").length===0){N=new t({model:K}).render().el;$(".auth_main_container").append(N)}if(K.type==="basicAuth"&&$("#basic_auth_button").length===0){N=new k({model:K}).render().el;$(".auth_main_container").append(N)}}}$(this.el).html(Handlebars.templates.main(this.model));I={};F=0;J=this.model.apisArray;for(M=0,O=J.length;MF){O=F-G}if(OE){L=E-I}if(L")}this.model.oauth=null;if(this.model.authorizations){if(Array.isArray(this.model.authorizations)){Q=this.model.authorizations;for(ai=0,T=Q.length;ai0){H[M.name]=M.value}if(M.type==="file"){R=true}}I=K.find("textarea");for(P=0,J=I.length;P0){H[M.name]=M.value}}F=K.find("select");for(O=0,G=F.length;O0){H[M.name]=N}}E.responseContentType=$("div select[name=responseContentType]",$(this.el)).val();E.requestContentType=$("div select[name=parameterContentType]",$(this.el)).val();$(".response_throbber",$(this.el)).show();if(R){return this.handleFileUpload(H,K)}else{return this.model["do"](H,E,this.showCompleteStatus,this.showErrorStatus,this)}}};C.prototype.success=function(E,F){return F.showCompleteStatus(E)};C.prototype.handleFileUpload=function(V,M){var Q,L,G,R,P,O,T,N,K,J,H,U,Y,X,W,I,F,E,Z,S=this;I=M.serializeArray();for(N=0,U=I.length;N0){V[R.name]=R.value}}Q=new FormData();T=0;F=this.model.parameters;for(K=0,Y=F.length;K");$(".request_url pre",$(this.el)).text(this.invocationUrl);P={type:this.model.method,url:this.invocationUrl,headers:G,data:Q,dataType:"json",contentType:false,processData:false,error:function(ab,ac,aa){return S.showErrorStatus(S.wrap(ab),S)},success:function(aa){return S.showResponse(aa,S)},complete:function(aa){return S.showCompleteStatus(S.wrap(aa),S)}};if(window.authorizations){window.authorizations.apply(P)}if(T===0){P.data.append("fake","true")}jQuery.ajax(P);return false};C.prototype.wrap=function(I){var G,J,L,F,K,H,E;L={};J=I.getAllResponseHeaders().split("\r");for(H=0,E=J.length;H0){return G}else{return null}}};C.prototype.hideResponse=function(E){if(E!=null){E.preventDefault()}$(".response",$(this.el)).slideUp();return $(".response_hider",$(this.el)).fadeOut()};C.prototype.showResponse=function(E){var F;F=JSON.stringify(E,null,"\t").replace(/\n/g,"
      ");return $(".response_body",$(this.el)).html(escape(F))};C.prototype.showErrorStatus=function(F,E){return E.showStatus(F)};C.prototype.showCompleteStatus=function(F,E){return E.showStatus(F)};C.prototype.formatXml=function(L){var H,K,F,M,R,N,G,E,P,Q,J,I,O;E=/(>)(<)(\/*)/g;Q=/[ ]*(.*)[ ]+\n/g;H=/(<.+>)(.+\n)/g;L=L.replace(E,"$1\n$2$3").replace(Q,"$1\n").replace(H,"$1\n$2");G=0;K="";R=L.split("\n");F=0;M="other";P={"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};J=function(X){var T,S,V,Z,W,U,Y;U={single:Boolean(X.match(/<.+\/>/)),closing:Boolean(X.match(/<\/.+>/)),opening:Boolean(X.match(/<[^!?].*>/))};W=((function(){var aa;aa=[];for(V in U){Y=U[V];if(Y){aa.push(V)}}return aa})())[0];W=W===void 0?"other":W;T=M+"->"+W;M=W;Z="";F+=P[T];Z=((function(){var ab,ac,aa;aa=[];for(S=ab=0,ac=F;0<=ac?abac;S=0<=ac?++ab:--ab){aa.push(" ")}return aa})()).join("");if(T==="opening->closing"){return K=K.substr(0,K.length-1)+X+"\n"}else{return K+=Z+X+"\n"}};for(I=0,O=R.length;I").text("no content");I=$('
      ').append(G)}else{if(P==="application/json"||/\+json$/.test(P)){Q=null;try{Q=JSON.stringify(JSON.parse(N),null,"  ")}catch(O){M=O;Q="can't parse JSON.  Raw result:\n\n"+N}G=$("").text(Q);I=$('
      ').append(G)}else{if(P==="application/xml"||/\+xml$/.test(P)){G=$("").text(this.formatXml(N));I=$('
      ').append(G)}else{if(P==="text/html"){G=$("").html(_.escape(N));I=$('
      ').append(G)}else{if(/^image\//.test(P)){I=$("").attr("src",F)}else{G=$("").text(N);I=$('
      ').append(G)}}}}}L=I;$(".request_url",$(this.el)).html("
      ");$(".request_url pre",$(this.el)).text(F);$(".response_code",$(this.el)).html("
      "+J.status+"
      ");$(".response_body",$(this.el)).html(L);$(".response_headers",$(this.el)).html("
      "+_.escape(JSON.stringify(J.headers,null,"  ")).replace(/\n/g,"
      ")+"
      ");$(".response",$(this.el)).slideDown();$(".response_hider",$(this.el)).show();$(".response_throbber",$(this.el)).hide();K=$(".response_body",$(this.el))[0];E=this.options.swaggerOptions;if(E.highlightSizeThreshold&&J.data.length>E.highlightSizeThreshold){return K}else{return hljs.highlightBlock(K)}};C.prototype.toggleOperationContent=function(){var E;E=$("#"+Docs.escapeResourceName(this.model.parentId+"_"+this.model.nickname+"_content"));if(E.is(":visible")){return Docs.collapseOperation(E)}else{return Docs.expandOperation(E)}};return C})(Backbone.View);r=(function(D){y(C,D);function C(){e=C.__super__.constructor.apply(this,arguments);return e}C.prototype.initialize=function(){};C.prototype.render=function(){var F,E,G;G=this.template();$(this.el).html(G(this.model));if(swaggerUi.api.models.hasOwnProperty(this.model.responseModel)){F={sampleJSON:JSON.stringify(swaggerUi.api.models[this.model.responseModel].createJSONSample(),null,2),isParam:false,signature:swaggerUi.api.models[this.model.responseModel].getMockSignature()};E=new j({model:F,tagName:"div"});$(".model-signature",this.$el).append(E.render().el)}else{$(".model-signature",this.$el).html("")}return this};C.prototype.template=function(){return Handlebars.templates.status_code};return C})(Backbone.View);m=(function(D){y(C,D);function C(){c=C.__super__.constructor.apply(this,arguments);return c}C.prototype.initialize=function(){return Handlebars.registerHelper("isArray",function(F,E){if(F.type.toLowerCase()==="array"||F.allowMultiple){return E.fn(this)}else{return E.inverse(this)}})};C.prototype.render=function(){var E,F,I,G,J,H,M,N,L,K;K=this.model.type||this.model.dataType;if(typeof K==="undefined"){H=this.model.schema;if(H&&H["$ref"]){G=H["$ref"];if(G.indexOf("#/definitions/")===0){K=G.substring("#/definitions/".length)}else{K=G}}}this.model.type=K;this.model.paramType=this.model["in"]||this.model.paramType;if(this.model.paramType==="body"){this.model.isBody=true}if(K&&K.toLowerCase()==="file"){this.model.isFile=true}this.model["default"]=this.model["default"]||this.model.defaultValue;if(this.model.allowableValues){this.model.isList=true}L=this.template();$(this.el).html(L(this.model));M={sampleJSON:this.model.sampleJSON,isParam:true,signature:this.model.signature};if(this.model.sampleJSON){N=new j({model:M,tagName:"div"});$(".model-signature",$(this.el)).append(N.render().el)}else{$(".model-signature",$(this.el)).html(this.model.signature)}F=false;if(this.model.isBody){F=true}E={isParam:F};E.consumes=this.model.consumes;if(F){I=new n({model:E});$(".parameter-content-type",$(this.el)).append(I.render().el)}else{J=new o({model:E});$(".response-content-type",$(this.el)).append(J.render().el)}return this};C.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 C})(Backbone.View);j=(function(D){y(C,D);function C(){a=C.__super__.constructor.apply(this,arguments);return a}C.prototype.events={"click a.description-link":"switchToDescription","click a.snippet-link":"switchToSnippet","mousedown .snippet":"snippetToTextArea"};C.prototype.initialize=function(){};C.prototype.render=function(){var E;E=this.template();$(this.el).html(E(this.model));this.switchToSnippet();this.isParam=this.model.isParam;if(this.isParam){$(".notice",$(this.el)).text("Click to set as parameter value")}return this};C.prototype.template=function(){return Handlebars.templates.signature};C.prototype.switchToDescription=function(E){if(E!=null){E.preventDefault()}$(".snippet",$(this.el)).hide();$(".description",$(this.el)).show();$(".description-link",$(this.el)).addClass("selected");return $(".snippet-link",$(this.el)).removeClass("selected")};C.prototype.switchToSnippet=function(E){if(E!=null){E.preventDefault()}$(".description",$(this.el)).hide();$(".snippet",$(this.el)).show();$(".snippet-link",$(this.el)).addClass("selected");return $(".description-link",$(this.el)).removeClass("selected")};C.prototype.snippetToTextArea=function(E){var F;if(this.isParam){if(E!=null){E.preventDefault()}F=$("textarea",$(this.el.parentNode.parentNode.parentNode));if($.trim(F.val())===""){return F.val(this.model.sampleJSON)}}};return C})(Backbone.View);l=(function(C){y(D,C);function D(){A=D.__super__.constructor.apply(this,arguments);return A}D.prototype.initialize=function(){};D.prototype.render=function(){var E;E=this.template();$(this.el).html(E(this.model));$("label[for=contentType]",$(this.el)).text("Response Content Type");return this};D.prototype.template=function(){return Handlebars.templates.content_type};return D})(Backbone.View);o=(function(C){y(D,C);function D(){z=D.__super__.constructor.apply(this,arguments);return z}D.prototype.initialize=function(){};D.prototype.render=function(){var E;E=this.template();$(this.el).html(E(this.model));$("label[for=responseContentType]",$(this.el)).text("Response Content Type");return this};D.prototype.template=function(){return Handlebars.templates.response_content_type};return D})(Backbone.View);n=(function(D){y(C,D);function C(){d=C.__super__.constructor.apply(this,arguments);return d}C.prototype.initialize=function(){};C.prototype.render=function(){var E;E=this.template();$(this.el).html(E(this.model));$("label[for=parameterContentType]",$(this.el)).text("Parameter content type:");return this};C.prototype.template=function(){return Handlebars.templates.parameter_content_type};return C})(Backbone.View);t=(function(D){y(C,D);function C(){b=C.__super__.constructor.apply(this,arguments);return b}C.prototype.initialize=function(){};C.prototype.render=function(){var E;E=this.template();$(this.el).html(E(this.model));return this};C.prototype.events={"click #apikey_button":"toggleApiKeyContainer","click #apply_api_key":"applyApiKey"};C.prototype.applyApiKey=function(){var E;window.authorizations.add(this.model.name,new ApiKeyAuthorization(this.model.name,$("#input_apiKey_entry").val(),this.model["in"]));window.swaggerUi.load();return E=$("#apikey_container").show()};C.prototype.toggleApiKeyContainer=function(){var E;if($("#apikey_container").length>0){E=$("#apikey_container").first();if(E.is(":visible")){return E.hide()}else{$(".auth_container").hide();return E.show()}}};C.prototype.template=function(){return Handlebars.templates.apikey_button_view};return C})(Backbone.View);k=(function(D){y(C,D);function C(){B=C.__super__.constructor.apply(this,arguments);return B}C.prototype.initialize=function(){};C.prototype.render=function(){var E;E=this.template();$(this.el).html(E(this.model));return this};C.prototype.events={"click #basic_auth_button":"togglePasswordContainer","click #apply_basic_auth":"applyPassword"};C.prototype.applyPassword=function(){var F,E,G;console.log("applying password");G=$(".input_username").val();E=$(".input_password").val();window.authorizations.add(this.model.type,new PasswordAuthorization("basic",G,E));window.swaggerUi.load();return F=$("#basic_auth_container").hide()};C.prototype.togglePasswordContainer=function(){var E;if($("#basic_auth_container").length>0){E=$("#basic_auth_container").show();if(E.is(":visible")){return E.slideUp()}else{$(".auth_container").hide();return E.show()}}};C.prototype.template=function(){return Handlebars.templates.basic_auth_button_view};return C})(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.apikey_button_view=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+="
      apply api key
      \n
      \n
      \n
      ";if(c=d.keyName){c=c.call(k,{hash:{},data:i})}else{c=k.keyName;c=typeof c===f?c.apply(k):c}g+=h(c)+'
      \n \n \n
      \n
      \n\n';return g})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.basic_auth_button_view=b(function(f,g,d,c,e){this.compilerInfo=[4,">= 1.0.0"];d=this.merge(d,f.helpers);e=e||{};return'
      \n
      \n
      \n
      Username
      \n \n
      Password
      \n \n \n
      \n
      \n\n'})})();(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,s,i="function",k=this.escapeExpression,q=this;function f(x,w){var t="",v,u;t+='\n
      '+k(((v=((v=x.info),v==null||v===false?v:v.title)),typeof v===i?v.apply(x):v))+'
      \n
      ';u=((v=((v=x.info),v==null||v===false?v:v.description)),typeof v===i?v.apply(x):v);if(u||u===0){t+=u}t+="
      \n ";u=g["if"].call(x,((v=x.info),v==null||v===false?v:v.termsOfServiceUrl),{hash:{},inverse:q.noop,fn:q.program(2,d,w),data:w});if(u||u===0){t+=u}t+="\n ";u=g["if"].call(x,((v=x.info),v==null||v===false?v:v.contact),{hash:{},inverse:q.noop,fn:q.program(4,r,w),data:w});if(u||u===0){t+=u}t+="\n ";u=g["if"].call(x,((v=x.info),v==null||v===false?v:v.license),{hash:{},inverse:q.noop,fn:q.program(6,p,w),data:w});if(u||u===0){t+=u}t+="\n ";return t}function d(w,v){var t="",u;t+='';return t}function r(w,v){var t="",u;t+="';return t}function p(w,v){var t="",u;t+="";return t}function o(w,v){var t="",u;t+='\n , api version: '+k(((u=((u=w.info),u==null||u===false?u:u.version)),typeof u===i?u.apply(w):u))+"\n ";return t}function e(w,v){var t="",u;t+='\n \n \n ';return t}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

        [ 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 ";s=g["if"].call(n,((c=n.info),c==null||c===false?c:c.version),{hash:{},inverse:q.noop,fn:q.program(8,o,l),data:l});if(s||s===0){j+=s}j+="]\n ";s=g["if"].call(n,n.validatorUrl,{hash:{},inverse:q.noop,fn:q.program(10,e,l),data:l});if(s||s===0){j+=s}j+="\n

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

        Warning: Deprecated

        \n "}function n(E,D){var B="",C;B+="\n

        Implementation Notes

        \n

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

        \n ";return B}function m(C,B){return'\n
        \n '}function i(E,D){var B="",C;B+='\n \n ";return B}function z(F,E){var B="",D,C;B+="\n
        "+d(((D=F.scope),typeof D===e?D.apply(F):D))+"
        \n ";return B}function y(C,B){return"
        "}function x(C,B){return'\n
        \n \n
        \n '}function w(C,B){return'\n

        Response Class

        \n

        \n
        \n
        \n '}function v(C,B){return'\n

        Parameters

        \n \n \n \n \n \n \n \n \n \n \n \n\n \n
        ParameterValueDescriptionParameter TypeData Type
        \n '}function l(C,B){return"\n
        \n

        Response Messages

        \n \n \n \n \n \n \n \n \n \n \n \n
        HTTP Status CodeReasonResponse Model
        \n "}function h(C,B){return"\n "}function g(C,B){return"\n
        \n \n \n \n
        \n "}t+="\n
          \n
        • \n \n \n
        • \n
        \n";return t})})();(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["default"],{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["default"],{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["default"],{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["default"],{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["default"]){r=r.call(t,{hash:{},data:s})}else{r=t["default"];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["default"],{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["default"]){r=r.call(t,{hash:{},data:s})}else{r=t["default"];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["default"],{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["default"],{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";return i})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.response_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.signature=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+='
        \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 t,k,l,u,x,q,n,m,p,o,j,r,v,s,i,d,b,B,h,g,f,e,c,a,A,z,w={}.hasOwnProperty,y=function(F,D){for(var C in D){if(w.call(D,C)){F[C]=D[C]}}function E(){this.constructor=F}E.prototype=D.prototype;F.prototype=new E();F.__super__=D.prototype;return F};v=(function(D){y(C,D);function C(){s=C.__super__.constructor.apply(this,arguments);return s}C.prototype.dom_id="swagger_ui";C.prototype.options=null;C.prototype.api=null;C.prototype.headerView=null;C.prototype.mainView=null;C.prototype.initialize=function(E){var F=this;if(E==null){E={}}if(E.dom_id!=null){this.dom_id=E.dom_id;delete E.dom_id}if($("#"+this.dom_id)==null){$("body").append('
        ')}this.options=E;this.options.success=function(){return F.render()};this.options.progress=function(G){return F.showMessage(G)};this.options.failure=function(G){if(F.api&&F.api.isValid===false){log("not a valid 2.0 spec, loading legacy client");F.api=new SwaggerApi(F.options);return F.api.build()}else{return F.onLoadFailure(G)}};this.headerView=new u({el:$("#header")});return this.headerView.on("update-swagger-ui",function(G){return F.updateSwaggerUi(G)})};C.prototype.setOption=function(E,F){return this.options[E]=F};C.prototype.getOption=function(E){return this.options[E]};C.prototype.updateSwaggerUi=function(E){this.options.url=E.url;return this.load()};C.prototype.load=function(){var F,E;if((E=this.mainView)!=null){E.clear()}F=this.options.url;if(F.indexOf("http")!==0){F=this.buildUrl(window.location.href.toString(),F)}this.options.url=F;this.headerView.update(F);this.api=new SwaggerClient(this.options);return this.api.build()};C.prototype.collapseAll=function(){return Docs.collapseEndpointListForResource("")};C.prototype.listAll=function(){return Docs.collapseOperationsForResource("")};C.prototype.expandAll=function(){return Docs.expandOperationsForResource("")};C.prototype.render=function(){var E=this;this.showMessage("Finished Loading Resource Information. Rendering Swagger UI...");this.mainView=new x({model:this.api,el:$("#"+this.dom_id),swaggerOptions:this.options}).render();this.showMessage();switch(this.options.docExpansion){case"full":this.expandAll();break;case"list":this.listAll()}if(this.options.onComplete){this.options.onComplete(this.api,this)}return setTimeout(function(){return Docs.shebang()},400)};C.prototype.buildUrl=function(G,E){var F,H;log("base is "+G);if(E.indexOf("/")===0){H=G.split("/");G=H[0]+"//"+H[2];return G+E}else{F=G.length;if(G.indexOf("?")>-1){F=Math.min(F,G.indexOf("?"))}if(G.indexOf("#")>-1){F=Math.min(F,G.indexOf("#"))}G=G.substring(0,F);if(G.indexOf("/",G.length-1)!==-1){return G+E}return G+"/"+E}};C.prototype.showMessage=function(E){if(E==null){E=""}$("#message-bar").removeClass("message-fail");$("#message-bar").addClass("message-success");return $("#message-bar").html(E)};C.prototype.onLoadFailure=function(E){var F;if(E==null){E=""}$("#message-bar").removeClass("message-success");$("#message-bar").addClass("message-fail");F=$("#message-bar").html(E);if(this.options.onFailure!=null){this.options.onFailure(E)}return F};return C})(Backbone.Router);window.SwaggerUi=v;u=(function(D){y(C,D);function C(){i=C.__super__.constructor.apply(this,arguments);return i}C.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"};C.prototype.initialize=function(){};C.prototype.showPetStore=function(E){return this.trigger("update-swagger-ui",{url:"http://petstore.swagger.wordnik.com/api/api-docs"})};C.prototype.showWordnikDev=function(E){return this.trigger("update-swagger-ui",{url:"http://api.wordnik.com/v4/resources.json"})};C.prototype.showCustomOnKeyup=function(E){if(E.keyCode===13){return this.showCustom()}};C.prototype.showCustom=function(E){if(E!=null){E.preventDefault()}return this.trigger("update-swagger-ui",{url:$("#input_baseUrl").val(),apiKey:$("#input_apiKey").val()})};C.prototype.update=function(F,G,E){if(E==null){E=false}$("#input_baseUrl").val(F);if(E){return this.trigger("update-swagger-ui",{url:F})}};return C})(Backbone.View);x=(function(C){var D;y(E,C);function E(){h=E.__super__.constructor.apply(this,arguments);return h}D={alpha:function(G,F){return G.path.localeCompare(F.path)},method:function(G,F){return G.method.localeCompare(F.method)}};E.prototype.initialize=function(J){var I,H,G,F,K,L;if(J==null){J={}}this.model.auths=[];L=this.model.securityDefinitions;for(H in L){K=L[H];I={name:H,type:K.type,value:K};this.model.auths.push(I)}if(this.model.info&&this.model.info.license&&typeof this.model.info.license==="string"){G=this.model.info.license;F=this.model.info.licenseUrl;this.model.info.license={};this.model.info.license.name=G;this.model.info.license.url=F}if(!this.model.info){this.model.info={}}if(!this.model.info.version){this.model.info.version=this.model.apiVersion}if(this.model.swaggerVersion==="2.0"){if("validatorUrl" in J.swaggerOptions){return this.model.validatorUrl=J.swaggerOptions.validatorUrl}else{if(this.model.url.indexOf("localhost")>0){return this.model.validatorUrl=null}else{return this.model.validatorUrl="http://online.swagger.io/validator"}}}};E.prototype.render=function(){var K,N,F,H,G,L,I,M,O,J;if(this.model.securityDefinitions){for(G in this.model.securityDefinitions){K=this.model.securityDefinitions[G];if(K.type==="apiKey"&&$("#apikey_button").length===0){N=new t({model:K}).render().el;$(".auth_main_container").append(N)}if(K.type==="basicAuth"&&$("#basic_auth_button").length===0){N=new k({model:K}).render().el;$(".auth_main_container").append(N)}}}$(this.el).html(Handlebars.templates.main(this.model));I={};F=0;J=this.model.apisArray;for(M=0,O=J.length;MF){O=F-G}if(OE){L=E-I}if(L")}this.model.oauth=null;if(this.model.authorizations){if(Array.isArray(this.model.authorizations)){Q=this.model.authorizations;for(ai=0,T=Q.length;ai0){H[M.name]=M.value}if(M.type==="file"){R=true}}I=K.find("textarea");for(P=0,J=I.length;P0){H[M.name]=M.value}}F=K.find("select");for(O=0,G=F.length;O0){H[M.name]=N}}E.responseContentType=$("div select[name=responseContentType]",$(this.el)).val();E.requestContentType=$("div select[name=parameterContentType]",$(this.el)).val();$(".response_throbber",$(this.el)).show();if(R){return this.handleFileUpload(H,K)}else{return this.model["do"](H,E,this.showCompleteStatus,this.showErrorStatus,this)}}};C.prototype.success=function(E,F){return F.showCompleteStatus(E)};C.prototype.handleFileUpload=function(V,M){var Q,L,G,R,P,O,T,N,K,J,H,U,Y,X,W,I,F,E,Z,S=this;I=M.serializeArray();for(N=0,U=I.length;N0){V[R.name]=R.value}}Q=new FormData();T=0;F=this.model.parameters;for(K=0,Y=F.length;K
        ");$(".request_url pre",$(this.el)).text(this.invocationUrl);P={type:this.model.method,url:this.invocationUrl,headers:G,data:Q,dataType:"json",contentType:false,processData:false,error:function(ab,ac,aa){return S.showErrorStatus(S.wrap(ab),S)},success:function(aa){return S.showResponse(aa,S)},complete:function(aa){return S.showCompleteStatus(S.wrap(aa),S)}};if(window.authorizations){window.authorizations.apply(P)}if(T===0){P.data.append("fake","true")}jQuery.ajax(P);return false};C.prototype.wrap=function(I){var G,J,L,F,K,H,E;L={};J=I.getAllResponseHeaders().split("\r");for(H=0,E=J.length;H0){return G}else{return null}}};C.prototype.hideResponse=function(E){if(E!=null){E.preventDefault()}$(".response",$(this.el)).slideUp();return $(".response_hider",$(this.el)).fadeOut()};C.prototype.showResponse=function(E){var F;F=JSON.stringify(E,null,"\t").replace(/\n/g,"
        ");return $(".response_body",$(this.el)).html(escape(F))};C.prototype.showErrorStatus=function(F,E){return E.showStatus(F)};C.prototype.showCompleteStatus=function(F,E){return E.showStatus(F)};C.prototype.formatXml=function(L){var H,K,F,M,R,N,G,E,P,Q,J,I,O;E=/(>)(<)(\/*)/g;Q=/[ ]*(.*)[ ]+\n/g;H=/(<.+>)(.+\n)/g;L=L.replace(E,"$1\n$2$3").replace(Q,"$1\n").replace(H,"$1\n$2");G=0;K="";R=L.split("\n");F=0;M="other";P={"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};J=function(X){var T,S,V,Z,W,U,Y;U={single:Boolean(X.match(/<.+\/>/)),closing:Boolean(X.match(/<\/.+>/)),opening:Boolean(X.match(/<[^!?].*>/))};W=((function(){var aa;aa=[];for(V in U){Y=U[V];if(Y){aa.push(V)}}return aa})())[0];W=W===void 0?"other":W;T=M+"->"+W;M=W;Z="";F+=P[T];Z=((function(){var ab,ac,aa;aa=[];for(S=ab=0,ac=F;0<=ac?abac;S=0<=ac?++ab:--ab){aa.push(" ")}return aa})()).join("");if(T==="opening->closing"){return K=K.substr(0,K.length-1)+X+"\n"}else{return K+=Z+X+"\n"}};for(I=0,O=R.length;I").text("no content");I=$('
        ').append(G)}else{if(P==="application/json"||/\+json$/.test(P)){Q=null;try{Q=JSON.stringify(JSON.parse(N),null,"  ")}catch(O){M=O;Q="can't parse JSON.  Raw result:\n\n"+N}G=$("").text(Q);I=$('
        ').append(G)}else{if(P==="application/xml"||/\+xml$/.test(P)){G=$("").text(this.formatXml(N));I=$('
        ').append(G)}else{if(P==="text/html"){G=$("").html(_.escape(N));I=$('
        ').append(G)}else{if(/^image\//.test(P)){I=$("").attr("src",F)}else{G=$("").text(N);I=$('
        ').append(G)}}}}}L=I;$(".request_url",$(this.el)).html("
        ");$(".request_url pre",$(this.el)).text(F);$(".response_code",$(this.el)).html("
        "+J.status+"
        ");$(".response_body",$(this.el)).html(L);$(".response_headers",$(this.el)).html("
        "+_.escape(JSON.stringify(J.headers,null,"  ")).replace(/\n/g,"
        ")+"
        ");$(".response",$(this.el)).slideDown();$(".response_hider",$(this.el)).show();$(".response_throbber",$(this.el)).hide();K=$(".response_body",$(this.el))[0];E=this.options.swaggerOptions;if(E.highlightSizeThreshold&&J.data.length>E.highlightSizeThreshold){return K}else{return hljs.highlightBlock(K)}};C.prototype.toggleOperationContent=function(){var E;E=$("#"+Docs.escapeResourceName(this.model.parentId+"_"+this.model.nickname+"_content"));if(E.is(":visible")){return Docs.collapseOperation(E)}else{return Docs.expandOperation(E)}};return C})(Backbone.View);r=(function(D){y(C,D);function C(){e=C.__super__.constructor.apply(this,arguments);return e}C.prototype.initialize=function(){};C.prototype.render=function(){var F,E,G;G=this.template();$(this.el).html(G(this.model));if(swaggerUi.api.models.hasOwnProperty(this.model.responseModel)){F={sampleJSON:JSON.stringify(swaggerUi.api.models[this.model.responseModel].createJSONSample(),null,2),isParam:false,signature:swaggerUi.api.models[this.model.responseModel].getMockSignature()};E=new j({model:F,tagName:"div"});$(".model-signature",this.$el).append(E.render().el)}else{$(".model-signature",this.$el).html("")}return this};C.prototype.template=function(){return Handlebars.templates.status_code};return C})(Backbone.View);m=(function(D){y(C,D);function C(){c=C.__super__.constructor.apply(this,arguments);return c}C.prototype.initialize=function(){return Handlebars.registerHelper("isArray",function(F,E){if(F.type.toLowerCase()==="array"||F.allowMultiple){return E.fn(this)}else{return E.inverse(this)}})};C.prototype.render=function(){var E,F,I,G,J,H,M,N,L,K;K=this.model.type||this.model.dataType;if(typeof K==="undefined"){H=this.model.schema;if(H&&H["$ref"]){G=H["$ref"];if(G.indexOf("#/definitions/")===0){K=G.substring("#/definitions/".length)}else{K=G}}}this.model.type=K;this.model.paramType=this.model["in"]||this.model.paramType;if(this.model.paramType==="body"){this.model.isBody=true}if(K&&K.toLowerCase()==="file"){this.model.isFile=true}this.model["default"]=this.model["default"]||this.model.defaultValue;if(this.model.allowableValues){this.model.isList=true}L=this.template();$(this.el).html(L(this.model));M={sampleJSON:this.model.sampleJSON,isParam:true,signature:this.model.signature};if(this.model.sampleJSON){N=new j({model:M,tagName:"div"});$(".model-signature",$(this.el)).append(N.render().el)}else{$(".model-signature",$(this.el)).html(this.model.signature)}F=false;if(this.model.isBody){F=true}E={isParam:F};E.consumes=this.model.consumes;if(F){I=new n({model:E});$(".parameter-content-type",$(this.el)).append(I.render().el)}else{J=new o({model:E});$(".response-content-type",$(this.el)).append(J.render().el)}return this};C.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 C})(Backbone.View);j=(function(D){y(C,D);function C(){a=C.__super__.constructor.apply(this,arguments);return a}C.prototype.events={"click a.description-link":"switchToDescription","click a.snippet-link":"switchToSnippet","mousedown .snippet":"snippetToTextArea"};C.prototype.initialize=function(){};C.prototype.render=function(){var E;E=this.template();$(this.el).html(E(this.model));this.switchToSnippet();this.isParam=this.model.isParam;if(this.isParam){$(".notice",$(this.el)).text("Click to set as parameter value")}return this};C.prototype.template=function(){return Handlebars.templates.signature};C.prototype.switchToDescription=function(E){if(E!=null){E.preventDefault()}$(".snippet",$(this.el)).hide();$(".description",$(this.el)).show();$(".description-link",$(this.el)).addClass("selected");return $(".snippet-link",$(this.el)).removeClass("selected")};C.prototype.switchToSnippet=function(E){if(E!=null){E.preventDefault()}$(".description",$(this.el)).hide();$(".snippet",$(this.el)).show();$(".snippet-link",$(this.el)).addClass("selected");return $(".description-link",$(this.el)).removeClass("selected")};C.prototype.snippetToTextArea=function(E){var F;if(this.isParam){if(E!=null){E.preventDefault()}F=$("textarea",$(this.el.parentNode.parentNode.parentNode));if($.trim(F.val())===""){return F.val(this.model.sampleJSON)}}};return C})(Backbone.View);l=(function(C){y(D,C);function D(){A=D.__super__.constructor.apply(this,arguments);return A}D.prototype.initialize=function(){};D.prototype.render=function(){var E;E=this.template();$(this.el).html(E(this.model));$("label[for=contentType]",$(this.el)).text("Response Content Type");return this};D.prototype.template=function(){return Handlebars.templates.content_type};return D})(Backbone.View);o=(function(C){y(D,C);function D(){z=D.__super__.constructor.apply(this,arguments);return z}D.prototype.initialize=function(){};D.prototype.render=function(){var E;E=this.template();$(this.el).html(E(this.model));$("label[for=responseContentType]",$(this.el)).text("Response Content Type");return this};D.prototype.template=function(){return Handlebars.templates.response_content_type};return D})(Backbone.View);n=(function(D){y(C,D);function C(){d=C.__super__.constructor.apply(this,arguments);return d}C.prototype.initialize=function(){};C.prototype.render=function(){var E;E=this.template();$(this.el).html(E(this.model));$("label[for=parameterContentType]",$(this.el)).text("Parameter content type:");return this};C.prototype.template=function(){return Handlebars.templates.parameter_content_type};return C})(Backbone.View);t=(function(D){y(C,D);function C(){b=C.__super__.constructor.apply(this,arguments);return b}C.prototype.initialize=function(){};C.prototype.render=function(){var E;E=this.template();$(this.el).html(E(this.model));return this};C.prototype.events={"click #apikey_button":"toggleApiKeyContainer","click #apply_api_key":"applyApiKey"};C.prototype.applyApiKey=function(){var E;window.authorizations.add(this.model.name,new ApiKeyAuthorization(this.model.name,$("#input_apiKey_entry").val(),this.model["in"]));window.swaggerUi.load();return E=$("#apikey_container").show()};C.prototype.toggleApiKeyContainer=function(){var E;if($("#apikey_container").length>0){E=$("#apikey_container").first();if(E.is(":visible")){return E.hide()}else{$(".auth_container").hide();return E.show()}}};C.prototype.template=function(){return Handlebars.templates.apikey_button_view};return C})(Backbone.View);k=(function(D){y(C,D);function C(){B=C.__super__.constructor.apply(this,arguments);return B}C.prototype.initialize=function(){};C.prototype.render=function(){var E;E=this.template();$(this.el).html(E(this.model));return this};C.prototype.events={"click #basic_auth_button":"togglePasswordContainer","click #apply_basic_auth":"applyPassword"};C.prototype.applyPassword=function(){var F,E,G;console.log("applying password");G=$(".input_username").val();E=$(".input_password").val();window.authorizations.add(this.model.type,new PasswordAuthorization("basic",G,E));window.swaggerUi.load();return F=$("#basic_auth_container").hide()};C.prototype.togglePasswordContainer=function(){var E;if($("#basic_auth_container").length>0){E=$("#basic_auth_container").show();if(E.is(":visible")){return E.slideUp()}else{$(".auth_container").hide();return E.show()}}};C.prototype.template=function(){return Handlebars.templates.basic_auth_button_view};return C})(Backbone.View)}).call(this); \ No newline at end of file