Skip to content

Commit d5b65aa

Browse files
committed
Merge branch 'master' of github.com:wordnik/swagger-ui
Conflicts: dist/lib/swagger.js dist/swagger-ui.js dist/swagger-ui.min.js src/main/template/param.handlebars
2 parents c122c4d + 9b0aa32 commit d5b65aa

20 files changed

+739
-551
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,10 @@ To use swagger-ui you should take a look at the [source of swagger-ui html page]
5959
* *dom_id parameter* is the the id of a dom element inside which SwaggerUi will put the user interface for swagger
6060
* *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)
6161
* *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)
62+
* *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.
6263
* *onComplete* is a callback function parameter which can be passed to be notified of when SwaggerUI has completed rendering successfully.
6364
* *onFailure* is a callback function parameter which can be passed to be notified of when SwaggerUI encountered a failure was unable to render.
65+
* *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
6466
* All other parameters are explained in greater detail below
6567

6668

dist/css/screen.css

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -743,17 +743,20 @@
743743
display: inline-block;
744744
font-size: 0.9em;
745745
}
746-
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content div.sandbox_header img {
747-
display: block;
748-
clear: none;
749-
float: right;
750-
}
751746
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content div.sandbox_header input.submit {
752747
display: block;
753748
clear: none;
754749
float: left;
755750
padding: 6px 8px;
756751
}
752+
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content div.sandbox_header span.response_throbber {
753+
background-image: url('../images/throbber.gif');
754+
width: 128px;
755+
height: 16px;
756+
display: block;
757+
clear: none;
758+
float: right;
759+
}
757760
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content form input[type='text'].error {
758761
outline: 2px solid black;
759762
outline-color: #cc0000;

dist/index.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@
4747
onFailure: function(data) {
4848
log("Unable to Load SwaggerUI");
4949
},
50-
docExpansion: "none"
50+
docExpansion: "none",
51+
sorter : "alpha"
5152
});
5253

5354
$('#input_apiKey').change(function() {

dist/lib/swagger-oauth.js

Lines changed: 54 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -48,72 +48,65 @@ function handleLogin() {
4848
str += '</label></li>';
4949
popup.append(str);
5050
}
51-
52-
53-
var $win = $(window),
54-
dw = $win.width(),
55-
dh = $win.height(),
56-
st = $win.scrollTop(),
57-
dlgWd = popupDialog.outerWidth(),
58-
dlgHt = popupDialog.outerHeight(),
59-
top = (dh -dlgHt)/2 + st,
60-
left = (dw - dlgWd)/2;
61-
62-
popupDialog.css({
63-
top: (top < 0? 0 : top) + 'px',
64-
left: (left < 0? 0 : left) + 'px'
65-
});
66-
67-
popupDialog.find('button.api-popup-cancel').click(function() {
68-
popupMask.hide();
69-
popupDialog.hide();
70-
});
71-
popupDialog.find('button.api-popup-authbtn').click(function() {
72-
popupMask.hide();
73-
popupDialog.hide();
74-
75-
var authSchemes = window.swaggerUi.api.authSchemes;
76-
var location = window.location;
77-
var locationUrl = location.protocol + '//' + location.host + location.pathname;
78-
var redirectUrl = locationUrl.replace("index.html","").concat("/o2c.html").replace("//o2c.html","/o2c.html");
79-
var url = null;
80-
81-
var p = window.swaggerUi.api.authSchemes;
82-
for (var key in p) {
83-
if (p.hasOwnProperty(key)) {
84-
var o = p[key].grantTypes;
85-
for(var t in o) {
86-
if(o.hasOwnProperty(t) && t === 'implicit') {
87-
var dets = o[t];
88-
url = dets.loginEndpoint.url + "?response_type=token";
89-
window.swaggerUi.tokenName = dets.tokenName;
90-
}
51+
}
52+
53+
var $win = $(window),
54+
dw = $win.width(),
55+
dh = $win.height(),
56+
st = $win.scrollTop(),
57+
dlgWd = popupDialog.outerWidth(),
58+
dlgHt = popupDialog.outerHeight(),
59+
top = (dh -dlgHt)/2 + st,
60+
left = (dw - dlgWd)/2;
61+
62+
popupDialog.css({
63+
top: (top < 0? 0 : top) + 'px',
64+
left: (left < 0? 0 : left) + 'px'
65+
});
66+
67+
popupDialog.find('button.api-popup-cancel').click(function() {
68+
popupMask.hide();
69+
popupDialog.hide();
70+
});
71+
popupDialog.find('button.api-popup-authbtn').click(function() {
72+
popupMask.hide();
73+
popupDialog.hide();
74+
75+
var authSchemes = window.swaggerUi.api.authSchemes;
76+
var host = window.location;
77+
var pathname = location.pathname.substring(0, location.pathname.lastIndexOf("/"));
78+
var redirectUrl = host.protocol + '//' + host.host + pathname + "/o2c.html";
79+
var url = null;
80+
81+
for (var key in authSchemes) {
82+
if (authSchemes.hasOwnProperty(key)) {
83+
var o = authSchemes[key].grantTypes;
84+
for(var t in o) {
85+
if(o.hasOwnProperty(t) && t === 'implicit') {
86+
var dets = o[t];
87+
url = dets.loginEndpoint.url + "?response_type=token";
88+
window.swaggerUi.tokenName = dets.tokenName;
9189
}
9290
}
9391
}
94-
var scopes = [];
95-
var scopeForUrl='';
96-
var o = $('.api-popup-scopes').find('input:checked');
97-
98-
for(var k =0; k < o.length; k++) {
99-
scopes.push($(o[k]).attr("scope"));
100-
if(k > 0){
101-
scopeForUrl+=' ';
102-
}
103-
scopeForUrl+=$(o[k]).attr("scope");
104-
}
92+
}
93+
var scopes = []
94+
var o = $('.api-popup-scopes').find('input:checked');
10595

106-
window.enabledScopes=scopes;
107-
96+
for(k =0; k < o.length; k++) {
97+
scopes.push($(o[k]).attr("scope"));
98+
}
10899

109-
url += '&redirect_uri=' + encodeURIComponent(redirectUrl);
110-
url += '&realm=' + encodeURIComponent(realm);
111-
url += '&client_id=' + encodeURIComponent(clientId);
112-
url += '&scope=' + encodeURIComponent(scopeForUrl);
100+
window.enabledScopes=scopes;
101+
102+
url += '&redirect_uri=' + encodeURIComponent(redirectUrl);
103+
url += '&realm=' + encodeURIComponent(realm);
104+
url += '&client_id=' + encodeURIComponent(clientId);
105+
url += '&scope=' + encodeURIComponent(scopes);
106+
107+
window.open(url);
108+
});
113109

114-
window.open(url);
115-
});
116-
}
117110
popupMask.show();
118111
popupDialog.show();
119112
return;
@@ -211,7 +204,7 @@ function onOAuthComplete(token) {
211204
}
212205
});
213206

214-
window.authorizations.add("key", new ApiKeyAuthorization("Authorization", "Bearer " + b, "header"));
207+
window.authorizations.add("oauth2", new ApiKeyAuthorization("Authorization", "Bearer " + b, "header"));
215208
}
216209
}
217210
}

0 commit comments

Comments
 (0)