Compare commits

...
12 Commits
Author SHA1 Message Date
Tony Tam f7424a7009 updated README 2016-09-20 09:51:34 -07:00
Tony Tam f50851913e Merge pull request #2414 from swagger-api/release-prepare
rebuilt for release
2016-09-20 09:50:38 -07:00
Tony Tam e3d5ad2595 rebuilt for release 2016-09-20 08:46:19 -07:00
Tony Tam 656808b20c Merge pull request #2404 from swagger-api/issue-2132
Add support for binary downloads, inline image rendering
2016-09-16 10:02:07 -07:00
Tony Tam 9fee08daa3 updated versions 2016-09-16 09:18:20 -07:00
Tony Tam cf96414f78 removed unused var 2016-09-15 10:39:34 -07:00
Tony Tam 80e548df0a no more blob conversions 2016-09-15 10:35:01 -07:00
Tony Tam 4bdaeba797 treat blobs as binary, render images w/o image url 2016-09-15 01:07:08 -07:00
Tony Tam 15f76ad355 updated js lib 2016-09-15 01:06:55 -07:00
Tony Tam f321c62edc rebuilt 2016-09-07 22:23:08 -07:00
Tony Tam 1a98574c03 Merge pull request #2383 from jt1796/param-fix
fix params showing as undefined
2016-09-04 20:32:18 -07:00
John Tompkins 1ce3dada00 fix params showing as undefined 2016-09-04 15:28:23 -04:00
7 changed files with 656 additions and 412 deletions
+1 -1
View File
@@ -24,7 +24,7 @@ The OpenAPI Specification has undergone 4 revisions since initial creation in 20
Swagger UI Version | Release Date | OpenAPI Spec compatibility | Notes | Status
------------------ | ------------ | -------------------------- | ----- | ------
2.2.2 | 2016-08-23 | 1.1, 1.2, 2.0 | [tag v.2.2.2](https://github.com/swagger-api/swagger-ui/tree/v2.2.2) |
2.2.4 | 2016-09-20 | 1.1, 1.2, 2.0 | [tag v.2.2.4](https://github.com/swagger-api/swagger-ui/tree/v2.2.4) |
2.1.5 | 2016-07-20 | 1.1, 1.2, 2.0 | [tag v.2.1.5](https://github.com/swagger-api/swagger-ui/tree/v2.1.5) |
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) |
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) |
+596 -356
View File
File diff suppressed because one or more lines are too long
+13 -13
View File
File diff suppressed because one or more lines are too long
+2 -2
View File
@@ -8,7 +8,7 @@
}
],
"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.2.3",
"version": "2.2.4",
"homepage": "http://swagger.io",
"license": "Apache-2.0",
"main": "dist/swagger-ui.js",
@@ -60,6 +60,6 @@
"phantomjs": "1.9.19",
"selenium-webdriver": "^2.45.0",
"sinon-chai": "2.8.0",
"swagger-client": "2.1.18"
"swagger-client": "2.1.20"
}
}
+6 -2
View File
@@ -43,7 +43,11 @@ Handlebars.registerHelper('renderTextParam', function(param) {
idAtt = ' id=\'' + valueId + '\'';
}
defaultValue = sanitizeHtml(defaultValue);
if (defaultValue) {
defaultValue = sanitizeHtml(defaultValue);
} else {
defaultValue = '';
}
if(isArray) {
result = '<textarea class=\'body-textarea' + (param.required ? ' required' : '') + '\' name=\'' + name + '\'' + idAtt + dataVendorExtensions;
@@ -89,4 +93,4 @@ Handlebars.registerHelper('escape', function (value) {
var text = Handlebars.Utils.escapeExpression(value);
return new Handlebars.SafeString(text);
});
});
+38 -37
View File
@@ -651,6 +651,7 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
// puts the response data in UI
showStatus: function(response) {
console.log(response.headers);
var url, content;
if (response.content === undefined) {
content = response.data;
@@ -660,7 +661,9 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
url = response.request.url;
}
var headers = response.headers;
content = jQuery.trim(content);
if(typeof content === 'string') {
content = jQuery.trim(content);
}
// if server is nice, and sends content-type back, we can use it
var contentType = null;
@@ -685,6 +688,36 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
pre = $('<pre class="json" />').append(code);
// JSON
} else if (headers['Content-Disposition'] && (/attachment/).test(headers['Content-Disposition']) ||
headers['content-disposition'] && (/attachment/).test(headers['content-disposition']) ||
headers['Content-Description'] && (/File Transfer/).test(headers['Content-Description']) ||
headers['content-description'] && (/File Transfer/).test(headers['content-description'])) {
if ('Blob' in window) {
var type = contentType || 'text/html';
var a = document.createElement('a');
var href = window.URL.createObjectURL(content);
var fileName = response.url.substr(response.url.lastIndexOf('/') + 1);
var download = [type, fileName, href].join(':');
// Use filename from response header
var disposition = headers['content-disposition'] || headers['Content-Disposition'];
if(typeof disposition !== 'undefined') {
var responseFilename = /filename=([^;]*);?/.exec(disposition);
if(responseFilename !== null && responseFilename.length > 1) {
download = responseFilename[1];
}
}
a.setAttribute('href', href);
a.setAttribute('download', download);
a.innerText = 'Download ' + fileName;
pre = $('<div/>').append(a);
} else {
pre = $('<pre class="json" />').append('Download headers detected but your browser does not support downloading binary via XHR (Blob).');
}
} else if (contentType === 'application/json' || /\+json$/.test(contentType)) {
var json = null;
try {
@@ -710,49 +743,17 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
code = $('<code />').text(content);
pre = $('<pre class="plain" />').append(code);
// Image
} else if (/^image\//.test(contentType)) {
pre = $('<img>').attr('src', url);
var urlCreator = window.URL || window.webkitURL;
var imageUrl = urlCreator.createObjectURL(content);
pre = $('<img>').attr( 'src', imageUrl);
// Audio
} else if (/^audio\//.test(contentType) && supportsAudioPlayback(contentType)) {
pre = $('<audio controls>').append($('<source>').attr('src', url).attr('type', contentType));
// Download
} else if (headers['Content-Disposition'] && (/attachment/).test(headers['Content-Disposition']) ||
headers['content-disposition'] && (/attachment/).test(headers['content-disposition']) ||
headers['Content-Description'] && (/File Transfer/).test(headers['Content-Description']) ||
headers['content-description'] && (/File Transfer/).test(headers['content-description'])) {
if ('Blob' in window) {
var type = contentType || 'text/html';
var blob = new Blob([content], {type: type});
var a = document.createElement('a');
var href = window.URL.createObjectURL(blob);
var fileName = response.url.substr(response.url.lastIndexOf('/') + 1);
var download = [type, fileName, href].join(':');
// Use filename from response header
var disposition = headers['content-disposition'] || headers['Content-Disposition'];
if(typeof disposition !== 'undefined') {
var responseFilename = /filename=([^;]*);?/.exec(disposition);
if(responseFilename !== null && responseFilename.length > 1) {
download = responseFilename[1];
}
}
a.setAttribute('href', href);
a.setAttribute('download', download);
a.innerText = 'Download ' + fileName;
pre = $('<div/>').append(a);
} else {
pre = $('<pre class="json" />').append('Download headers detected but your browser does not support downloading binary via XHR (Blob).');
}
// Location header based redirect download
} else if(headers.location || headers.Location) {
// Location header based redirect download
window.location = response.url;
// Anything else (CORS)
@@ -24,7 +24,6 @@ SwaggerUi.Views.ParameterView = Backbone.View.extend({
var consumes = this.model.consumes || [];
var sampleJSON, signatureView;
if (typeof type === 'undefined') {
if (schema.$ref) {
var ref = schema.$ref;