diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index edf33e53..2167f06f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,5 +1,5 @@ ## Pull Requests -Plase make your pull requests are made to the [**`develop_2.0`**](https://github.com/swagger-api/swagger-ui/tree/develop_2.0) branch at this time. +Please open your pull requests against the [**`develop_2.0`**](https://github.com/swagger-api/swagger-ui/tree/develop_2.0) branch at this time. ## Issues SwaggerUI uses [SwaggerJS](https://github.com/swagger-api/swagger-js) library for many internal operations. If you see errors in diff --git a/bower.json b/bower.json index da275f56..a8c047b8 100644 --- a/bower.json +++ b/bower.json @@ -1,7 +1,6 @@ { "name": "swagger-ui", "main": "dist/index.html", - "version": "2.1.0", "authors": [ "Mohsen Azimi " ], diff --git a/dist/css/screen.css b/dist/css/screen.css index d6ed90bb..436cc28e 100644 --- a/dist/css/screen.css +++ b/dist/css/screen.css @@ -1155,8 +1155,16 @@ .swagger-section .auth { float: right; } -.swagger-section #api_information_panel { - position: absolute; +.swagger-section .api-ic { + height: 18px; + vertical-align: middle; + display: inline-block; + background: url(../images/explorer_icons.png) no-repeat; +} +.swagger-section .api-ic .api_information_panel { + position: relative; + margin-top: 20px; + margin-left: -5px; background: #FFF; border: 1px solid #ccc; border-radius: 5px; @@ -1167,34 +1175,32 @@ color: black; padding: 5px; } -.swagger-section #api_information_panel p .api-msg-enabled { +.swagger-section .api-ic .api_information_panel p .api-msg-enabled { color: green; } -.swagger-section #api_information_panel p .api-msg-disabled { +.swagger-section .api-ic .api_information_panel p .api-msg-disabled { color: red; } -.swagger-section .api-ic { - height: 18px; - vertical-align: middle; - display: inline-block; - background: url(../images/explorer_icons.png) no-repeat; +.swagger-section .api-ic:hover .api_information_panel { + position: absolute; + display: block; } .swagger-section .ic-info { background-position: 0 0; width: 18px; - margin-top: -7px; + margin-top: -6px; margin-left: 4px; } .swagger-section .ic-warning { background-position: -60px 0; width: 18px; - margin-top: -7px; + margin-top: -6px; margin-left: 4px; } .swagger-section .ic-error { background-position: -30px 0; width: 18px; - margin-top: -7px; + margin-top: -6px; margin-left: 4px; } .swagger-section .ic-off { diff --git a/dist/index.html b/dist/index.html index a6904d0f..3e47f2b8 100644 --- a/dist/index.html +++ b/dist/index.html @@ -1,6 +1,7 @@ + Swagger UI @@ -21,6 +22,11 @@ + + + + + . + * For example - + * + * If you wish to translate some new texsts you should do two things: + * 1. Add a new phrase pair ("New Phrase": "New Translation") into your language file (for example lang/ru.js). It will be great if you add it in other language files too. + * 2. Mark that text it templates this way New Phrase or . + * The main thing here is attribute data-sw-translate. Only inner html, title-attribute and value-attribute are going to translate. + * + */ +window.SwaggerTranslator = { + + _words:[], + + translate: function(sel) { + var $this = this; + sel = sel || '[data-sw-translate]'; + + $(sel).each(function() { + $(this).html($this._tryTranslate($(this).html())); + + $(this).val($this._tryTranslate($(this).val())); + $(this).attr('title', $this._tryTranslate($(this).attr('title'))); + }); + }, + + _tryTranslate: function(word) { + return this._words[$.trim(word)] !== undefined ? this._words[$.trim(word)] : word; + }, + + learn: function(wordsMap) { + this._words = wordsMap; + } +}; diff --git a/dist/lib/swagger-oauth.js b/dist/lib/swagger-oauth.js index fed588c6..3bf32647 100644 --- a/dist/lib/swagger-oauth.js +++ b/dist/lib/swagger-oauth.js @@ -5,6 +5,8 @@ var clientId; var realm; var oauth2KeyName; var redirect_uri; +var clientSecret; +var scopeSeparator; function handleLogin() { var scopes = []; @@ -40,6 +42,7 @@ function handleLogin() { appName = window.swaggerUi.api.info.title; } + $('.api-popup-dialog').remove(); popupDialog = $( [ '
', @@ -151,7 +154,7 @@ function handleLogin() { url += '&redirect_uri=' + encodeURIComponent(redirectUrl); url += '&realm=' + encodeURIComponent(realm); url += '&client_id=' + encodeURIComponent(clientId); - url += '&scope=' + encodeURIComponent(scopes.join(' ')); + url += '&scope=' + encodeURIComponent(scopes.join(scopeSeparator)); url += '&state=' + encodeURIComponent(state); window.open(url); @@ -184,7 +187,9 @@ function initOAuth(opts) { popupMask = (o.popupMask||$('#api-common-mask')); popupDialog = (o.popupDialog||$('.api-popup-dialog')); clientId = (o.clientId||errors.push('missing client id')); + clientSecret = (o.clientSecret||errors.push('missing client secret')); realm = (o.realm||errors.push('missing realm')); + scopeSeparator = (o.scopeSeparator||' '); if(errors.length > 0){ log('auth unable initialize oauth: ' + errors); @@ -206,6 +211,7 @@ function initOAuth(opts) { window.processOAuthCode = function processOAuthCode(data) { var params = { 'client_id': clientId, + 'client_secret': clientSecret, 'code': data.code, 'grant_type': 'authorization_code', 'redirect_uri': redirect_uri @@ -240,7 +246,7 @@ window.onOAuthComplete = function onOAuthComplete(token) { if(b){ // if all roles are satisfied var o = null; - $.each($('.auth #api_information_panel'), function(k, v) { + $.each($('.auth .api-ic .api_information_panel'), function(k, v) { var children = v; if(children && children.childNodes) { var requiredScopes = []; @@ -257,7 +263,7 @@ window.onOAuthComplete = function onOAuthComplete(token) { } } if(diff.length > 0){ - o = v.parentNode; + o = v.parentNode.parentNode; $(o.parentNode).find('.api-ic.ic-on').addClass('ic-off'); $(o.parentNode).find('.api-ic.ic-on').removeClass('ic-on'); @@ -266,7 +272,7 @@ window.onOAuthComplete = function onOAuthComplete(token) { $(o).find('.api-ic').removeClass('ic-error'); } else { - o = v.parentNode; + o = v.parentNode.parentNode; $(o.parentNode).find('.api-ic.ic-off').addClass('ic-on'); $(o.parentNode).find('.api-ic.ic-off').removeClass('ic-off'); diff --git a/dist/swagger-ui.js b/dist/swagger-ui.js index cb460bbb..13423330 100644 --- a/dist/swagger-ui.js +++ b/dist/swagger-ui.js @@ -1,8 +1,8 @@ /** * swagger-ui - Swagger UI is a dependency-free collection of HTML, JavaScript, and CSS assets that dynamically generate beautiful documentation from a Swagger-compliant API - * @version v2.1.0 + * @version v2.1.1 * @link http://swagger.io - * @license Apache 2.0 + * @license Apache-2.0 */ (function(){this["Handlebars"] = this["Handlebars"] || {}; this["Handlebars"]["templates"] = this["Handlebars"]["templates"] || {}; @@ -10,10 +10,10 @@ this["Handlebars"]["templates"]["apikey_button_view"] = Handlebars.template({"co var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression; return "\n
\n
\n
\n \n \n
\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"; + 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 = ""; @@ -31,7 +31,7 @@ this["Handlebars"]["templates"]["content_type"] = Handlebars.template({"1":funct },"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'; } return new Handlebars.SafeString(result); @@ -319,15 +327,15 @@ this["Handlebars"]["templates"]["main"] = Handlebars.template({"1":function(dept var stack1, lambda=this.lambda, escapeExpression=this.escapeExpression; return ""; + + "\" data-sw-translate>Terms of service"; },"6":function(depth0,helpers,partials,data) { var stack1, lambda=this.lambda, escapeExpression=this.escapeExpression; - return ""; },"12":function(depth0,helpers,partials,data) { var stack1, lambda=this.lambda, escapeExpression=this.escapeExpression; return "\n"; },"16":function(depth0,helpers,partials,data) { var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression; - return "

