diff --git a/.jshintrc b/.jshintrc index e5afedf9..6baab87b 100644 --- a/.jshintrc +++ b/.jshintrc @@ -18,18 +18,21 @@ "trailing": true, "smarttabs": true, "globals": { - "Backbone": false, + + // Libraries "_": false, "$": false, + "Backbone": false, + "Handlebars": false, "jQuery": false, "marked": false, - "Docs": false, "SwaggerClient": false, - "Handlebars": false, - "ApiKeyAuthorization": false, - "PasswordAuthorization": false, "hljs": false, "SwaggerUi": false, - "swaggerUi": false // TODO: remove me + + // Global object + // TODO: remove these + "swaggerUi": false, + "Docs": false } } \ No newline at end of file diff --git a/dist/index.html b/dist/index.html index bf585c96..809749a7 100644 --- a/dist/index.html +++ b/dist/index.html @@ -61,8 +61,9 @@ var key = encodeURIComponent($('#input_apiKey')[0].value); log("key: " + key); if(key && key.trim() != "") { + var apiKeyAuth = new SwaggerClient.ApiKeyAuthorization("api_key", key, "query"); + window.swaggerUi.api.clientAuthorizations.add("api_key", apiKeyAuth); log("added key " + key); - window.authorizations.add("api_key", new ApiKeyAuthorization("api_key", key, "query")); } } @@ -78,6 +79,12 @@ */ window.swaggerUi.load(); + + function log() { + if ('console' in window) { + console.log.apply(console, arguments); + } + } }); diff --git a/dist/swagger-ui.js b/dist/swagger-ui.js index 12ddf755..7e71b706 100644 --- a/dist/swagger-ui.js +++ b/dist/swagger-ui.js @@ -59,7 +59,7 @@ window.SwaggerUi = Backbone.Router.extend({ // Event handler for when the baseUrl/apiKey is entered by user this.headerView.on('update-swagger-ui', function(data) { - return this.updateSwaggerUi(data); + return that.updateSwaggerUi(data); }); }, @@ -1025,7 +1025,7 @@ SwaggerUi.Views.ApiKeyButton = Backbone.View.extend({ // TODO: append this to gl applyApiKey: function(){ - var keyAuth = new ApiKeyAuthorization( + var keyAuth = new SwaggerClient.ApiKeyAuthorization( this.model.name, $('#input_apiKey_entry').val(), this.model.in @@ -1078,7 +1078,7 @@ SwaggerUi.Views.BasicAuthButton = Backbone.View.extend({ applyPassword: function(){ var username = $('.input_username').val(); var password = $('.input_password').val(); - var basicAuth = new PasswordAuthorization('basic', username, password); + var basicAuth = new SwaggerClient.PasswordAuthorization('basic', username, password); window.authorizations.add(this.model.type, basicAuth); window.swaggerUi.load(); $('#basic_auth_container').hide(); diff --git a/dist/swagger-ui.min.js b/dist/swagger-ui.min.js index 1eaf09f2..f77de638 100644 --- a/dist/swagger-ui.min.js +++ b/dist/swagger-ui.min.js @@ -1,2 +1,2 @@ -(function(){"use strict";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).length||$("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(){e.collapseEndpointListForResource("")},listAll:function(){e.collapseOperationsForResource("")},expandAll:function(){e.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,router:this}).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(e.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={},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