diff --git a/.jshintignore b/.jshintignore index 38614d1f..43f7cdb1 100644 --- a/.jshintignore +++ b/.jshintignore @@ -1,3 +1,5 @@ +node_modules +test src/main/javascript/doc.js dist lib \ No newline at end of file diff --git a/.jshintrc b/.jshintrc index 292552e3..e5afedf9 100644 --- a/.jshintrc +++ b/.jshintrc @@ -23,13 +23,13 @@ "$": false, "jQuery": false, "marked": false, - "HeaderView": false, - "MainView": false, "Docs": false, "SwaggerClient": false, "Handlebars": false, "ApiKeyAuthorization": false, "PasswordAuthorization": false, - "hljs": false + "hljs": false, + "SwaggerUi": false, + "swaggerUi": false // TODO: remove me } } \ No newline at end of file diff --git a/dist/swagger-ui.js b/dist/swagger-ui.js index b6842116..e8002ac9 100644 --- a/dist/swagger-ui.js +++ b/dist/swagger-ui.js @@ -200,8 +200,7 @@ window.SwaggerUi = Backbone.Router.extend({ }); -window.SwaggerUi.Views = {}; -window.SwaggerUi = SwaggerUi; +window.SwaggerUi.Views = {}; 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) { @@ -1159,7 +1158,7 @@ SwaggerUi.Views.HeaderView = Backbone.View.extend({ update: function(url, apiKey, trigger){ if (trigger === undefined) { - trigger = false + trigger = false; } $('#input_baseUrl').val(url); @@ -1509,7 +1508,7 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({ addStatusCode: function(statusCode) { // Render status codes - var statusCodeView = new StatusCodeView({model: statusCode, tagName: 'tr'}); + var statusCodeView = new SwaggerUi.Views.StatusCodeView({model: statusCode, tagName: 'tr'}); $('.operation-status', $(this.el)).append(statusCodeView.render().el); }, @@ -2053,7 +2052,7 @@ SwaggerUi.Views.ResourceView = Backbone.View.extend({ operation.nickname = id; operation.parentId = this.model.id; this.addOperation(operation); - }; + } $('.toggleEndpointList', this.el).click(this.callDocs.bind(this, 'toggleEndpointListForResource')); $('.collapseResource', this.el).click(this.callDocs.bind(this, 'collapseOperationsForResource')); @@ -2163,7 +2162,7 @@ SwaggerUi.Views.SignatureView = Backbone.View.extend({ }); 'use strict'; -var StatusCodeView = Backbone.View.extend({ +SwaggerUi.Views.StatusCodeView = Backbone.View.extend({ initialize: function () { }, @@ -2171,6 +2170,7 @@ var StatusCodeView = Backbone.View.extend({ render: function(){ $(this.el).html(Handlebars.templates.status_code(this.model)); + // TODO get rid of "swaggerUi" global dependency if (swaggerUi.api.models.hasOwnProperty(this.model.responseModel)) { var responseModel = { sampleJSON: JSON.stringify(swaggerUi.api.models[this.model.responseModel].createJSONSample(), null, 2), diff --git a/dist/swagger-ui.min.js b/dist/swagger-ui.min.js index 3dd8128d..2846b4ef 100644 --- a/dist/swagger-ui.min.js +++ b/dist/swagger-ui.min.js @@ -1,2 +1,2 @@ -"use strict";function clippyCopiedCallback(){$("#api_key_copied").fadeIn().delay(1e3).fadeOut()}function log(){log.history=log.history||[],log.history.push(arguments),this.console&&console.log(Array.prototype.slice.call(arguments)[0])}window.SwaggerUi=Backbone.Router.extend({dom_id:"swagger_ui",options:null,api:null,headerView:null,mainView:null,initialize:function(e){e=e||{},e.dom_id&&(this.dom_id=e.dom_id,delete e.dom_id),e.supportedSubmitMethods||(e.supportedSubmitMethods=["get","put","post","delete","head","options","patch"]),$("#"+this.dom_id)||$("body").append('
'),this.options=e,marked.setOptions({gfm:!0});var n=this;this.options.success=function(){return n.render()},this.options.progress=function(e){return n.showMessage(e)},this.options.failure=function(e){return n.onLoadFailure(e)},this.headerView=new SwaggerUi.Views.HeaderView({el:$("#header")}),this.headerView.on("update-swagger-ui",function(e){return this.updateSwaggerUi(e)})},setOption:function(e,n){this.options[e]=n},getOption:function(e){return this.options[e]},updateSwaggerUi:function(e){this.options.url=e.url,this.load()},load:function(){this.mainView&&this.mainView.clear();var e=this.options.url;e&&0!==e.indexOf("http")&&(e=this.buildUrl(window.location.href.toString(),e)),this.options.url=e,this.headerView.update(e),this.api=new SwaggerClient(this.options)},collapseAll:function(){Docs.collapseEndpointListForResource("")},listAll:function(){Docs.collapseOperationsForResource("")},expandAll:function(){Docs.expandOperationsForResource("")},render:function(){switch(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}).render(),this.showMessage(),this.options.docExpansion){case"full":this.expandAll();break;case"list":this.listAll()}this.renderGFM(),this.options.onComplete&&this.options.onComplete(this.api,this),setTimeout(Docs.shebang.bind(this),100)},buildUrl:function(e,n){if(0===n.indexOf("/")){var a=e.split("/");return e=a[0]+"//"+a[2],e+n}var t=e.length;return e.indexOf("?")>-1&&(t=Math.min(t,e.indexOf("?"))),e.indexOf("#")>-1&&(t=Math.min(t,e.indexOf("#"))),e=e.substring(0,t),-1!==e.indexOf("/",e.length-1)?e+n:e+"/"+n},showMessage:function(e){void 0===e&&(e=""),$("#message-bar").removeClass("message-fail"),$("#message-bar").addClass("message-success"),$("#message-bar").html(e)},onLoadFailure:function(e){void 0===e&&(e=""),$("#message-bar").removeClass("message-success"),$("#message-bar").addClass("message-fail");var n=$("#message-bar").html(e);return this.options.onFailure&&this.options.onFailure(e),n},renderGFM:function(){$(".markdown").each(function(){$(this).html(marked($(this).html()))})}}),window.SwaggerUi.Views={},window.SwaggerUi=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(e,n,a,t){var i,s="function",l=n.helperMissing,r=this.escapeExpression;return"\n