Response Class (Status " + return "

Response Class (Status " + escapeExpression(((helper = (helper = helpers.successCode || (depth0 != null ? depth0.successCode : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"successCode","hash":{},"data":data}) : helper))) + ")

\n

\n
\n
\n"; },"18":function(depth0,helpers,partials,data) { - return "

Parameters

\n \n \n \n \n \n \n \n \n \n \n \n\n \n
ParameterValueDescriptionParameter TypeData Type
\n"; + return "

Parameters

\n \n \n \n \n \n \n \n \n \n \n \n\n \n
ParameterValueDescriptionParameter TypeData Type
\n"; },"20":function(depth0,helpers,partials,data) { - return "
\n

Response Messages

\n \n \n \n \n \n \n \n \n \n \n\n \n
HTTP Status CodeReasonResponse ModelHeaders
\n"; + return "
\n

Response Messages

\n \n \n \n \n \n \n \n \n \n \n\n \n
HTTP Status CodeReasonResponse ModelHeaders
\n"; },"22":function(depth0,helpers,partials,data) { return ""; },"24":function(depth0,helpers,partials,data) { - return "
\n"; + return "
\n \n \n \n
\n"; },"26":function(depth0,helpers,partials,data) { - return "

Request Headers

\n
\n"; + return "

Request Headers

\n
\n"; },"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) { var stack1, helper, options, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression, blockHelperMissing=helpers.blockHelperMissing, buffer = "\n
    \n
  • Response Body\n
    \n

    Response Code

    \n
    \n

    Response Headers

    \n
    \n
\n \n \n \n"; + return buffer + "

Response Body

\n
\n

Response Code

\n
\n

Response Headers

\n
\n \n \n \n \n"; },"useData":true}); this["Handlebars"]["templates"]["param_list"] = Handlebars.template({"1":function(depth0,helpers,partials,data) { return " required"; @@ -525,7 +533,7 @@ this["Handlebars"]["templates"]["param_list"] = Handlebars.template({"1":functio + escapeExpression(((helper = (helper = helpers.valueId || (depth0 != null ? depth0.valueId : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"valueId","hash":{},"data":data}) : helper))) + "'>" + escapeExpression(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"name","hash":{},"data":data}) : helper))) - + "\n\n \n Raw\n \n"; + + "' data-sw-translate>Raw\n \n"; },"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) { var stack1, helper, options, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression, blockHelperMissing=helpers.blockHelperMissing, buffer = "
\n

\n Show/Hide\n \n
  • \n Show/Hide\n
  • \n
  • \n \n List Operations\n \n
  • \n
  • \n \n List Operations\n \n
  • \n
  • \n \n Expand Operations\n \n
  • \n"; + + "\" data-sw-translate>\n Expand Operations\n \n \n"; stack1 = helpers['if'].call(depth0, (depth0 != null ? depth0.url : depth0), {"name":"if","hash":{},"fn":this.program(3, data),"inverse":this.noop,"data":data}); if (stack1 != null) { buffer += stack1; } return buffer + " \n

    \n