Make SwaggerUi UMD compatible
BIN
dist/fonts/droid-sans-v6-latin-700.eot
vendored
BIN
dist/fonts/droid-sans-v6-latin-700.ttf
vendored
BIN
dist/fonts/droid-sans-v6-latin-regular.ttf
vendored
BIN
dist/images/explorer_icons.png
vendored
|
Before Width: | Height: | Size: 5.6 KiB After Width: | Height: | Size: 5.6 KiB |
BIN
dist/images/favicon-16x16.png
vendored
|
Before Width: | Height: | Size: 645 B After Width: | Height: | Size: 644 B |
BIN
dist/images/favicon-32x32.png
vendored
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
BIN
dist/images/logo_small.png
vendored
|
Before Width: | Height: | Size: 770 B After Width: | Height: | Size: 769 B |
BIN
dist/images/pet_store_api.png
vendored
|
Before Width: | Height: | Size: 824 B After Width: | Height: | Size: 823 B |
BIN
dist/images/wordnik_api.png
vendored
|
Before Width: | Height: | Size: 980 B After Width: | Height: | Size: 979 B |
210
dist/index.html
vendored
@@ -1,105 +1,105 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Swagger UI</title>
|
<title>Swagger UI</title>
|
||||||
<link rel="icon" type="image/png" href="images/favicon-32x32.png" sizes="32x32" />
|
<link rel="icon" type="image/png" href="images/favicon-32x32.png" sizes="32x32" />
|
||||||
<link rel="icon" type="image/png" href="images/favicon-16x16.png" sizes="16x16" />
|
<link rel="icon" type="image/png" href="images/favicon-16x16.png" sizes="16x16" />
|
||||||
<link href='css/typography.css' media='screen' rel='stylesheet' type='text/css'/>
|
<link href='css/typography.css' media='screen' rel='stylesheet' type='text/css'/>
|
||||||
<link href='css/reset.css' media='screen' rel='stylesheet' type='text/css'/>
|
<link href='css/reset.css' media='screen' rel='stylesheet' type='text/css'/>
|
||||||
<link href='css/screen.css' media='screen' rel='stylesheet' type='text/css'/>
|
<link href='css/screen.css' media='screen' rel='stylesheet' type='text/css'/>
|
||||||
<link href='css/reset.css' media='print' rel='stylesheet' type='text/css'/>
|
<link href='css/reset.css' media='print' rel='stylesheet' type='text/css'/>
|
||||||
<link href='css/print.css' media='print' rel='stylesheet' type='text/css'/>
|
<link href='css/print.css' media='print' rel='stylesheet' type='text/css'/>
|
||||||
<script type="text/javascript" src="lib/shred.bundle.js"></script>
|
<script type="text/javascript" src="lib/shred.bundle.js"></script>
|
||||||
<script src='lib/jquery-1.8.0.min.js' type='text/javascript'></script>
|
<script src='lib/jquery-1.8.0.min.js' type='text/javascript'></script>
|
||||||
<script src='lib/jquery.slideto.min.js' type='text/javascript'></script>
|
<script src='lib/jquery.slideto.min.js' type='text/javascript'></script>
|
||||||
<script src='lib/jquery.wiggle.min.js' type='text/javascript'></script>
|
<script src='lib/jquery.wiggle.min.js' type='text/javascript'></script>
|
||||||
<script src='lib/jquery.ba-bbq.min.js' type='text/javascript'></script>
|
<script src='lib/jquery.ba-bbq.min.js' type='text/javascript'></script>
|
||||||
<script src='lib/handlebars-2.0.0.js' type='text/javascript'></script>
|
<script src='lib/handlebars-2.0.0.js' type='text/javascript'></script>
|
||||||
<script src='lib/underscore-min.js' type='text/javascript'></script>
|
<script src='lib/underscore-min.js' type='text/javascript'></script>
|
||||||
<script src='lib/backbone-min.js' type='text/javascript'></script>
|
<script src='lib/backbone-min.js' type='text/javascript'></script>
|
||||||
<script src='lib/swagger-client.js' type='text/javascript'></script>
|
<script src='lib/swagger-client.js' type='text/javascript'></script>
|
||||||
<script src='swagger-ui.js' type='text/javascript'></script>
|
<script src='swagger-ui.js' type='text/javascript'></script>
|
||||||
<script src='lib/highlight.7.3.pack.js' type='text/javascript'></script>
|
<script src='lib/highlight.7.3.pack.js' type='text/javascript'></script>
|
||||||
<script src='lib/marked.js' type='text/javascript'></script>
|
<script src='lib/marked.js' type='text/javascript'></script>
|
||||||
|
|
||||||
<!-- enabling this will enable oauth2 implicit scope support -->
|
<!-- enabling this will enable oauth2 implicit scope support -->
|
||||||
<script src='lib/swagger-oauth.js' type='text/javascript'></script>
|
<script src='lib/swagger-oauth.js' type='text/javascript'></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(function () {
|
$(function () {
|
||||||
var url = window.location.search.match(/url=([^&]+)/);
|
var url = window.location.search.match(/url=([^&]+)/);
|
||||||
if (url && url.length > 1) {
|
if (url && url.length > 1) {
|
||||||
url = decodeURIComponent(url[1]);
|
url = decodeURIComponent(url[1]);
|
||||||
} else {
|
} else {
|
||||||
url = "http://petstore.swagger.io/v2/swagger.json";
|
url = "http://petstore.swagger.io/v2/swagger.json";
|
||||||
}
|
}
|
||||||
window.swaggerUi = new SwaggerUi({
|
window.swaggerUi = new SwaggerUi({
|
||||||
url: url,
|
url: url,
|
||||||
dom_id: "swagger-ui-container",
|
dom_id: "swagger-ui-container",
|
||||||
supportedSubmitMethods: ['get', 'post', 'put', 'delete', 'patch'],
|
supportedSubmitMethods: ['get', 'post', 'put', 'delete', 'patch'],
|
||||||
onComplete: function(swaggerApi, swaggerUi){
|
onComplete: function(swaggerApi, swaggerUi){
|
||||||
if(typeof initOAuth == "function") {
|
if(typeof initOAuth == "function") {
|
||||||
/*
|
/*
|
||||||
initOAuth({
|
initOAuth({
|
||||||
clientId: "your-client-id",
|
clientId: "your-client-id",
|
||||||
realm: "your-realms",
|
realm: "your-realms",
|
||||||
appName: "your-app-name"
|
appName: "your-app-name"
|
||||||
});
|
});
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
$('pre code').each(function(i, e) {
|
$('pre code').each(function(i, e) {
|
||||||
hljs.highlightBlock(e)
|
hljs.highlightBlock(e)
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
onFailure: function(data) {
|
onFailure: function(data) {
|
||||||
log("Unable to Load SwaggerUI");
|
log("Unable to Load SwaggerUI");
|
||||||
},
|
},
|
||||||
docExpansion: "none",
|
docExpansion: "none",
|
||||||
sorter : "alpha"
|
sorter : "alpha"
|
||||||
});
|
});
|
||||||
|
|
||||||
function addApiKeyAuthorization() {
|
function addApiKeyAuthorization() {
|
||||||
var key = encodeURIComponent($('#input_apiKey')[0].value);
|
var key = encodeURIComponent($('#input_apiKey')[0].value);
|
||||||
log("key: " + key);
|
log("key: " + key);
|
||||||
if(key && key.trim() != "") {
|
if(key && key.trim() != "") {
|
||||||
var apiKeyAuth = new SwaggerClient.ApiKeyAuthorization("api_key", key, "query");
|
var apiKeyAuth = new SwaggerClient.ApiKeyAuthorization("api_key", key, "query");
|
||||||
window.swaggerUi.api.clientAuthorizations.add("api_key", apiKeyAuth);
|
window.swaggerUi.api.clientAuthorizations.add("api_key", apiKeyAuth);
|
||||||
log("added key " + key);
|
log("added key " + key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#input_apiKey').change(addApiKeyAuthorization);
|
$('#input_apiKey').change(addApiKeyAuthorization);
|
||||||
|
|
||||||
// if you have an apiKey you would like to pre-populate on the page for demonstration purposes...
|
// if you have an apiKey you would like to pre-populate on the page for demonstration purposes...
|
||||||
/*
|
/*
|
||||||
var apiKey = "myApiKeyXXXX123456789";
|
var apiKey = "myApiKeyXXXX123456789";
|
||||||
$('#input_apiKey').val(apiKey);
|
$('#input_apiKey').val(apiKey);
|
||||||
addApiKeyAuthorization();
|
addApiKeyAuthorization();
|
||||||
*/
|
*/
|
||||||
|
|
||||||
window.swaggerUi.load();
|
window.swaggerUi.load();
|
||||||
|
|
||||||
function log() {
|
function log() {
|
||||||
if ('console' in window) {
|
if ('console' in window) {
|
||||||
console.log.apply(console, arguments);
|
console.log.apply(console, arguments);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body class="swagger-section">
|
<body class="swagger-section">
|
||||||
<div id='header'>
|
<div id='header'>
|
||||||
<div class="swagger-ui-wrap">
|
<div class="swagger-ui-wrap">
|
||||||
<a id="logo" href="http://swagger.io">swagger</a>
|
<a id="logo" href="http://swagger.io">swagger</a>
|
||||||
<form id='api_selector'>
|
<form id='api_selector'>
|
||||||
<div class='input'><input placeholder="http://example.com/api" id="input_baseUrl" name="baseUrl" type="text"/></div>
|
<div class='input'><input placeholder="http://example.com/api" id="input_baseUrl" name="baseUrl" type="text"/></div>
|
||||||
<div class='input'><input placeholder="api_key" id="input_apiKey" name="apiKey" type="text"/></div>
|
<div class='input'><input placeholder="api_key" id="input_apiKey" name="apiKey" type="text"/></div>
|
||||||
<div class='input'><a id="explore" href="#">Explore</a></div>
|
<div class='input'><a id="explore" href="#">Explore</a></div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="message-bar" class="swagger-ui-wrap"> </div>
|
<div id="message-bar" class="swagger-ui-wrap"> </div>
|
||||||
<div id="swagger-ui-container" class="swagger-ui-wrap"></div>
|
<div id="swagger-ui-container" class="swagger-ui-wrap"></div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
2
dist/lib/jquery-1.8.0.min.js
vendored
82
dist/swagger-ui.js
vendored
@@ -6,7 +6,7 @@
|
|||||||
*/
|
*/
|
||||||
(function(){'use strict';
|
(function(){'use strict';
|
||||||
|
|
||||||
window.SwaggerUi = Backbone.Router.extend({
|
var SwaggerUi = Backbone.Router.extend({
|
||||||
|
|
||||||
dom_id: 'swagger_ui',
|
dom_id: 'swagger_ui',
|
||||||
|
|
||||||
@@ -201,13 +201,14 @@ window.SwaggerUi = Backbone.Router.extend({
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
window.SwaggerUi = SwaggerUi;
|
||||||
window.SwaggerUi.Views = {};
|
window.SwaggerUi.Views = {};
|
||||||
|
|
||||||
// don't break backward compatibility with previous versions and warn users to upgrade their code
|
// don't break backward compatibility with previous versions and warn users to upgrade their code
|
||||||
(function(){
|
(function(){
|
||||||
window.authorizations = {
|
window.authorizations = {
|
||||||
add: function() {
|
add: function() {
|
||||||
warn('using window.authorizations is depreciated. Please use waggerUi.api.clientAuthorizations.add().');
|
warn('Using window.authorizations is deprecated. Please use SwaggerUi.api.clientAuthorizations.add().');
|
||||||
|
|
||||||
if (typeof window.swaggerUi === 'undefined') {
|
if (typeof window.swaggerUi === 'undefined') {
|
||||||
throw new TypeError('window.swaggerUi is not defined');
|
throw new TypeError('window.swaggerUi is not defined');
|
||||||
@@ -220,12 +221,12 @@ window.SwaggerUi.Views = {};
|
|||||||
};
|
};
|
||||||
|
|
||||||
window.ApiKeyAuthorization = function() {
|
window.ApiKeyAuthorization = function() {
|
||||||
warn('window.ApiKeyAuthorization is depreciated. Please use SwaggerClient.ApiKeyAuthorization.');
|
warn('window.ApiKeyAuthorization is deprecated. Please use SwaggerClient.ApiKeyAuthorization.');
|
||||||
SwaggerClient.ApiKeyAuthorization.apply(window, arguments);
|
SwaggerClient.ApiKeyAuthorization.apply(window, arguments);
|
||||||
};
|
};
|
||||||
|
|
||||||
window.PasswordAuthorization = function() {
|
window.PasswordAuthorization = function() {
|
||||||
warn('window.PasswordAuthorization is depreciated. Please use SwaggerClient.PasswordAuthorization.');
|
warn('window.PasswordAuthorization is deprecated. Please use SwaggerClient.PasswordAuthorization.');
|
||||||
SwaggerClient.PasswordAuthorization.apply(window, arguments);
|
SwaggerClient.PasswordAuthorization.apply(window, arguments);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -235,6 +236,27 @@ window.SwaggerUi.Views = {};
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
|
||||||
|
// UMD
|
||||||
|
(function (root, factory) {
|
||||||
|
if (typeof define === 'function' && define.amd) {
|
||||||
|
// AMD. Register as an anonymous module.
|
||||||
|
define(['b'], function (b) {
|
||||||
|
return (root.SwaggerUi = factory(b));
|
||||||
|
});
|
||||||
|
} else if (typeof exports === 'object') {
|
||||||
|
// Node. Does not work with strict CommonJS, but
|
||||||
|
// only CommonJS-like enviroments that support module.exports,
|
||||||
|
// like Node.
|
||||||
|
module.exports = factory(require('b'));
|
||||||
|
} else {
|
||||||
|
// Browser globals
|
||||||
|
root.SwaggerUi = factory(root.b);
|
||||||
|
}
|
||||||
|
}(this, function () {
|
||||||
|
return SwaggerUi;
|
||||||
|
}));
|
||||||
this["Handlebars"] = this["Handlebars"] || {};
|
this["Handlebars"] = this["Handlebars"] || {};
|
||||||
this["Handlebars"]["templates"] = this["Handlebars"]["templates"] || {};
|
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) {
|
this["Handlebars"]["templates"]["apikey_button_view"] = Handlebars.template({"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
|
||||||
@@ -572,10 +594,10 @@ this["Handlebars"]["templates"]["operation"] = Handlebars.template({"1":function
|
|||||||
},"3":function(depth0,helpers,partials,data) {
|
},"3":function(depth0,helpers,partials,data) {
|
||||||
return " <h4>Warning: Deprecated</h4>\n";
|
return " <h4>Warning: Deprecated</h4>\n";
|
||||||
},"5":function(depth0,helpers,partials,data) {
|
},"5":function(depth0,helpers,partials,data) {
|
||||||
var stack1, helper, functionType="function", helperMissing=helpers.helperMissing, buffer = " <h4>Implementation Notes</h4>\n <p class=\"markdown\">";
|
var stack1, helper, functionType="function", helperMissing=helpers.helperMissing, buffer = " <h4>Implementation Notes</h4>\n <div class=\"markdown\">";
|
||||||
stack1 = ((helper = (helper = helpers.description || (depth0 != null ? depth0.description : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"description","hash":{},"data":data}) : helper));
|
stack1 = ((helper = (helper = helpers.description || (depth0 != null ? depth0.description : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"description","hash":{},"data":data}) : helper));
|
||||||
if (stack1 != null) { buffer += stack1; }
|
if (stack1 != null) { buffer += stack1; }
|
||||||
return buffer + "</p>\n";
|
return buffer + "</div>\n";
|
||||||
},"7":function(depth0,helpers,partials,data) {
|
},"7":function(depth0,helpers,partials,data) {
|
||||||
return " <div class=\"auth\">\n <span class=\"api-ic ic-error\"></span>";
|
return " <div class=\"auth\">\n <span class=\"api-ic ic-error\"></span>";
|
||||||
},"9":function(depth0,helpers,partials,data) {
|
},"9":function(depth0,helpers,partials,data) {
|
||||||
@@ -1212,21 +1234,48 @@ SwaggerUi.Views.HeaderView = Backbone.View.extend({
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
SwaggerUi.Views.MainView = Backbone.View.extend({
|
SwaggerUi.Views.MainView = Backbone.View.extend({
|
||||||
|
apisSorters : {
|
||||||
// TODO: sorters were not used in any place, do we need them?
|
alpha : function(a,b){ return a.name.localeCompare(b.name); }
|
||||||
// sorters = {
|
},
|
||||||
// alpha : function(a,b){ return a.path.localeCompare(b.path); },
|
operationsSorters : {
|
||||||
// method : function(a,b){ return a.method.localeCompare(b.method); },
|
alpha : function(a,b){ return a.path.localeCompare(b.path); },
|
||||||
// },
|
method : function(a,b){ return a.method.localeCompare(b.method); }
|
||||||
|
},
|
||||||
initialize: function(opts){
|
initialize: function(opts){
|
||||||
|
var sorterOption, sorterFn, key, value;
|
||||||
opts = opts || {};
|
opts = opts || {};
|
||||||
|
|
||||||
this.router = opts.router;
|
this.router = opts.router;
|
||||||
|
|
||||||
|
// Sort APIs
|
||||||
|
if (opts.swaggerOptions.apisSorter) {
|
||||||
|
sorterOption = opts.swaggerOptions.apisSorter;
|
||||||
|
if (_.isFunction(sorterOption)) {
|
||||||
|
sorterFn = sorterOption;
|
||||||
|
} else {
|
||||||
|
sorterFn = this.apisSorters[sorterOption];
|
||||||
|
}
|
||||||
|
if (_.isFunction(sorterFn)) {
|
||||||
|
this.model.apisArray.sort(sorterFn);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Sort operations of each API
|
||||||
|
if (opts.swaggerOptions.operationsSorter) {
|
||||||
|
sorterOption = opts.swaggerOptions.operationsSorter;
|
||||||
|
if (_.isFunction(sorterOption)) {
|
||||||
|
sorterFn = sorterOption;
|
||||||
|
} else {
|
||||||
|
sorterFn = this.operationsSorters[sorterOption];
|
||||||
|
}
|
||||||
|
if (_.isFunction(sorterFn)) {
|
||||||
|
for (key in this.model.apisArray) {
|
||||||
|
this.model.apisArray[key].operationsArray.sort(sorterFn);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// set up the UI for input
|
// set up the UI for input
|
||||||
this.model.auths = [];
|
this.model.auths = [];
|
||||||
var key, value;
|
|
||||||
|
|
||||||
for (key in this.model.securityDefinitions) {
|
for (key in this.model.securityDefinitions) {
|
||||||
value = this.model.securityDefinitions[key];
|
value = this.model.securityDefinitions[key];
|
||||||
@@ -1321,6 +1370,7 @@ SwaggerUi.Views.MainView = Backbone.View.extend({
|
|||||||
$(this.el).html('');
|
$(this.el).html('');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
SwaggerUi.Views.OperationView = Backbone.View.extend({
|
SwaggerUi.Views.OperationView = Backbone.View.extend({
|
||||||
@@ -1392,9 +1442,6 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
|
|||||||
this.model.isReadOnly = true;
|
this.model.isReadOnly = true;
|
||||||
}
|
}
|
||||||
this.model.description = this.model.description || this.model.notes;
|
this.model.description = this.model.description || this.model.notes;
|
||||||
if (this.model.description) {
|
|
||||||
this.model.description = this.model.description.replace(/(?:\r\n|\r|\n)/g, '<br />');
|
|
||||||
}
|
|
||||||
this.model.oauth = null;
|
this.model.oauth = null;
|
||||||
modelAuths = this.model.authorizations || this.model.security;
|
modelAuths = this.model.authorizations || this.model.security;
|
||||||
if (modelAuths) {
|
if (modelAuths) {
|
||||||
@@ -1950,6 +1997,7 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
SwaggerUi.Views.ParameterContentTypeView = Backbone.View.extend({
|
SwaggerUi.Views.ParameterContentTypeView = Backbone.View.extend({
|
||||||
|
|||||||
4
dist/swagger-ui.min.js
vendored
@@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
window.SwaggerUi = Backbone.Router.extend({
|
var SwaggerUi = Backbone.Router.extend({
|
||||||
|
|
||||||
dom_id: 'swagger_ui',
|
dom_id: 'swagger_ui',
|
||||||
|
|
||||||
@@ -195,6 +195,7 @@ window.SwaggerUi = Backbone.Router.extend({
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
window.SwaggerUi = SwaggerUi;
|
||||||
window.SwaggerUi.Views = {};
|
window.SwaggerUi.Views = {};
|
||||||
|
|
||||||
// don't break backward compatibility with previous versions and warn users to upgrade their code
|
// don't break backward compatibility with previous versions and warn users to upgrade their code
|
||||||
@@ -228,4 +229,25 @@ window.SwaggerUi.Views = {};
|
|||||||
console.warn(message);
|
console.warn(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
|
||||||
|
// UMD
|
||||||
|
(function (root, factory) {
|
||||||
|
if (typeof define === 'function' && define.amd) {
|
||||||
|
// AMD. Register as an anonymous module.
|
||||||
|
define(['b'], function (b) {
|
||||||
|
return (root.SwaggerUi = factory(b));
|
||||||
|
});
|
||||||
|
} else if (typeof exports === 'object') {
|
||||||
|
// Node. Does not work with strict CommonJS, but
|
||||||
|
// only CommonJS-like enviroments that support module.exports,
|
||||||
|
// like Node.
|
||||||
|
module.exports = factory(require('b'));
|
||||||
|
} else {
|
||||||
|
// Browser globals
|
||||||
|
root.SwaggerUi = factory(root.b);
|
||||||
|
}
|
||||||
|
}(this, function () {
|
||||||
|
return SwaggerUi;
|
||||||
|
}));
|
||||||