Merge branch 'develop_2.0' into JSONEditor
Conflicts: dist/index.html dist/swagger-ui.js dist/swagger-ui.min.js
This commit is contained in:
@@ -2,3 +2,4 @@ node_modules
|
||||
src/main/javascript/doc.js
|
||||
dist
|
||||
lib
|
||||
.log
|
||||
@@ -17,6 +17,7 @@
|
||||
"strict": true,
|
||||
"trailing": true,
|
||||
"smarttabs": true,
|
||||
"validthis": true,
|
||||
"globals": {
|
||||
|
||||
// Libraries
|
||||
@@ -29,6 +30,7 @@
|
||||
"SwaggerClient": false,
|
||||
"hljs": false,
|
||||
"SwaggerUi": false,
|
||||
"define": false,
|
||||
|
||||
// Global object
|
||||
// TODO: remove these
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
sudo: false
|
||||
language: node_js
|
||||
node_js:
|
||||
- '0.10'
|
||||
@@ -7,7 +8,3 @@ install:
|
||||
- sh -e /etc/init.d/xvfb start
|
||||
- npm i -g jshint
|
||||
- npm install
|
||||
|
||||
script:
|
||||
- jshint .
|
||||
- npm test
|
||||
@@ -91,11 +91,13 @@ validatorUrl | By default, Swagger-UI attempts to validate specs against swagger
|
||||
dom_id | The id of a dom element inside which SwaggerUi will put the user interface for swagger.
|
||||
booleanValues | SwaggerUI renders boolean data types as a dropdown. By default it provides a 'true' and 'false' string as the possible choices. You can use this parameter to change the values in dropdown to be something else, for example 0 and 1 by setting booleanValues to new Array(0, 1).
|
||||
docExpansion | Controls how the API listing is displayed. It can be set to 'none' (default), 'list' (shows operations for each resource), or 'full' (fully expanded: shows operations and their details).
|
||||
sorter | Apply a sort to the API list. It can be 'alpha' (sort paths alphanumerically) or 'method' (sort operations by HTTP method). Default is the order returned by the server unchanged.
|
||||
apisSorter | Apply a sort to the API/tags list. It can be 'alpha' (sort by name) or a function (see Array.prototype.sort() to know how sort function works). Default is the order returned by the server unchanged.
|
||||
operationsSorter | Apply a sort to the operation list of each API. It can be 'alpha' (sort by paths alphanumerically), 'method' (sort by HTTP method) or a function (see Array.prototype.sort() to know how sort function works). Default is the order returned by the server unchanged.
|
||||
onComplete | This is a callback function parameter which can be passed to be notified of when SwaggerUI has completed rendering successfully.
|
||||
onFailure | This is a callback function parameter which can be passed to be notified of when SwaggerUI encountered a failure was unable to render.
|
||||
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.
|
||||
oauth2RedirectUrl | OAuth redirect URL
|
||||
|
||||
* All other parameters are explained in greater detail below
|
||||
|
||||
|
||||
4
dist/index.html
vendored
4
dist/index.html
vendored
@@ -10,7 +10,6 @@
|
||||
<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/print.css' media='print' rel='stylesheet' type='text/css'/>
|
||||
<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.slideto.min.js' type='text/javascript'></script>
|
||||
<script src='lib/jquery.wiggle.min.js' type='text/javascript'></script>
|
||||
@@ -18,14 +17,11 @@
|
||||
<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/backbone-min.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='lib/highlight.7.3.pack.js' type='text/javascript'></script>
|
||||
<script src='lib/jsoneditor.min.js' type='text/javascript'></script>
|
||||
<script src='lib/marked.js' type='text/javascript'></script>
|
||||
|
||||
<!-- enabling this will enable oauth2 implicit scope support -->
|
||||
<script src='lib/swagger-oauth.js' type='text/javascript'></script>
|
||||
<script type="text/javascript">
|
||||
$(function () {
|
||||
var url = window.location.search.match(/url=([^&]+)/);
|
||||
|
||||
2765
dist/lib/shred.bundle.js
vendored
2765
dist/lib/shred.bundle.js
vendored
File diff suppressed because it is too large
Load Diff
16128
dist/lib/swagger-client.js
vendored
16128
dist/lib/swagger-client.js
vendored
File diff suppressed because one or more lines are too long
3
dist/lib/swagger-oauth.js
vendored
3
dist/lib/swagger-oauth.js
vendored
@@ -97,7 +97,8 @@ function handleLogin() {
|
||||
var authSchemes = window.swaggerUi.api.authSchemes;
|
||||
var host = window.location;
|
||||
var pathname = location.pathname.substring(0, location.pathname.lastIndexOf("/"));
|
||||
var redirectUrl = host.protocol + '//' + host.host + pathname + '/o2c.html';
|
||||
var defaultRedirectUrl = host.protocol + '//' + host.host + pathname + '/o2c.html';
|
||||
var redirectUrl = window.oAuthRedirectUrl || defaultRedirectUrl;
|
||||
var url = null;
|
||||
|
||||
for (var key in authSchemes) {
|
||||
|
||||
75
dist/swagger-ui.js
vendored
75
dist/swagger-ui.js
vendored
@@ -38,6 +38,10 @@ window.SwaggerUi = Backbone.Router.extend({
|
||||
];
|
||||
}
|
||||
|
||||
if (typeof options.oauth2RedirectUrl === 'string') {
|
||||
window.oAuthRedirectUrl = options.redirectUrl;
|
||||
}
|
||||
|
||||
// Create an empty div which contains the dom_id
|
||||
if (! $('#' + this.dom_id).length){
|
||||
$('body').append('<div id="' + this.dom_id + '"></div>') ;
|
||||
@@ -207,7 +211,7 @@ window.SwaggerUi.Views = {};
|
||||
(function(){
|
||||
window.authorizations = {
|
||||
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') {
|
||||
throw new TypeError('window.swaggerUi is not defined');
|
||||
@@ -220,12 +224,12 @@ window.SwaggerUi.Views = {};
|
||||
};
|
||||
|
||||
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);
|
||||
};
|
||||
|
||||
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);
|
||||
};
|
||||
|
||||
@@ -235,6 +239,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"]["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) {
|
||||
@@ -1212,21 +1237,48 @@ SwaggerUi.Views.HeaderView = Backbone.View.extend({
|
||||
'use strict';
|
||||
|
||||
SwaggerUi.Views.MainView = Backbone.View.extend({
|
||||
|
||||
// TODO: sorters were not used in any place, do we need them?
|
||||
// sorters = {
|
||||
// alpha : function(a,b){ return a.path.localeCompare(b.path); },
|
||||
// method : function(a,b){ return a.method.localeCompare(b.method); },
|
||||
// },
|
||||
|
||||
apisSorter : {
|
||||
alpha : function(a,b){ return a.name.localeCompare(b.name); }
|
||||
},
|
||||
operationsSorters : {
|
||||
alpha : function(a,b){ return a.path.localeCompare(b.path); },
|
||||
method : function(a,b){ return a.method.localeCompare(b.method); }
|
||||
},
|
||||
initialize: function(opts){
|
||||
var sorterOption, sorterFn, key, value;
|
||||
opts = opts || {};
|
||||
|
||||
this.router = opts.router;
|
||||
|
||||
// Sort APIs
|
||||
if (opts.swaggerOptions.apisSorter) {
|
||||
sorterOption = opts.swaggerOptions.apisSorter;
|
||||
if (_.isFunction(sorterOption)) {
|
||||
sorterFn = sorterOption;
|
||||
} else {
|
||||
sorterFn = this.apisSorter[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
|
||||
this.model.auths = [];
|
||||
var key, value;
|
||||
|
||||
for (key in this.model.securityDefinitions) {
|
||||
value = this.model.securityDefinitions[key];
|
||||
@@ -1334,6 +1386,7 @@ SwaggerUi.Views.MainView = Backbone.View.extend({
|
||||
$(this.el).html('');
|
||||
}
|
||||
});
|
||||
|
||||
'use strict';
|
||||
|
||||
SwaggerUi.Views.OperationView = Backbone.View.extend({
|
||||
|
||||
4
dist/swagger-ui.min.js
vendored
4
dist/swagger-ui.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -54,7 +54,10 @@ function templates() {
|
||||
gulp.task('dist', ['clean'], function() {
|
||||
|
||||
return es.merge(
|
||||
gulp.src('./src/main/javascript/**/*.js'),
|
||||
gulp.src([
|
||||
'./src/main/javascript/**/*.js',
|
||||
'./node_modules/swagger-client/browser/swagger-client.js'
|
||||
]),
|
||||
templates()
|
||||
)
|
||||
.pipe(order(['scripts.js', 'templates.js']))
|
||||
|
||||
2765
lib/shred.bundle.js
2765
lib/shred.bundle.js
File diff suppressed because it is too large
Load Diff
16128
lib/swagger-client.js
16128
lib/swagger-client.js
File diff suppressed because one or more lines are too long
@@ -97,7 +97,8 @@ function handleLogin() {
|
||||
var authSchemes = window.swaggerUi.api.authSchemes;
|
||||
var host = window.location;
|
||||
var pathname = location.pathname.substring(0, location.pathname.lastIndexOf("/"));
|
||||
var redirectUrl = host.protocol + '//' + host.host + pathname + '/o2c.html';
|
||||
var defaultRedirectUrl = host.protocol + '//' + host.host + pathname + '/o2c.html';
|
||||
var redirectUrl = window.oAuthRedirectUrl || defaultRedirectUrl;
|
||||
var url = null;
|
||||
|
||||
for (var key in authSchemes) {
|
||||
|
||||
11
package.json
11
package.json
@@ -6,9 +6,11 @@
|
||||
"homepage": "http://swagger.io",
|
||||
"license": "Apache 2.0",
|
||||
"scripts": {
|
||||
"build": "./node_modules/gulp/bin/gulp.js;",
|
||||
"serve": "./node_modules/gulp/bin/gulp.js serve;",
|
||||
"test": "./node_modules/gulp/bin/gulp.js; ./node_modules/mocha/bin/mocha"
|
||||
"build": "gulp.js;",
|
||||
"serve": "gulp.js serve;",
|
||||
"pretest": "jshint .",
|
||||
"test": "gulp; mocha",
|
||||
"postinstall": "cd node_modules/swagger-client/; npm install; gulp"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -43,6 +45,7 @@
|
||||
"http-server": "git+https://github.com/nodeapps/http-server.git",
|
||||
"less": "^2.4.0",
|
||||
"mocha": "^2.1.0",
|
||||
"selenium-webdriver": "^2.45.0"
|
||||
"selenium-webdriver": "^2.45.0",
|
||||
"swagger-client": "git://github.com/swagger-api/swagger-js#develop_2.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
<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/print.css' media='print' rel='stylesheet' type='text/css'/>
|
||||
<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.slideto.min.js' type='text/javascript'></script>
|
||||
<script src='lib/jquery.wiggle.min.js' type='text/javascript'></script>
|
||||
@@ -18,14 +17,11 @@
|
||||
<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/backbone-min.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='lib/highlight.7.3.pack.js' type='text/javascript'></script>
|
||||
<script src='lib/jsoneditor.min.js' type='text/javascript'></script>
|
||||
<script src='lib/marked.js' type='text/javascript'></script>
|
||||
|
||||
<!-- enabling this will enable oauth2 implicit scope support -->
|
||||
<script src='lib/swagger-oauth.js' type='text/javascript'></script>
|
||||
<script type="text/javascript">
|
||||
$(function () {
|
||||
var url = window.location.search.match(/url=([^&]+)/);
|
||||
|
||||
@@ -32,6 +32,10 @@ window.SwaggerUi = Backbone.Router.extend({
|
||||
];
|
||||
}
|
||||
|
||||
if (typeof options.oauth2RedirectUrl === 'string') {
|
||||
window.oAuthRedirectUrl = options.redirectUrl;
|
||||
}
|
||||
|
||||
// Create an empty div which contains the dom_id
|
||||
if (! $('#' + this.dom_id).length){
|
||||
$('body').append('<div id="' + this.dom_id + '"></div>') ;
|
||||
@@ -201,7 +205,7 @@ window.SwaggerUi.Views = {};
|
||||
(function(){
|
||||
window.authorizations = {
|
||||
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') {
|
||||
throw new TypeError('window.swaggerUi is not defined');
|
||||
@@ -214,12 +218,12 @@ window.SwaggerUi.Views = {};
|
||||
};
|
||||
|
||||
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);
|
||||
};
|
||||
|
||||
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);
|
||||
};
|
||||
|
||||
@@ -229,3 +233,24 @@ 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;
|
||||
}));
|
||||
@@ -1,21 +1,48 @@
|
||||
'use strict';
|
||||
|
||||
SwaggerUi.Views.MainView = Backbone.View.extend({
|
||||
|
||||
// TODO: sorters were not used in any place, do we need them?
|
||||
// sorters = {
|
||||
// alpha : function(a,b){ return a.path.localeCompare(b.path); },
|
||||
// method : function(a,b){ return a.method.localeCompare(b.method); },
|
||||
// },
|
||||
|
||||
apisSorter : {
|
||||
alpha : function(a,b){ return a.name.localeCompare(b.name); }
|
||||
},
|
||||
operationsSorters : {
|
||||
alpha : function(a,b){ return a.path.localeCompare(b.path); },
|
||||
method : function(a,b){ return a.method.localeCompare(b.method); }
|
||||
},
|
||||
initialize: function(opts){
|
||||
var sorterOption, sorterFn, key, value;
|
||||
opts = opts || {};
|
||||
|
||||
this.router = opts.router;
|
||||
|
||||
// Sort APIs
|
||||
if (opts.swaggerOptions.apisSorter) {
|
||||
sorterOption = opts.swaggerOptions.apisSorter;
|
||||
if (_.isFunction(sorterOption)) {
|
||||
sorterFn = sorterOption;
|
||||
} else {
|
||||
sorterFn = this.apisSorter[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
|
||||
this.model.auths = [];
|
||||
var key, value;
|
||||
|
||||
for (key in this.model.securityDefinitions) {
|
||||
value = this.model.securityDefinitions[key];
|
||||
|
||||
@@ -20,7 +20,7 @@ describe('swagger 1.x spec tests', function () {
|
||||
|
||||
before(function (done) {
|
||||
this.timeout(25 * 1000);
|
||||
servers.start('/v1.2/petstore/api-docs', done);
|
||||
servers.start('/v1.2/petstore/api-docs.json', done);
|
||||
});
|
||||
|
||||
afterEach(function(){
|
||||
@@ -57,7 +57,8 @@ describe('swagger 1.x spec tests', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('should find the contact name element', function(done){
|
||||
// TODO: enable me
|
||||
xit('should find the contact name element', function(done){
|
||||
var locator = webdriver.By.css('.info_name');
|
||||
driver.isElementPresent(locator).then(function (isPresent) {
|
||||
expect(isPresent).to.be.true;
|
||||
@@ -73,7 +74,8 @@ describe('swagger 1.x spec tests', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('should find the pet resource description', function(done){
|
||||
// TODO: enable me
|
||||
xit('should find the pet resource description', function(done){
|
||||
var locator = webdriver.By.xpath('//div[contains(., "Operations about pets")]');
|
||||
driver.findElements(locator).then(function (elements) {
|
||||
expect(elements.length).to.not.equal(0);
|
||||
|
||||
@@ -3,15 +3,15 @@
|
||||
"swaggerVersion": "1.2",
|
||||
"apis": [
|
||||
{
|
||||
"path": "http://localhost:8081/v1.2/petstore/pet",
|
||||
"path": "http://localhost:8081/v1.2/petstore/pet.json",
|
||||
"description": "Operations about pets"
|
||||
},
|
||||
{
|
||||
"path": "http://localhost:8081/v1.2/petstore/user",
|
||||
"path": "http://localhost:8081/v1.2/petstore/user.json",
|
||||
"description": "Operations about user"
|
||||
},
|
||||
{
|
||||
"path": "http://localhost:8081/v1.2/petstore/store",
|
||||
"path": "http://localhost:8081/v1.2/petstore/store.json",
|
||||
"description": "Operations about store"
|
||||
}
|
||||
],
|
||||
Reference in New Issue
Block a user