swagger-ui
Advanced tools
Comparing version 2.1.2-M2 to 2.1.2
{ | ||
"name": "swagger-ui", | ||
"main": "dist/index.html", | ||
"version": "2.1.8-M1", | ||
"authors": [ | ||
@@ -16,3 +15,3 @@ "Mohsen Azimi <me@azimi.me>" | ||
], | ||
"license": "Copyright 2015 Reverb Technologies, Inc.", | ||
"license": "Copyright 2015 SmartBear Software", | ||
"homepage": "http://swagger.io", | ||
@@ -19,0 +18,0 @@ "private": true, |
@@ -1,5 +0,1 @@ | ||
## 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. | ||
## Issues | ||
SwaggerUI uses [SwaggerJS](https://github.com/swagger-api/swagger-js) library for many internal operations. If you see errors in | ||
@@ -6,0 +2,0 @@ [`swagger-client.js`](lib/swagger-client.js) file, you should probably open the issue in [SwaggerJS](https://github.com/swagger-api/swagger-js) repository. |
@@ -8,2 +8,4 @@ var appName; | ||
var redirect_uri; | ||
var clientSecret; | ||
var scopeSeparator; | ||
@@ -44,2 +46,3 @@ function handleLogin() { | ||
$('.api-popup-dialog').remove(); | ||
popupDialog = $( | ||
@@ -156,3 +159,3 @@ [ | ||
url += '&client_id=' + encodeURIComponent(clientId); | ||
url += '&scope=' + encodeURIComponent(scopes.join(' ')); | ||
url += '&scope=' + encodeURIComponent(scopes.join(scopeSeparator)); | ||
url += '&state=' + encodeURIComponent(state); | ||
@@ -170,4 +173,4 @@ | ||
function handleLogout() { | ||
for(key in window.authorizations.authz){ | ||
window.authorizations.remove(key) | ||
for(key in window.swaggerUi.api.clientAuthorizations.authz){ | ||
window.swaggerUi.api.clientAuthorizations.remove(key) | ||
} | ||
@@ -191,3 +194,5 @@ window.enabledScopes = null; | ||
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||' '); | ||
@@ -214,2 +219,3 @@ if(errors.length > 0){ | ||
'client_id': clientId, | ||
'client_secret': clientSecret, | ||
'code': data.code, | ||
@@ -249,3 +255,3 @@ 'grant_type': 'authorization_code', | ||
var o = null; | ||
$.each($('.auth #api_information_panel'), function(k, v) { | ||
$.each($('.auth .api-ic .api_information_panel'), function(k, v) { | ||
var children = v; | ||
@@ -267,3 +273,3 @@ if(children && children.childNodes) { | ||
if(diff.length > 0){ | ||
o = v.parentNode; | ||
o = v.parentNode.parentNode; | ||
$(o.parentNode).find('.api-ic.ic-on').addClass('ic-off'); | ||
@@ -277,3 +283,3 @@ $(o.parentNode).find('.api-ic.ic-on').removeClass('ic-on'); | ||
else { | ||
o = v.parentNode; | ||
o = v.parentNode.parentNode; | ||
$(o.parentNode).find('.api-ic.ic-off').addClass('ic-on'); | ||
@@ -280,0 +286,0 @@ $(o.parentNode).find('.api-ic.ic-off').removeClass('ic-off'); |
@@ -95,3 +95,4 @@ 'use strict'; | ||
'./src/main/less/print.less', | ||
'./src/main/less/reset.less' | ||
'./src/main/less/reset.less', | ||
'./src/main/less/style.less' | ||
]) | ||
@@ -116,2 +117,8 @@ .pipe(less()) | ||
// copy `lang` for translations | ||
gulp | ||
.src(['./lang/**/*.js']) | ||
.pipe(gulp.dest('./dist/lang')) | ||
.on('error', log); | ||
// copy all files inside html folder | ||
@@ -118,0 +125,0 @@ gulp |
@@ -24,2 +24,3 @@ 'use strict'; | ||
"Hide Response":"Hide Response", | ||
"Headers":"Headers", | ||
"Try it out!":"Try it out!", | ||
@@ -46,3 +47,2 @@ "Show/Hide":"Show/Hide", | ||
"Show Swagger Petstore Example Apis":"Show Swagger Petstore Example Apis", | ||
"Show Wordnik Developer Apis":"Show Wordnik Developer Apis", | ||
"Can't read from server. It may not have the appropriate access-control-origin settings.":"Can't read from server. It may not have the appropriate access-control-origin settings.", | ||
@@ -55,2 +55,2 @@ "Please specify the protocol for":"Please specify the protocol for", | ||
"server returned":"server returned" | ||
}); | ||
}); |
@@ -45,3 +45,2 @@ 'use strict'; | ||
"Show Swagger Petstore Example Apis":"Показать примеры АПИ", | ||
"Show Wordnik Developer Apis":"Показать АПИ Wordnik Developer", | ||
"Can't read from server. It may not have the appropriate access-control-origin settings.":"Не удается получить ответ от сервера. Возможно, какая-то лажа с настройками доступа", | ||
@@ -54,2 +53,2 @@ "Please specify the protocol for":"Пожалуйста, укажите протогол для", | ||
"server returned":"сервер сказал" | ||
}); | ||
}); |
@@ -20,6 +20,7 @@ 'use strict'; | ||
translate: function() { | ||
translate: function(sel) { | ||
var $this = this; | ||
sel = sel || '[data-sw-translate]'; | ||
$('[data-sw-translate]').each(function() { | ||
$(sel).each(function() { | ||
$(this).html($this._tryTranslate($(this).html())); | ||
@@ -33,3 +34,3 @@ | ||
_tryTranslate: function(word) { | ||
return this._words[word] !== undefined ? this._words[word] : word; | ||
return this._words[$.trim(word)] !== undefined ? this._words[$.trim(word)] : word; | ||
}, | ||
@@ -36,0 +37,0 @@ |
@@ -8,2 +8,4 @@ var appName; | ||
var redirect_uri; | ||
var clientSecret; | ||
var scopeSeparator; | ||
@@ -44,2 +46,3 @@ function handleLogin() { | ||
$('.api-popup-dialog').remove(); | ||
popupDialog = $( | ||
@@ -156,3 +159,3 @@ [ | ||
url += '&client_id=' + encodeURIComponent(clientId); | ||
url += '&scope=' + encodeURIComponent(scopes.join(' ')); | ||
url += '&scope=' + encodeURIComponent(scopes.join(scopeSeparator)); | ||
url += '&state=' + encodeURIComponent(state); | ||
@@ -170,4 +173,4 @@ | ||
function handleLogout() { | ||
for(key in window.authorizations.authz){ | ||
window.authorizations.remove(key) | ||
for(key in window.swaggerUi.api.clientAuthorizations.authz){ | ||
window.swaggerUi.api.clientAuthorizations.remove(key) | ||
} | ||
@@ -191,3 +194,5 @@ window.enabledScopes = null; | ||
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||' '); | ||
@@ -214,2 +219,3 @@ if(errors.length > 0){ | ||
'client_id': clientId, | ||
'client_secret': clientSecret, | ||
'code': data.code, | ||
@@ -249,3 +255,3 @@ 'grant_type': 'authorization_code', | ||
var o = null; | ||
$.each($('.auth #api_information_panel'), function(k, v) { | ||
$.each($('.auth .api-ic .api_information_panel'), function(k, v) { | ||
var children = v; | ||
@@ -267,3 +273,3 @@ if(children && children.childNodes) { | ||
if(diff.length > 0){ | ||
o = v.parentNode; | ||
o = v.parentNode.parentNode; | ||
$(o.parentNode).find('.api-ic.ic-on').addClass('ic-off'); | ||
@@ -277,3 +283,3 @@ $(o.parentNode).find('.api-ic.ic-on').removeClass('ic-on'); | ||
else { | ||
o = v.parentNode; | ||
o = v.parentNode.parentNode; | ||
$(o.parentNode).find('.api-ic.ic-off').addClass('ic-on'); | ||
@@ -280,0 +286,0 @@ $(o.parentNode).find('.api-ic.ic-off').removeClass('ic-off'); |
@@ -11,5 +11,5 @@ { | ||
"description": "Swagger UI is a dependency-free collection of HTML, JavaScript, and CSS assets that dynamically generate beautiful documentation from a Swagger-compliant API", | ||
"version": "2.1.2-M2", | ||
"version": "2.1.2", | ||
"homepage": "http://swagger.io", | ||
"license": "Apache 2.0", | ||
"license": "Apache-2.0", | ||
"main": "dist/swagger-ui.js", | ||
@@ -54,4 +54,4 @@ "scripts": { | ||
"selenium-webdriver": "^2.45.0", | ||
"swagger-client": "2.1.4-M2" | ||
"swagger-client": "2.1.3" | ||
} | ||
} |
@@ -23,3 +23,3 @@ # Swagger UI | ||
------------------ | ------------ | -------------------------- | ----- | ------ | ||
2.1.1-M2 | 2015-04-16 | 1.1, 1.2, 2.0 | [master](https://github.com/swagger-api/swagger-ui) | | ||
2.1.1 | 2015-07-23 | 1.1, 1.2, 2.0 | [tag v.2.1.1](https://github.com/swagger-api/swagger-ui/tree/v2.1.1) | | ||
2.0.24 | 2014-09-12 | 1.1, 1.2 | [tag v2.0.24](https://github.com/swagger-api/swagger-ui/tree/v2.0.24) | | ||
@@ -100,4 +100,5 @@ 1.0.13 | 2013-03-08 | 1.1, 1.2 | [tag v1.0.13](https://github.com/swagger-api/swagger-ui/tree/v1.0.13) | | ||
highlightSizeThreshold | Any size response below this threshold will be highlighted syntactically, attempting to highlight large responses can lead to browser hangs, not including a threshold will default to highlight all returned responses. | ||
supportedSubmitMethods | An array of of the HTTP operations that will have the 'Try it out!` option. An empty array disables all operations. This does not filter the operations from the display. | ||
supportedSubmitMethods | An array of of the HTTP operations that will have the 'Try it out!' option. An empty array disables all operations. This does not filter the operations from the display. | ||
oauth2RedirectUrl | OAuth redirect URL | ||
showRequestHeaders | Whether or not to show the headers that were sent when making a request via the 'Try it out!' option. Defaults to `false`. | ||
@@ -161,2 +162,3 @@ * All other parameters are explained in greater detail below | ||
## CORS Support | ||
### OR: How to deal with "Can't read from server. It may not have the appropriate access-control-origin settings." | ||
@@ -229,7 +231,7 @@ CORS is a technique to prevent websites from doing bad things with your personal data. Most browsers + javascript toolkits not only support CORS but enforce it, which has implications for your API server which supports Swagger. | ||
## Change Log | ||
Plsee see [releases](https://github.com/swagger-api/swagger-ui/releases) for change log. | ||
Please see [releases](https://github.com/swagger-api/swagger-ui/releases) for change log. | ||
## License | ||
Copyright 2011-2015 Reverb technologies, Inc. | ||
Copyright 2011-2015 SmartBear Software | ||
@@ -236,0 +238,0 @@ Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -96,7 +96,9 @@ 'use strict'; | ||
case 1: | ||
// Expand all operations for the resource and scroll to it | ||
var dom_id = 'resource_' + fragments[0]; | ||
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}); | ||
Docs.expandEndpointListForResource(fragments[0]); | ||
$("#"+dom_id).slideto({highlight: false}); | ||
} | ||
break; | ||
@@ -103,0 +105,0 @@ case 2: |
@@ -10,6 +10,14 @@ 'use strict'; | ||
Handlebars.registerHelper('renderTextParam', function(param) { | ||
var result, type = 'text'; | ||
var result, type = 'text', idAtt = ''; | ||
var isArray = param.type.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') { | ||
@@ -20,12 +28,20 @@ defaultValue = ''; | ||
if(param.format && param.format === 'password') { | ||
type = 'password'; | ||
type = 'password'; | ||
} | ||
if(param.valueId) { | ||
idAtt = ' id=\'' + param.valueId + '\''; | ||
} | ||
if(isArray) { | ||
result = '<textarea class=\'body-textarea' + (param.required ? ' required' : '') + '\' name=\'' + param.name + '\''; | ||
result = '<textarea class=\'body-textarea' + (param.required ? ' required' : '') + '\' name=\'' + param.name + '\'' + idAtt + dataVendorExtensions; | ||
result += ' placeholder=\'Provide multiple values in new lines' + (param.required ? ' (at least one required).' : '.') + '\'>'; | ||
result += defaultValue + '</textarea>'; | ||
} else { | ||
result = '<input class=\'parameter\'' + (param.required ? ' class=\'required\'' : '') + ' minlength=\'' + (param.required ? 1 : 0) + '\''; | ||
result += ' name=\'' + param.name +'\' placeholder=\'' + (param.required ? '(required)' : '') + '\''; | ||
var parameterClass = 'parameter'; | ||
if(param.required) { | ||
parameterClass += ' required'; | ||
} | ||
result = '<input class=\'' + parameterClass + '\' minlength=\'' + (param.required ? 1 : 0) + '\''; | ||
result += ' name=\'' + param.name +'\' placeholder=\'' + (param.required ? '(required)' : '') + '\'' + idAtt + dataVendorExtensions; | ||
result += ' type=\'' + type + '\' value=\'' + defaultValue + '\'/>'; | ||
@@ -32,0 +48,0 @@ } |
@@ -93,3 +93,5 @@ 'use strict'; | ||
} | ||
if(this.api) { | ||
this.options.authorizations = this.api.clientAuthorizations.authz; | ||
} | ||
this.options.url = url; | ||
@@ -175,5 +177,9 @@ this.headerView.update(url); | ||
} | ||
$('#message-bar').removeClass('message-fail'); | ||
$('#message-bar').addClass('message-success'); | ||
$('#message-bar').html(data); | ||
var $msgbar = $('#message-bar'); | ||
$msgbar.removeClass('message-fail'); | ||
$msgbar.addClass('message-success'); | ||
$msgbar.html(data); | ||
if(window.SwaggerTranslator) { | ||
window.SwaggerTranslator.translate($msgbar); | ||
} | ||
}, | ||
@@ -189,3 +195,3 @@ | ||
var val = $('#message-bar').html(data); | ||
var val = $('#message-bar').text(data); | ||
@@ -204,2 +210,6 @@ if (this.options.onFailure) { | ||
}); | ||
$('.propDesc', '.model-signature .description').each(function () { | ||
$(this).html(marked($(this).html())).addClass('markdown'); | ||
}); | ||
} | ||
@@ -254,3 +264,3 @@ | ||
// Node. Does not work with strict CommonJS, but | ||
// only CommonJS-like enviroments that support module.exports, | ||
// only CommonJS-like environments that support module.exports, | ||
// like Node. | ||
@@ -264,2 +274,2 @@ module.exports = factory(require('b')); | ||
return SwaggerUi; | ||
})); | ||
})); |
@@ -7,8 +7,6 @@ 'use strict'; | ||
render: function(){ | ||
this.model.contentTypeId = 'ct' + Math.random(); | ||
$(this.el).html(Handlebars.templates.content_type(this.model)); | ||
$('label[for=contentType]', $(this.el)).text('Response Content Type'); | ||
return this; | ||
} | ||
}); |
@@ -6,3 +6,2 @@ 'use strict'; | ||
'click #show-pet-store-icon' : 'showPetStore', | ||
'click #show-wordnik-dev-icon' : 'showWordnikDev', | ||
'click #explore' : 'showCustom', | ||
@@ -21,8 +20,2 @@ 'keyup #input_baseUrl' : 'showCustomOnKeyup', | ||
showWordnikDev: function(){ | ||
this.trigger('update-swagger-ui', { | ||
url: 'http://api.wordnik.com/v4/resources.json' | ||
}); | ||
}, | ||
showCustomOnKeyup: function(e){ | ||
@@ -29,0 +22,0 @@ if (e.keyCode === 13) { |
@@ -57,20 +57,16 @@ 'use strict'; | ||
if (this.model.swaggerVersion === '2.0') { | ||
if ('validatorUrl' in opts.swaggerOptions) { | ||
// Validator URL specified explicitly | ||
this.model.validatorUrl = opts.swaggerOptions.validatorUrl; | ||
} else if (this.model.url.indexOf('localhost') > 0) { | ||
// Localhost override | ||
this.model.validatorUrl = null; | ||
} else { | ||
// Default validator | ||
if(window.location.protocol.startsWith('http')) { | ||
this.model.validatorUrl = window.location.protocol + '//online.swagger.io/validator'; | ||
} | ||
if ('validatorUrl' in opts.swaggerOptions) { | ||
// Validator URL specified explicitly | ||
this.model.validatorUrl = opts.swaggerOptions.validatorUrl; | ||
} else if (this.model.url.indexOf('localhost') > 0) { | ||
// Localhost override | ||
this.model.validatorUrl = null; | ||
} else { | ||
// Default validator | ||
if(window.location.protocol === 'https:') { | ||
this.model.validatorUrl = 'https://online.swagger.io/validator'; | ||
} | ||
else { | ||
this.model.validatorUrl = 'http://online.swagger.io/validator'; | ||
} | ||
} | ||
@@ -77,0 +73,0 @@ }, |
@@ -12,3 +12,3 @@ 'use strict'; | ||
'mouseenter .api-ic' : 'mouseEnter', | ||
'mouseout .api-ic' : 'mouseExit', | ||
'dblclick .curl' : 'selectText', | ||
}, | ||
@@ -26,2 +26,20 @@ | ||
selectText: function(event) { | ||
var doc = document, | ||
text = event.target.firstChild, | ||
range, | ||
selection; | ||
if (doc.body.createTextRange) { | ||
range = document.body.createTextRange(); | ||
range.moveToElementText(text); | ||
range.select(); | ||
} else if (window.getSelection) { | ||
selection = window.getSelection(); | ||
range = document.createRange(); | ||
range.selectNodeContents(text); | ||
selection.removeAllRanges(); | ||
selection.addRange(range); | ||
} | ||
}, | ||
mouseEnter: function(e) { | ||
@@ -58,9 +76,4 @@ var elem = $(this.el).find('.content'); | ||
elem.css(pos); | ||
$(e.currentTarget.parentNode).find('#api_information_panel').show(); | ||
}, | ||
mouseExit: function(e) { | ||
$(e.currentTarget.parentNode).find('#api_information_panel').hide(); | ||
}, | ||
// Note: copied from CoffeeScript compiled file | ||
@@ -82,18 +95,19 @@ // TODO: redactor | ||
for (key in auths) { | ||
auth = auths[key]; | ||
for (a in this.auths) { | ||
auth = this.auths[a]; | ||
if (auth.type === 'oauth2') { | ||
this.model.oauth = {}; | ||
this.model.oauth.scopes = []; | ||
ref1 = auth.value.scopes; | ||
for (k in ref1) { | ||
v = ref1[k]; | ||
scopeIndex = auths[key].indexOf(k); | ||
if (scopeIndex >= 0) { | ||
o = { | ||
scope: k, | ||
description: v | ||
}; | ||
this.model.oauth.scopes.push(o); | ||
if (key === auth.name) { | ||
if (auth.type === 'oauth2') { | ||
this.model.oauth = {}; | ||
this.model.oauth.scopes = []; | ||
ref1 = auth.value.scopes; | ||
for (k in ref1) { | ||
v = ref1[k]; | ||
scopeIndex = auths[key].indexOf(k); | ||
if (scopeIndex >= 0) { | ||
o = { | ||
scope: k, | ||
description: v | ||
}; | ||
this.model.oauth.scopes.push(o); | ||
} | ||
} | ||
@@ -132,4 +146,4 @@ } | ||
schema = schemaObj.$ref; | ||
if (schema.indexOf('#/definitions/') === 0) { | ||
schema = schema.substring('#/definitions/'.length); | ||
if (schema.indexOf('#/definitions/') !== -1) { | ||
schema = schema.replace(/^.*#\/definitions\//, ''); | ||
} | ||
@@ -168,2 +182,6 @@ } | ||
} | ||
var opts = this.options.swaggerOptions; | ||
if (opts.showRequestHeaders) { | ||
this.model.showRequestHeaders = true; | ||
} | ||
$(this.el).html(Handlebars.templates.operation(this.model)); | ||
@@ -250,3 +268,3 @@ if (signatureModel) { | ||
submitOperation: function(e) { | ||
var error_free, form, isFileUpload, l, len, len1, len2, m, map, n, o, opts, ref1, ref2, ref3, val; | ||
var error_free, form, isFileUpload, map, opts; | ||
if (e !== null) { | ||
@@ -300,7 +318,8 @@ e.preventDefault(); | ||
if (error_free) { | ||
map = {}; | ||
map = this.getInputMap(form); | ||
isFileUpload = this.isFileUpload(form); | ||
opts = { | ||
parent: this | ||
}; | ||
if(this.options.swaggerOptions) { | ||
if (this.options.swaggerOptions) { | ||
for(var key in this.options.swaggerOptions) { | ||
@@ -310,30 +329,2 @@ opts[key] = this.options.swaggerOptions[key]; | ||
} | ||
isFileUpload = false; | ||
ref1 = form.find('input'); | ||
for (l = 0, len = ref1.length; l < len; l++) { | ||
o = ref1[l]; | ||
if ((o.value !== null) && jQuery.trim(o.value).length > 0) { | ||
map[o.name] = o.value; | ||
} | ||
if (o.type === 'file') { | ||
map[o.name] = o.files[0]; | ||
isFileUpload = true; | ||
} | ||
} | ||
ref2 = form.find('textarea'); | ||
for (m = 0, len1 = ref2.length; m < len1; m++) { | ||
o = ref2[m]; | ||
val = this.getTextAreaValue(o); | ||
if ((val !== null) && jQuery.trim(val).length > 0) { | ||
map[o.name] = val; | ||
} | ||
} | ||
ref3 = form.find('select'); | ||
for (n = 0, len2 = ref3.length; n < len2; n++) { | ||
o = ref3[n]; | ||
val = this.getSelectedValue(o); | ||
if ((val !== null) && jQuery.trim(val).length > 0) { | ||
map[o.name] = val; | ||
} | ||
} | ||
opts.responseContentType = $('div select[name=responseContentType]', $(this.el)).val(); | ||
@@ -343,4 +334,11 @@ opts.requestContentType = $('div select[name=parameterContentType]', $(this.el)).val(); | ||
if (isFileUpload) { | ||
return this.handleFileUpload(map, form); | ||
$('.request_url', $(this.el)).html('<pre></pre>'); | ||
$('.request_url pre', $(this.el)).text(this.invocationUrl); | ||
opts.useJQuery = true; | ||
map.parameterContentType = 'multipart/form-data'; | ||
return this.model.execute(map, opts, this.showCompleteStatus, this.showErrorStatus, this); | ||
} else { | ||
this.map = map; | ||
return this.model.execute(map, opts, this.showCompleteStatus, this.showErrorStatus, this); | ||
@@ -351,11 +349,6 @@ } | ||
success: function(response, parent) { | ||
parent.showCompleteStatus(response); | ||
}, | ||
// Note: This is compiled code | ||
// TODO: Refactor | ||
handleFileUpload: function(map, form) { | ||
var bodyParam, el, headerParams, l, len, len1, len2, len3, m, n, o, p, param, params, ref1, ref2, ref3, ref4; | ||
ref1 = form.serializeArray(); | ||
getInputMap: function (form) { | ||
var map, ref1, l, len, o, ref2, m, len1, val, ref3, n, len2; | ||
map = {}; | ||
ref1 = form.find('input'); | ||
for (l = 0, len = ref1.length; l < len; l++) { | ||
@@ -366,65 +359,43 @@ o = ref1[l]; | ||
} | ||
if (o.type === 'file') { | ||
map[o.name] = o.files[0]; | ||
} | ||
} | ||
bodyParam = new FormData(); | ||
params = 0; | ||
ref2 = this.model.parameters; | ||
ref2 = form.find('textarea'); | ||
for (m = 0, len1 = ref2.length; m < len1; m++) { | ||
param = ref2[m]; | ||
if (param.paramType === 'form' || param['in'] === 'formData') { | ||
if (param.type.toLowerCase() !== 'file' && map[param.name] !== void 0) { | ||
bodyParam.append(param.name, map[param.name]); | ||
} | ||
o = ref2[m]; | ||
val = this.getTextAreaValue(o); | ||
if ((val !== null) && jQuery.trim(val).length > 0) { | ||
map[o.name] = val; | ||
} | ||
} | ||
headerParams = {}; | ||
ref3 = this.model.parameters; | ||
ref3 = form.find('select'); | ||
for (n = 0, len2 = ref3.length; n < len2; n++) { | ||
param = ref3[n]; | ||
if (param.paramType === 'header') { | ||
headerParams[param.name] = map[param.name]; | ||
o = ref3[n]; | ||
val = this.getSelectedValue(o); | ||
if ((val !== null) && jQuery.trim(val).length > 0) { | ||
map[o.name] = val; | ||
} | ||
} | ||
ref4 = form.find('input[type~="file"]'); | ||
for (p = 0, len3 = ref4.length; p < len3; p++) { | ||
el = ref4[p]; | ||
if (typeof el.files[0] !== 'undefined') { | ||
bodyParam.append($(el).attr('name'), el.files[0]); | ||
params += 1; | ||
return map; | ||
}, | ||
isFileUpload: function (form) { | ||
var ref1, l, len, o; | ||
var isFileUpload = false; | ||
ref1 = form.find('input'); | ||
for (l = 0, len = ref1.length; l < len; l++) { | ||
o = ref1[l]; | ||
if (o.type === 'file') { | ||
isFileUpload = 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('<pre></pre>'); | ||
$('.request_url pre', $(this.el)).text(this.invocationUrl); | ||
return isFileUpload; | ||
}, | ||
// TODO: don't use jQuery. Use SwaggerJS for handling the call. | ||
var obj = { | ||
type: this.model.method, | ||
url: this.invocationUrl, | ||
headers: headerParams, | ||
data: bodyParam, | ||
dataType: 'json', | ||
contentType: false, | ||
processData: false, | ||
error: (function(_this) { | ||
return function(data) { | ||
return _this.showErrorStatus(_this.wrap(data), _this); | ||
}; | ||
})(this), | ||
success: (function(_this) { | ||
return function(data) { | ||
return _this.showResponse(data, _this); | ||
}; | ||
})(this), | ||
complete: (function(_this) { | ||
return function(data) { | ||
return _this.showCompleteStatus(_this.wrap(data), _this); | ||
}; | ||
})(this) | ||
}; | ||
jQuery.ajax(obj); | ||
return false; | ||
// end of file-upload nastiness | ||
success: function(response, parent) { | ||
parent.showCompleteStatus(response); | ||
}, | ||
// wraps a jquery response as a shred response | ||
wrap: function(data) { | ||
@@ -684,7 +655,23 @@ var h, headerArray, headers, i, l, len, o; | ||
$('.response_throbber', $(this.el)).hide(); | ||
var response_body_el = $('.response_body', $(this.el))[0]; | ||
//adds curl output | ||
var curlCommand = this.model.asCurl(this.map); | ||
curlCommand = curlCommand.replace('!', '!'); | ||
$( '.curl', $(this.el)).html('<pre>' + curlCommand + '</pre>'); | ||
// only highlight the response if response is less than threshold, default state is highlight response | ||
var opts = this.options.swaggerOptions; | ||
if (opts.highlightSizeThreshold && response.data.length > opts.highlightSizeThreshold) { | ||
if (opts.showRequestHeaders) { | ||
var form = $('.sandbox', $(this.el)), | ||
map = this.getInputMap(form), | ||
requestHeaders = this.model.getHeaderParams(map); | ||
delete requestHeaders['Content-Type']; | ||
$('.request_headers', $(this.el)).html('<pre>' + _.escape(JSON.stringify(requestHeaders, null, ' ')).replace(/\n/g, '<br>') + '</pre>'); | ||
} | ||
var response_body_el = $('.response_body', $(this.el))[0]; | ||
// only highlight the response if response is less than threshold, default state is highlight response | ||
if (opts.highlightSizeThreshold && typeof response.data !== 'undefined' && response.data.length > opts.highlightSizeThreshold) { | ||
return response_body_el; | ||
@@ -696,5 +683,7 @@ } else { | ||
toggleOperationContent: function() { | ||
toggleOperationContent: function (event) { | ||
var elem = $('#' + Docs.escapeResourceName(this.parentId + '_' + this.nickname + '_content')); | ||
if (elem.is(':visible')){ | ||
event.preventDefault(); | ||
$.bbq.pushState('#/', 2); | ||
Docs.collapseOperation(elem); | ||
@@ -701,0 +690,0 @@ } else { |
@@ -7,6 +7,4 @@ 'use strict'; | ||
render: function(){ | ||
this.model.parameterContentTypeId = 'pct' + Math.random(); | ||
$(this.el).html(Handlebars.templates.parameter_content_type(this.model)); | ||
$('label[for=parameterContentType]', $(this.el)).text('Parameter content type:'); | ||
return this; | ||
@@ -13,0 +11,0 @@ } |
@@ -33,4 +33,11 @@ 'use strict'; | ||
this.model.isFile = type && type.toLowerCase() === 'file'; | ||
this.model.default = (this.model.default || this.model.defaultValue); | ||
// Allow for default === false | ||
if(typeof this.model.default === 'undefined') { | ||
this.model.default = this.model.defaultValue; | ||
} | ||
this.model.hasDefault = (typeof this.model.default !== 'undefined'); | ||
this.model.valueId = 'm' + this.model.name + Math.random(); | ||
if (this.model.allowableValues) { | ||
@@ -37,0 +44,0 @@ this.model.isList = true; |
@@ -7,8 +7,6 @@ 'use strict'; | ||
render: function(){ | ||
this.model.responseContentTypeId = 'rct' + Math.random(); | ||
$(this.el).html(Handlebars.templates.response_content_type(this.model)); | ||
$('label[for=responseContentType]', $(this.el)).text('Response Content Type'); | ||
return this; | ||
} | ||
}); |
@@ -55,3 +55,5 @@ 'use strict'; | ||
var textArea = $('textarea', $(this.el.parentNode.parentNode.parentNode)); | ||
if ($.trim(textArea.val()) === '') { | ||
// Fix for bug in IE 10/11 which causes placeholder text to be copied to "value" | ||
if ($.trim(textArea.val()) === '' || textArea.prop('placeholder') === textArea.val()) { | ||
textArea.val(this.model.sampleJSON); | ||
@@ -58,0 +60,0 @@ } |
@@ -32,3 +32,3 @@ /* | ||
done(); | ||
}, process.env.TRAVIS ? 20000 : 3000); | ||
}, process.env.TRAVIS ? 20000 : 5000); | ||
}; | ||
@@ -35,0 +35,0 @@ |
@@ -7,2 +7,3 @@ 'use strict'; | ||
var webdriver = require('selenium-webdriver'); | ||
var until = webdriver.until; | ||
@@ -43,8 +44,4 @@ var elements = [ | ||
it('should have "Swagger UI" in title', function (done) { | ||
driver.sleep(200); | ||
driver.getTitle().then(function(title) { | ||
expect(title).to.contain('Swagger UI'); | ||
done(); | ||
}); | ||
it('should have "Swagger UI" in title', function () { | ||
return driver.wait(until.titleIs('Swagger UI'), 1000); | ||
}); | ||
@@ -107,2 +104,2 @@ | ||
}); | ||
}); | ||
}); |
@@ -7,4 +7,4 @@ 'use strict'; | ||
var servers = require('./servers'); | ||
var until = webdriver.until; | ||
var elements = [ | ||
@@ -44,8 +44,4 @@ 'swagger-ui-container', | ||
it('should have "Swagger UI" in title', function (done) { | ||
driver.sleep(200); | ||
driver.getTitle().then(function(title) { | ||
expect(title).to.contain('Swagger UI'); | ||
done(); | ||
}); | ||
it('should have "Swagger UI" in title', function () { | ||
return driver.wait(until.titleIs('Swagger UI'), 1000); | ||
}); | ||
@@ -122,2 +118,2 @@ | ||
}); | ||
}); | ||
}); |
@@ -55,3 +55,3 @@ { | ||
"description": "This is a sample server Petstore server. You can find out more about Swagger \n at <a href=\"http://swagger.io\">http://swagger.io</a> or on irc.freenode.net, #swagger. For this sample,\n you can use the api key \"special-key\" to test the authorization filters", | ||
"termsOfServiceUrl": "http://helloreverb.com/terms/", | ||
"termsOfServiceUrl": "http://swagger.io/terms/", | ||
"contact": "apiteam@swagger.io", | ||
@@ -58,0 +58,0 @@ "license": "Apache 2.0", |
@@ -7,3 +7,3 @@ { | ||
"title": "Swagger Petstore", | ||
"termsOfService": "http://helloreverb.com/terms/", | ||
"termsOfService": "http://swagger.io/terms/", | ||
"contact": { | ||
@@ -10,0 +10,0 @@ "url": "http://swagger.io", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
High entropy strings
Supply chain riskContains high entropy strings. This could be a sign of encrypted data, leaked secrets or obfuscated code.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
4424173
145
47512
3
243
1
6