Skip to content

Commit 5fdbd72

Browse files
committed
Merge pull request #13 from mjanser/update-swagger-ui
Update Swagger source to version 2.1.3
2 parents 1be03e0 + f32ae5e commit 5fdbd72

File tree

6 files changed

+2020
-1860
lines changed

6 files changed

+2020
-1860
lines changed

Resources/public/css/print.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -807,6 +807,9 @@
807807
outline: 2px solid black;
808808
outline-color: #cc0000;
809809
}
810+
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content form select[name='parameterContentType'] {
811+
max-width: 300px;
812+
}
810813
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content div.response div.block pre {
811814
font-family: "Anonymous Pro", "Menlo", "Consolas", "Bitstream Vera Sans Mono", "Courier New", monospace;
812815
padding: 10px;

Resources/public/css/screen.css

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -807,6 +807,9 @@
807807
outline: 2px solid black;
808808
outline-color: #cc0000;
809809
}
810+
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content form select[name='parameterContentType'] {
811+
max-width: 300px;
812+
}
810813
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content div.response div.block pre {
811814
font-family: "Anonymous Pro", "Menlo", "Consolas", "Bitstream Vera Sans Mono", "Courier New", monospace;
812815
padding: 10px;
@@ -1155,8 +1158,16 @@
11551158
.swagger-section .auth {
11561159
float: right;
11571160
}
1158-
.swagger-section #api_information_panel {
1159-
position: absolute;
1161+
.swagger-section .api-ic {
1162+
height: 18px;
1163+
vertical-align: middle;
1164+
display: inline-block;
1165+
background: url(../images/explorer_icons.png) no-repeat;
1166+
}
1167+
.swagger-section .api-ic .api_information_panel {
1168+
position: relative;
1169+
margin-top: 20px;
1170+
margin-left: -5px;
11601171
background: #FFF;
11611172
border: 1px solid #ccc;
11621173
border-radius: 5px;
@@ -1167,34 +1178,32 @@
11671178
color: black;
11681179
padding: 5px;
11691180
}
1170-
.swagger-section #api_information_panel p .api-msg-enabled {
1181+
.swagger-section .api-ic .api_information_panel p .api-msg-enabled {
11711182
color: green;
11721183
}
1173-
.swagger-section #api_information_panel p .api-msg-disabled {
1184+
.swagger-section .api-ic .api_information_panel p .api-msg-disabled {
11741185
color: red;
11751186
}
1176-
.swagger-section .api-ic {
1177-
height: 18px;
1178-
vertical-align: middle;
1179-
display: inline-block;
1180-
background: url(../images/explorer_icons.png) no-repeat;
1187+
.swagger-section .api-ic:hover .api_information_panel {
1188+
position: absolute;
1189+
display: block;
11811190
}
11821191
.swagger-section .ic-info {
11831192
background-position: 0 0;
11841193
width: 18px;
1185-
margin-top: -7px;
1194+
margin-top: -6px;
11861195
margin-left: 4px;
11871196
}
11881197
.swagger-section .ic-warning {
11891198
background-position: -60px 0;
11901199
width: 18px;
1191-
margin-top: -7px;
1200+
margin-top: -6px;
11921201
margin-left: 4px;
11931202
}
11941203
.swagger-section .ic-error {
11951204
background-position: -30px 0;
11961205
width: 18px;
1197-
margin-top: -7px;
1206+
margin-top: -6px;
11981207
margin-left: 4px;
11991208
}
12001209
.swagger-section .ic-off {

Resources/public/index.html

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<!DOCTYPE html>
22
<html>
33
<head>
4+
<meta charset="UTF-8">
45
<title>Swagger UI</title>
56
<link rel="icon" type="image/png" href="images/favicon-32x32.png" sizes="32x32" />
67
<link rel="icon" type="image/png" href="images/favicon-16x16.png" sizes="16x16" />
@@ -21,6 +22,11 @@
2122
<script src='lib/marked.js' type='text/javascript'></script>
2223
<script src='lib/swagger-oauth.js' type='text/javascript'></script>
2324

25+
<!-- Some basic translations -->
26+
<!-- <script src='lang/translator.js' type='text/javascript'></script> -->
27+
<!-- <script src='lang/ru.js' type='text/javascript'></script> -->
28+
<!-- <script src='lang/en.js' type='text/javascript'></script> -->
29+
2430
<script type="text/javascript">
2531
$(function () {
2632
var url = window.location.search.match(/url=([^&]+)/);
@@ -29,6 +35,11 @@
2935
} else {
3036
url = "http://petstore.swagger.io/v2/swagger.json";
3137
}
38+
39+
// Pre load translate...
40+
if(window.SwaggerTranslator) {
41+
window.SwaggerTranslator.translate();
42+
}
3243
window.swaggerUi = new SwaggerUi({
3344
url: url,
3445
dom_id: "swagger-ui-container",
@@ -37,11 +48,17 @@
3748
if(typeof initOAuth == "function") {
3849
initOAuth({
3950
clientId: "your-client-id",
51+
clientSecret: "your-client-secret",
4052
realm: "your-realms",
41-
appName: "your-app-name"
53+
appName: "your-app-name",
54+
scopeSeparator: ","
4255
});
4356
}
4457

58+
if(window.SwaggerTranslator) {
59+
window.SwaggerTranslator.translate();
60+
}
61+
4562
$('pre code').each(function(i, e) {
4663
hljs.highlightBlock(e)
4764
});
@@ -91,12 +108,12 @@
91108
<form id='api_selector'>
92109
<div class='input'><input placeholder="http://example.com/api" id="input_baseUrl" name="baseUrl" type="text"/></div>
93110
<div class='input'><input placeholder="api_key" id="input_apiKey" name="apiKey" type="text"/></div>
94-
<div class='input'><a id="explore" href="#">Explore</a></div>
111+
<div class='input'><a id="explore" href="#" data-sw-translate>Explore</a></div>
95112
</form>
96113
</div>
97114
</div>
98115

99-
<div id="message-bar" class="swagger-ui-wrap">&nbsp;</div>
116+
<div id="message-bar" class="swagger-ui-wrap" data-sw-translate>&nbsp;</div>
100117
<div id="swagger-ui-container" class="swagger-ui-wrap"></div>
101118
</body>
102119
</html>

Resources/public/lib/swagger-oauth.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ var clientId;
55
var realm;
66
var oauth2KeyName;
77
var redirect_uri;
8+
var clientSecret;
9+
var scopeSeparator;
810

911
function handleLogin() {
1012
var scopes = [];
@@ -40,6 +42,7 @@ function handleLogin() {
4042
appName = window.swaggerUi.api.info.title;
4143
}
4244

45+
$('.api-popup-dialog').remove();
4346
popupDialog = $(
4447
[
4548
'<div class="api-popup-dialog">',
@@ -151,7 +154,7 @@ function handleLogin() {
151154
url += '&redirect_uri=' + encodeURIComponent(redirectUrl);
152155
url += '&realm=' + encodeURIComponent(realm);
153156
url += '&client_id=' + encodeURIComponent(clientId);
154-
url += '&scope=' + encodeURIComponent(scopes.join(' '));
157+
url += '&scope=' + encodeURIComponent(scopes.join(scopeSeparator));
155158
url += '&state=' + encodeURIComponent(state);
156159

157160
window.open(url);
@@ -164,8 +167,8 @@ function handleLogin() {
164167

165168

166169
function handleLogout() {
167-
for(key in window.authorizations.authz){
168-
window.authorizations.remove(key)
170+
for(key in window.swaggerUi.api.clientAuthorizations.authz){
171+
window.swaggerUi.api.clientAuthorizations.remove(key)
169172
}
170173
window.enabledScopes = null;
171174
$('.api-ic.ic-on').addClass('ic-off');
@@ -184,7 +187,9 @@ function initOAuth(opts) {
184187
popupMask = (o.popupMask||$('#api-common-mask'));
185188
popupDialog = (o.popupDialog||$('.api-popup-dialog'));
186189
clientId = (o.clientId||errors.push('missing client id'));
190+
clientSecret = (o.clientSecret||errors.push('missing client secret'));
187191
realm = (o.realm||errors.push('missing realm'));
192+
scopeSeparator = (o.scopeSeparator||' ');
188193

189194
if(errors.length > 0){
190195
log('auth unable initialize oauth: ' + errors);
@@ -206,6 +211,7 @@ function initOAuth(opts) {
206211
window.processOAuthCode = function processOAuthCode(data) {
207212
var params = {
208213
'client_id': clientId,
214+
'client_secret': clientSecret,
209215
'code': data.code,
210216
'grant_type': 'authorization_code',
211217
'redirect_uri': redirect_uri
@@ -240,7 +246,7 @@ window.onOAuthComplete = function onOAuthComplete(token) {
240246
if(b){
241247
// if all roles are satisfied
242248
var o = null;
243-
$.each($('.auth #api_information_panel'), function(k, v) {
249+
$.each($('.auth .api-ic .api_information_panel'), function(k, v) {
244250
var children = v;
245251
if(children && children.childNodes) {
246252
var requiredScopes = [];
@@ -257,7 +263,7 @@ window.onOAuthComplete = function onOAuthComplete(token) {
257263
}
258264
}
259265
if(diff.length > 0){
260-
o = v.parentNode;
266+
o = v.parentNode.parentNode;
261267
$(o.parentNode).find('.api-ic.ic-on').addClass('ic-off');
262268
$(o.parentNode).find('.api-ic.ic-on').removeClass('ic-on');
263269

@@ -266,7 +272,7 @@ window.onOAuthComplete = function onOAuthComplete(token) {
266272
$(o).find('.api-ic').removeClass('ic-error');
267273
}
268274
else {
269-
o = v.parentNode;
275+
o = v.parentNode.parentNode;
270276
$(o.parentNode).find('.api-ic.ic-off').addClass('ic-on');
271277
$(o.parentNode).find('.api-ic.ic-off').removeClass('ic-off');
272278

0 commit comments

Comments
 (0)