From 4f48f406388d1473e4c3433c1cd199a57f6aff27 Mon Sep 17 00:00:00 2001 From: bodnia Date: Wed, 24 Feb 2016 23:18:43 +0200 Subject: [PATCH] fixed running unit tests --- dist/css/print.css | 12 +- dist/css/screen.css | 12 +- dist/swagger-ui.js | 1780 +++++++++++++++++----------------- dist/swagger-ui.min.js | 22 +- karma.conf.js | 9 +- src/main/html/css/print.css | 12 +- src/main/html/css/screen.css | 12 +- 7 files changed, 916 insertions(+), 943 deletions(-) diff --git a/dist/css/print.css b/dist/css/print.css index 35ed65b0286..9470571f3e0 100644 --- a/dist/css/print.css +++ b/dist/css/print.css @@ -82,7 +82,7 @@ .swagger-section pre .vhdl .attribute, .swagger-section pre .clojure .attribute, .swagger-section pre .coffeescript .property { - color: #8888ff; + color: #88F; } .swagger-section pre .keyword, .swagger-section pre .id, @@ -124,11 +124,11 @@ display: block; overflow-x: auto; padding: 0.5em; - background: #f0f0f0; + background: #F0F0F0; } .swagger-section .hljs, .swagger-section .hljs-subst { - color: #444444; + color: #444; } .swagger-section .hljs-keyword, .swagger-section .hljs-attribute, @@ -143,7 +143,7 @@ .swagger-section .hljs-bullet, .swagger-section .hljs-code, .swagger-section .hljs-addition { - color: #1f811f; + color: #1F811F; } .swagger-section .hljs-regexp, .swagger-section .hljs-symbol, @@ -152,7 +152,7 @@ .swagger-section .hljs-link, .swagger-section .hljs-selector-attr, .swagger-section .hljs-selector-pseudo { - color: #bc6060; + color: #BC6060; } .swagger-section .hljs-type, .swagger-section .hljs-string, @@ -173,7 +173,7 @@ color: #888888; } .swagger-section .hljs-meta { - color: #2b6ea1; + color: #2B6EA1; } .swagger-section .hljs-emphasis { font-style: italic; diff --git a/dist/css/screen.css b/dist/css/screen.css index fbdb36a4c00..9fbd283bfac 100644 --- a/dist/css/screen.css +++ b/dist/css/screen.css @@ -82,7 +82,7 @@ .swagger-section pre .vhdl .attribute, .swagger-section pre .clojure .attribute, .swagger-section pre .coffeescript .property { - color: #8888ff; + color: #88F; } .swagger-section pre .keyword, .swagger-section pre .id, @@ -124,11 +124,11 @@ display: block; overflow-x: auto; padding: 0.5em; - background: #f0f0f0; + background: #F0F0F0; } .swagger-section .hljs, .swagger-section .hljs-subst { - color: #444444; + color: #444; } .swagger-section .hljs-keyword, .swagger-section .hljs-attribute, @@ -143,7 +143,7 @@ .swagger-section .hljs-bullet, .swagger-section .hljs-code, .swagger-section .hljs-addition { - color: #1f811f; + color: #1F811F; } .swagger-section .hljs-regexp, .swagger-section .hljs-symbol, @@ -152,7 +152,7 @@ .swagger-section .hljs-link, .swagger-section .hljs-selector-attr, .swagger-section .hljs-selector-pseudo { - color: #bc6060; + color: #BC6060; } .swagger-section .hljs-type, .swagger-section .hljs-string, @@ -173,7 +173,7 @@ color: #888888; } .swagger-section .hljs-meta { - color: #2b6ea1; + color: #2B6EA1; } .swagger-section .hljs-emphasis { font-style: italic; diff --git a/dist/swagger-ui.js b/dist/swagger-ui.js index d9ff599e6fb..76fb93677e6 100644 --- a/dist/swagger-ui.js +++ b/dist/swagger-ui.js @@ -4,585 +4,298 @@ * @link http://swagger.io * @license Apache-2.0 */ -(function(){ /*global JSONEditor*/ +(function(){this["Handlebars"] = this["Handlebars"] || {}; +this["Handlebars"]["templates"] = this["Handlebars"]["templates"] || {}; +this["Handlebars"]["templates"]["apikey_button_view"] = Handlebars.template({"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) { + var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression; + return "\n
\n
\n
\n \n \n
\n
\n"; +},"useData":true}); +this["Handlebars"]["templates"]["basic_auth_button_view"] = Handlebars.template({"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) { + return "
\n
\n
\n
\n \n
\n \n \n
\n
\n\n"; + },"useData":true}); +this["Handlebars"]["templates"]["content_type"] = Handlebars.template({"1":function(depth0,helpers,partials,data) { + var stack1, buffer = ""; + stack1 = helpers.each.call(depth0, (depth0 != null ? depth0.produces : depth0), {"name":"each","hash":{},"fn":this.program(2, data),"inverse":this.noop,"data":data}); + if (stack1 != null) { buffer += stack1; } + return buffer; +},"2":function(depth0,helpers,partials,data) { + var lambda=this.lambda, escapeExpression=this.escapeExpression; + return " \n"; +},"4":function(depth0,helpers,partials,data) { + return " \n"; + },"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) { + var stack1, helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression, buffer = "\n\n"; +},"useData":true}); 'use strict'; -window.SwaggerUi = Backbone.Router.extend({ - - dom_id: 'swagger_ui', - // Attributes - options: null, - api: null, - headerView: null, - mainView: null, +$(function() { - // SwaggerUi accepts all the same options as SwaggerApi - initialize: function(options) { - options = options || {}; + // Helper function for vertically aligning DOM elements + // http://www.seodenver.com/simple-vertical-align-plugin-for-jquery/ + $.fn.vAlign = function() { + return this.each(function(){ + var ah = $(this).height(); + var ph = $(this).parent().height(); + var mh = (ph - ah) / 2; + $(this).css('margin-top', mh); + }); + }; - if (options.defaultModelRendering !== 'model') { - options.defaultModelRendering = 'schema'; - } + $.fn.stretchFormtasticInputWidthToParent = function() { + return this.each(function(){ + var p_width = $(this).closest("form").innerWidth(); + var p_padding = parseInt($(this).closest("form").css('padding-left') ,10) + parseInt($(this).closest('form').css('padding-right'), 10); + var this_padding = parseInt($(this).css('padding-left'), 10) + parseInt($(this).css('padding-right'), 10); + $(this).css('width', p_width - p_padding - this_padding); + }); + }; - if (!options.highlightSizeThreshold) { - options.highlightSizeThreshold = 100000; - } + $('form.formtastic li.string input, form.formtastic textarea').stretchFormtasticInputWidthToParent(); - // Allow dom_id to be overridden - if (options.dom_id) { - this.dom_id = options.dom_id; - delete options.dom_id; - } + // Vertically center these paragraphs + // Parent may need a min-height for this to work.. + $('ul.downplayed li div.content p').vAlign(); - if (!options.supportedSubmitMethods){ - options.supportedSubmitMethods = [ - 'get', - 'put', - 'post', - 'delete', - 'head', - 'options', - 'patch' - ]; - } + // When a sandbox form is submitted.. + $("form.sandbox").submit(function(){ - if (typeof options.oauth2RedirectUrl === 'string') { - window.oAuthRedirectUrl = options.redirectUrl; - } + var error_free = true; - // Create an empty div which contains the dom_id - if (! $('#' + this.dom_id).length){ - $('body').append('
') ; - } + // Cycle through the forms required inputs + $(this).find("input.required").each(function() { - this.options = options; + // Remove any existing error styles from the input + $(this).removeClass('error'); - // set marked options - marked.setOptions({gfm: true}); + // Tack the error style on if the input is empty.. + if ($(this).val() === '') { + $(this).addClass('error'); + $(this).wiggle(); + error_free = false; + } - // Set the callbacks - var that = this; - this.options.success = function() { return that.render(); }; - this.options.progress = function(d) { return that.showMessage(d); }; - this.options.failure = function(d) { return that.onLoadFailure(d); }; + }); - // Create view to handle the header inputs - this.headerView = new SwaggerUi.Views.HeaderView({el: $('#header')}); + return error_free; + }); - // Event handler for when the baseUrl/apiKey is entered by user - this.headerView.on('update-swagger-ui', function(data) { - return that.updateSwaggerUi(data); - }); +}); - // JSon Editor custom theming - JSONEditor.defaults.iconlibs.swagger = JSONEditor.AbstractIconLib.extend({ - mapping: { - collapse: 'collapse', - expand: 'expand' - }, - icon_prefix: 'swagger-' - }); +function clippyCopiedCallback() { + $('#api_key_copied').fadeIn().delay(1000).fadeOut(); - }, + // var b = $("#clippy_tooltip_" + a); + // b.length != 0 && (b.attr("title", "copied!").trigger("tipsy.reload"), setTimeout(function() { + // b.attr("title", "copy to clipboard") + // }, + // 500)) +} - // Set an option after initializing - setOption: function(option, value) { - this.options[option] = value; - }, +// Logging function that accounts for browsers that don't have window.console +function log(){ + log.history = log.history || []; + log.history.push(arguments); + if(this.console){ + console.log( Array.prototype.slice.call(arguments)[0] ); + } +} - // Get the value of a previously set option - getOption: function(option) { - return this.options[option]; - }, +// Handle browsers that do console incorrectly (IE9 and below, see http://stackoverflow.com/a/5539378/7913) +if (Function.prototype.bind && console && typeof console.log === "object") { + [ + "log","info","warn","error","assert","dir","clear","profile","profileEnd" + ].forEach(function (method) { + console[method] = this.bind(console[method], console); + }, Function.prototype.call); +} - // Event handler for when url/key is received from user - updateSwaggerUi: function(data){ - this.options.url = data.url; - this.load(); - }, +window.Docs = { - // Create an api and render - load: function(){ - // Initialize the API object - if (this.mainView) { - this.mainView.clear(); - } - var url = this.options.url; - if (url && url.indexOf('http') !== 0) { - url = this.buildUrl(window.location.href.toString(), url); - } - if(this.api) { - this.options.authorizations = this.api.clientAuthorizations.authz; - } - this.options.url = url; - this.headerView.update(url); + shebang: function() { - this.api = new SwaggerClient(this.options); - }, + // If shebang has an operation nickname in it.. + // e.g. /docs/#!/words/get_search + var fragments = $.param.fragment().split('/'); + fragments.shift(); // get rid of the bang - // collapse all sections - collapseAll: function(){ - Docs.collapseEndpointListForResource(''); - }, + switch (fragments.length) { + case 1: + if (fragments[0].length > 0) { // prevent matching "#/" + // Expand all operations for the resource and scroll to it + var dom_id = 'resource_' + fragments[0]; - // list operations for all sections - listAll: function(){ - Docs.collapseOperationsForResource(''); - }, + Docs.expandEndpointListForResource(fragments[0]); + $("#"+dom_id).slideto({highlight: false}); + } + break; + case 2: + // Refer to the endpoint DOM element, e.g. #words_get_search - // expand operations for all sections - expandAll: function(){ - Docs.expandOperationsForResource(''); - }, + // Expand Resource + Docs.expandEndpointListForResource(fragments[0]); + $("#"+dom_id).slideto({highlight: false}); - // This is bound to success handler for SwaggerApi - // so it gets called when SwaggerApi completes loading - render: function(){ - this.showMessage('Finished Loading Resource Information. Rendering Swagger UI...'); - this.mainView = new SwaggerUi.Views.MainView({ - model: this.api, - el: $('#' + this.dom_id), - swaggerOptions: this.options, - router: this - }).render(); - this.showMessage(); - switch (this.options.docExpansion) { - case 'full': - this.expandAll(); break; - case 'list': - this.listAll(); break; - default: - break; - } - this.renderGFM(); + // Expand operation + var li_dom_id = fragments.join('_'); + var li_content_dom_id = li_dom_id + "_content"; - if (this.options.onComplete){ - this.options.onComplete(this.api, this); - } - setTimeout(Docs.shebang.bind(this), 100); - }, + Docs.expandOperation($('#'+li_content_dom_id)); + $('#'+li_dom_id).slideto({highlight: false}); + break; + } + }, - buildUrl: function(base, url){ - if (url.indexOf('/') === 0) { - var parts = base.split('/'); - base = parts[0] + '//' + parts[2]; - return base + url; - } else { - var endOfPath = base.length; + toggleEndpointListForResource: function(resource) { + var elem = $('li#resource_' + Docs.escapeResourceName(resource) + ' ul.endpoints'); + if (elem.is(':visible')) { + $.bbq.pushState('#/', 2); + Docs.collapseEndpointListForResource(resource); + } else { + $.bbq.pushState('#/' + resource, 2); + Docs.expandEndpointListForResource(resource); + } + }, - if (base.indexOf('?') > -1){ - endOfPath = Math.min(endOfPath, base.indexOf('?')); - } + // Expand resource + expandEndpointListForResource: function(resource) { + var resource = Docs.escapeResourceName(resource); + if (resource == '') { + $('.resource ul.endpoints').slideDown(); + return; + } - if (base.indexOf('#') > -1){ - endOfPath = Math.min(endOfPath, base.indexOf('#')); - } + $('li#resource_' + resource).addClass('active'); - base = base.substring(0, endOfPath); + var elem = $('li#resource_' + resource + ' ul.endpoints'); + elem.slideDown(); + }, - if (base.indexOf('/', base.length - 1 ) !== -1){ - return base + url; - } + // Collapse resource and mark as explicitly closed + collapseEndpointListForResource: function(resource) { + var resource = Docs.escapeResourceName(resource); + if (resource == '') { + $('.resource ul.endpoints').slideUp(); + return; + } - return base + '/' + url; - } - }, + $('li#resource_' + resource).removeClass('active'); - // Shows message on topbar of the ui - showMessage: function(data){ - if (data === undefined) { - data = ''; - } - var $msgbar = $('#message-bar'); - $msgbar.removeClass('message-fail'); - $msgbar.addClass('message-success'); - $msgbar.text(data); - if(window.SwaggerTranslator) { - window.SwaggerTranslator.translate($msgbar); - } - }, + var elem = $('li#resource_' + resource + ' ul.endpoints'); + elem.slideUp(); + }, - // shows message in red - onLoadFailure: function(data){ - if (data === undefined) { - data = ''; - } - $('#message-bar').removeClass('message-success'); - $('#message-bar').addClass('message-fail'); + expandOperationsForResource: function(resource) { + // Make sure the resource container is open.. + Docs.expandEndpointListForResource(resource); - var val = $('#message-bar').text(data); + if (resource == '') { + $('.resource ul.endpoints li.operation div.content').slideDown(); + return; + } - if (this.options.onFailure) { - this.options.onFailure(data); - } + $('li#resource_' + Docs.escapeResourceName(resource) + ' li.operation div.content').each(function() { + Docs.expandOperation($(this)); + }); + }, - return val; - }, + collapseOperationsForResource: function(resource) { + // Make sure the resource container is open.. + Docs.expandEndpointListForResource(resource); - // Renders GFM for elements with 'markdown' class - renderGFM: function(){ - $('.markdown').each(function(){ - $(this).html(marked($(this).html())); - }); + if (resource == '') { + $('.resource ul.endpoints li.operation div.content').slideUp(); + return; + } - $('.propDesc', '.model-signature .description').each(function () { - $(this).html(marked($(this).html())).addClass('markdown'); - }); - } + $('li#resource_' + Docs.escapeResourceName(resource) + ' li.operation div.content').each(function() { + Docs.collapseOperation($(this)); + }); + }, -}); + escapeResourceName: function(resource) { + return resource.replace(/[!"#$%&'()*+,.\/:;<=>?@\[\\\]\^`{|}~]/g, "\\$&"); + }, -window.SwaggerUi.Views = {}; -window.SwaggerUi.partials = {}; + expandOperation: function(elem) { + elem.slideDown(); + }, -// don't break backward compatibility with previous versions and warn users to upgrade their code -(function(){ - window.authorizations = { - add: function() { - warn('Using window.authorizations is deprecated. Please use SwaggerUi.api.clientAuthorizations.add().'); + collapseOperation: function(elem) { + elem.slideUp(); + } +}; - if (typeof window.swaggerUi === 'undefined') { - throw new TypeError('window.swaggerUi is not defined'); - } +'use strict'; +/*jslint eqeq: true*/ - if (window.swaggerUi instanceof SwaggerUi) { - window.swaggerUi.api.clientAuthorizations.add.apply(window.swaggerUi.api.clientAuthorizations, arguments); - } - } - }; +Handlebars.registerHelper('sanitize', function(html) { + // Strip the script tags from the html, and return it as a Handlebars.SafeString + html = html.replace(/)<[^<]*)*<\/script>/gi, ''); + return new Handlebars.SafeString(html); +}); - window.ApiKeyAuthorization = function() { - warn('window.ApiKeyAuthorization is deprecated. Please use SwaggerClient.ApiKeyAuthorization.'); - SwaggerClient.ApiKeyAuthorization.apply(window, arguments); - }; +Handlebars.registerHelper('renderTextParam', function(param) { + var result, type = 'text', idAtt = ''; + var paramType = param.type || param.schema.type || ''; + var isArray = paramType.toLowerCase() === 'array' || param.allowMultiple; + var defaultValue = isArray && Array.isArray(param.default) ? param.default.join('\n') : param.default; - window.PasswordAuthorization = function() { - warn('window.PasswordAuthorization is deprecated. Please use SwaggerClient.PasswordAuthorization.'); - SwaggerClient.PasswordAuthorization.apply(window, arguments); - }; + var dataVendorExtensions = Object.keys(param).filter(function(property) { + // filter X-data- properties + return property.match(/^X-data-/i) !== null; + }).reduce(function(result, property) { + // remove X- from property name, so it results in html attributes like data-foo='bar' + return result += ' ' + property.substring(2, property.length) + '=\'' + param[property] + '\''; + }, ''); - function warn(message) { - if ('console' in window && typeof window.console.warn === 'function') { - console.warn(message); + if (typeof defaultValue === 'undefined') { + defaultValue = ''; } - } -})(); + if(param.format && param.format === 'password') { + type = 'password'; + } -// UMD -(function (root, factory) { - if (typeof define === 'function' && define.amd) { - // AMD. Register as an anonymous module. - define(['b'], function (b) { - return (root.SwaggerUi = factory(b)); - }); - } else if (typeof exports === 'object') { - // Node. Does not work with strict CommonJS, but - // only CommonJS-like environments that support module.exports, - // like Node. - module.exports = factory(require('b')); - } else { - // Browser globals - root.SwaggerUi = factory(root.b); + if(param.valueId) { + idAtt = ' id=\'' + param.valueId + '\''; } -}(this, function () { - return SwaggerUi; -})); -this["Handlebars"] = this["Handlebars"] || {}; -this["Handlebars"]["templates"] = this["Handlebars"]["templates"] || {}; -this["Handlebars"]["templates"]["apikey_button_view"] = Handlebars.template({"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) { - var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression; - return "\n
\n
\n
\n \n \n
\n
\n"; -},"useData":true}); -this["Handlebars"]["templates"]["basic_auth_button_view"] = Handlebars.template({"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) { - return "
\n
\n
\n
\n \n
\n \n \n
\n
\n\n"; - },"useData":true}); -this["Handlebars"]["templates"]["content_type"] = Handlebars.template({"1":function(depth0,helpers,partials,data) { - var stack1, buffer = ""; - stack1 = helpers.each.call(depth0, (depth0 != null ? depth0.produces : depth0), {"name":"each","hash":{},"fn":this.program(2, data),"inverse":this.noop,"data":data}); - if (stack1 != null) { buffer += stack1; } - return buffer; -},"2":function(depth0,helpers,partials,data) { - var lambda=this.lambda, escapeExpression=this.escapeExpression; - return " \n"; -},"4":function(depth0,helpers,partials,data) { - return " \n"; - },"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) { - var stack1, helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression, buffer = "\n\n"; -},"useData":true}); -'use strict'; + if (typeof defaultValue === 'string' || defaultValue instanceof String) { + defaultValue = defaultValue.replace(/'/g,'''); + } + if(isArray) { + result = ''; + } else { + var parameterClass = 'parameter'; + if(param.required) { + parameterClass += ' required'; + } + result = ''; + } + return new Handlebars.SafeString(result); +}); -$(function() { - - // Helper function for vertically aligning DOM elements - // http://www.seodenver.com/simple-vertical-align-plugin-for-jquery/ - $.fn.vAlign = function() { - return this.each(function(){ - var ah = $(this).height(); - var ph = $(this).parent().height(); - var mh = (ph - ah) / 2; - $(this).css('margin-top', mh); - }); - }; - - $.fn.stretchFormtasticInputWidthToParent = function() { - return this.each(function(){ - var p_width = $(this).closest("form").innerWidth(); - var p_padding = parseInt($(this).closest("form").css('padding-left') ,10) + parseInt($(this).closest('form').css('padding-right'), 10); - var this_padding = parseInt($(this).css('padding-left'), 10) + parseInt($(this).css('padding-right'), 10); - $(this).css('width', p_width - p_padding - this_padding); - }); - }; - - $('form.formtastic li.string input, form.formtastic textarea').stretchFormtasticInputWidthToParent(); - - // Vertically center these paragraphs - // Parent may need a min-height for this to work.. - $('ul.downplayed li div.content p').vAlign(); - - // When a sandbox form is submitted.. - $("form.sandbox").submit(function(){ - - var error_free = true; - - // Cycle through the forms required inputs - $(this).find("input.required").each(function() { - - // Remove any existing error styles from the input - $(this).removeClass('error'); - - // Tack the error style on if the input is empty.. - if ($(this).val() === '') { - $(this).addClass('error'); - $(this).wiggle(); - error_free = false; - } - - }); - - return error_free; - }); - -}); - -function clippyCopiedCallback() { - $('#api_key_copied').fadeIn().delay(1000).fadeOut(); - - // var b = $("#clippy_tooltip_" + a); - // b.length != 0 && (b.attr("title", "copied!").trigger("tipsy.reload"), setTimeout(function() { - // b.attr("title", "copy to clipboard") - // }, - // 500)) -} - -// Logging function that accounts for browsers that don't have window.console -function log(){ - log.history = log.history || []; - log.history.push(arguments); - if(this.console){ - console.log( Array.prototype.slice.call(arguments)[0] ); - } -} - -// Handle browsers that do console incorrectly (IE9 and below, see http://stackoverflow.com/a/5539378/7913) -if (Function.prototype.bind && console && typeof console.log === "object") { - [ - "log","info","warn","error","assert","dir","clear","profile","profileEnd" - ].forEach(function (method) { - console[method] = this.bind(console[method], console); - }, Function.prototype.call); -} - -window.Docs = { - - shebang: function() { - - // If shebang has an operation nickname in it.. - // e.g. /docs/#!/words/get_search - var fragments = $.param.fragment().split('/'); - fragments.shift(); // get rid of the bang - - switch (fragments.length) { - case 1: - if (fragments[0].length > 0) { // prevent matching "#/" - // Expand all operations for the resource and scroll to it - var dom_id = 'resource_' + fragments[0]; - - Docs.expandEndpointListForResource(fragments[0]); - $("#"+dom_id).slideto({highlight: false}); - } - break; - case 2: - // Refer to the endpoint DOM element, e.g. #words_get_search - - // Expand Resource - Docs.expandEndpointListForResource(fragments[0]); - $("#"+dom_id).slideto({highlight: false}); - - // Expand operation - var li_dom_id = fragments.join('_'); - var li_content_dom_id = li_dom_id + "_content"; - - - Docs.expandOperation($('#'+li_content_dom_id)); - $('#'+li_dom_id).slideto({highlight: false}); - break; - } - }, - - toggleEndpointListForResource: function(resource) { - var elem = $('li#resource_' + Docs.escapeResourceName(resource) + ' ul.endpoints'); - if (elem.is(':visible')) { - $.bbq.pushState('#/', 2); - Docs.collapseEndpointListForResource(resource); - } else { - $.bbq.pushState('#/' + resource, 2); - Docs.expandEndpointListForResource(resource); - } - }, - - // Expand resource - expandEndpointListForResource: function(resource) { - var resource = Docs.escapeResourceName(resource); - if (resource == '') { - $('.resource ul.endpoints').slideDown(); - return; - } - - $('li#resource_' + resource).addClass('active'); - - var elem = $('li#resource_' + resource + ' ul.endpoints'); - elem.slideDown(); - }, - - // Collapse resource and mark as explicitly closed - collapseEndpointListForResource: function(resource) { - var resource = Docs.escapeResourceName(resource); - if (resource == '') { - $('.resource ul.endpoints').slideUp(); - return; - } - - $('li#resource_' + resource).removeClass('active'); - - var elem = $('li#resource_' + resource + ' ul.endpoints'); - elem.slideUp(); - }, - - expandOperationsForResource: function(resource) { - // Make sure the resource container is open.. - Docs.expandEndpointListForResource(resource); - - if (resource == '') { - $('.resource ul.endpoints li.operation div.content').slideDown(); - return; - } - - $('li#resource_' + Docs.escapeResourceName(resource) + ' li.operation div.content').each(function() { - Docs.expandOperation($(this)); - }); - }, - - collapseOperationsForResource: function(resource) { - // Make sure the resource container is open.. - Docs.expandEndpointListForResource(resource); - - if (resource == '') { - $('.resource ul.endpoints li.operation div.content').slideUp(); - return; - } - - $('li#resource_' + Docs.escapeResourceName(resource) + ' li.operation div.content').each(function() { - Docs.collapseOperation($(this)); - }); - }, - - escapeResourceName: function(resource) { - return resource.replace(/[!"#$%&'()*+,.\/:;<=>?@\[\\\]\^`{|}~]/g, "\\$&"); - }, - - expandOperation: function(elem) { - elem.slideDown(); - }, - - collapseOperation: function(elem) { - elem.slideUp(); - } -}; - -'use strict'; -/*jslint eqeq: true*/ - -Handlebars.registerHelper('sanitize', function(html) { - // Strip the script tags from the html, and return it as a Handlebars.SafeString - html = html.replace(/)<[^<]*)*<\/script>/gi, ''); - return new Handlebars.SafeString(html); -}); - -Handlebars.registerHelper('renderTextParam', function(param) { - var result, type = 'text', idAtt = ''; - var paramType = param.type || param.schema.type || ''; - var isArray = paramType.toLowerCase() === 'array' || param.allowMultiple; - var defaultValue = isArray && Array.isArray(param.default) ? param.default.join('\n') : param.default; - - var dataVendorExtensions = Object.keys(param).filter(function(property) { - // filter X-data- properties - return property.match(/^X-data-/i) !== null; - }).reduce(function(result, property) { - // remove X- from property name, so it results in html attributes like data-foo='bar' - return result += ' ' + property.substring(2, property.length) + '=\'' + param[property] + '\''; - }, ''); - - if (typeof defaultValue === 'undefined') { - defaultValue = ''; - } - - if(param.format && param.format === 'password') { - type = 'password'; - } - - if(param.valueId) { - idAtt = ' id=\'' + param.valueId + '\''; - } - - if (typeof defaultValue === 'string' || defaultValue instanceof String) { - defaultValue = defaultValue.replace(/'/g,'''); - } - - if(isArray) { - result = ''; - } else { - var parameterClass = 'parameter'; - if(param.required) { - parameterClass += ' required'; - } - result = ''; - } - return new Handlebars.SafeString(result); -}); - -Handlebars.registerHelper('ifCond', function (v1, operator, v2, options) { +Handlebars.registerHelper('ifCond', function (v1, operator, v2, options) { switch (operator) { case '==': @@ -834,76 +547,15 @@ this["Handlebars"]["templates"]["operation"] = Handlebars.template({"1":function if (stack1 != null) { buffer += stack1; } return buffer + "

Response Body

\n
\n

Response Code

\n
\n

Response Headers

\n
\n \n \n \n \n"; },"useData":true}); -this["Handlebars"]["templates"]["param"] = Handlebars.template({"1":function(depth0,helpers,partials,data) { - var stack1, buffer = ""; - stack1 = helpers['if'].call(depth0, (depth0 != null ? depth0.isFile : depth0), {"name":"if","hash":{},"fn":this.program(2, data),"inverse":this.program(4, data),"data":data}); - if (stack1 != null) { buffer += stack1; } - return buffer; -},"2":function(depth0,helpers,partials,data) { - var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression; - return " \n
\n"; -},"4":function(depth0,helpers,partials,data) { - var stack1, buffer = ""; - stack1 = helpers['if'].call(depth0, (depth0 != null ? depth0['default'] : depth0), {"name":"if","hash":{},"fn":this.program(5, data),"inverse":this.program(7, data),"data":data}); - if (stack1 != null) { buffer += stack1; } - return buffer; -},"5":function(depth0,helpers,partials,data) { - var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression; - return "
\n \n
\n
\n"; -},"7":function(depth0,helpers,partials,data) { - var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression; - return " \n
\n
\n
\n"; -},"9":function(depth0,helpers,partials,data) { - var stack1, buffer = ""; - stack1 = helpers['if'].call(depth0, (depth0 != null ? depth0.isFile : depth0), {"name":"if","hash":{},"fn":this.program(2, data),"inverse":this.program(10, data),"data":data}); - if (stack1 != null) { buffer += stack1; } - return buffer; -},"10":function(depth0,helpers,partials,data) { - var stack1, helperMissing=helpers.helperMissing, buffer = ""; - stack1 = ((helpers.renderTextParam || (depth0 && depth0.renderTextParam) || helperMissing).call(depth0, depth0, {"name":"renderTextParam","hash":{},"fn":this.program(11, data),"inverse":this.noop,"data":data})); - if (stack1 != null) { buffer += stack1; } - return buffer; -},"11":function(depth0,helpers,partials,data) { - return ""; -},"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) { - var stack1, helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression, buffer = "\n\n\n"; - stack1 = helpers['if'].call(depth0, (depth0 != null ? depth0.isBody : depth0), {"name":"if","hash":{},"fn":this.program(1, data),"inverse":this.program(9, data),"data":data}); - if (stack1 != null) { buffer += stack1; } - buffer += "\n\n"; - stack1 = ((helper = (helper = helpers.description || (depth0 != null ? depth0.description : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"description","hash":{},"data":data}) : helper)); - if (stack1 != null) { buffer += stack1; } - buffer += "\n"; - stack1 = ((helper = (helper = helpers.paramType || (depth0 != null ? depth0.paramType : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"paramType","hash":{},"data":data}) : helper)); - if (stack1 != null) { buffer += stack1; } - return buffer + "\n\n \n\n"; -},"useData":true}); -this["Handlebars"]["templates"]["param_list"] = Handlebars.template({"1":function(depth0,helpers,partials,data) { - return " required"; - },"3":function(depth0,helpers,partials,data) { - return " multiple=\"multiple\""; - },"5":function(depth0,helpers,partials,data) { - return " required "; - },"7":function(depth0,helpers,partials,data) { - var stack1, buffer = " \n"; },"8":function(depth0,helpers,partials,data) { @@ -964,15 +616,15 @@ this["Handlebars"]["templates"]["param_list"] = Handlebars.template({"1":functio if (stack1 != null) { buffer += stack1; } return buffer + "\n\n"; },"useData":true}); -this["Handlebars"]["templates"]["param_readonly"] = Handlebars.template({"1":function(depth0,helpers,partials,data) { +this["Handlebars"]["templates"]["param_readonly_required"] = Handlebars.template({"1":function(depth0,helpers,partials,data) { var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression; - return " \n
\n"; + + "\n"; },"3":function(depth0,helpers,partials,data) { var stack1, buffer = ""; stack1 = helpers['if'].call(depth0, (depth0 != null ? depth0['default'] : depth0), {"name":"if","hash":{},"fn":this.program(4, data),"inverse":this.program(6, data),"data":data}); @@ -986,7 +638,7 @@ this["Handlebars"]["templates"]["param_readonly"] = Handlebars.template({"1":fun },"6":function(depth0,helpers,partials,data) { return " (empty)\n"; },"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) { - var stack1, helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression, buffer = "