Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Resources/public/css/print.css
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,9 @@
outline: 2px solid black;
outline-color: #cc0000;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content form select[name='parameterContentType'] {
max-width: 300px;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content div.response div.block pre {
font-family: "Anonymous Pro", "Menlo", "Consolas", "Bitstream Vera Sans Mono", "Courier New", monospace;
padding: 10px;
Expand Down
33 changes: 21 additions & 12 deletions Resources/public/css/screen.css
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,9 @@
outline: 2px solid black;
outline-color: #cc0000;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content form select[name='parameterContentType'] {
max-width: 300px;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content div.response div.block pre {
font-family: "Anonymous Pro", "Menlo", "Consolas", "Bitstream Vera Sans Mono", "Courier New", monospace;
padding: 10px;
Expand Down Expand Up @@ -1155,8 +1158,16 @@
.swagger-section .auth {
float: right;
}
.swagger-section #api_information_panel {
position: absolute;
.swagger-section .api-ic {
height: 18px;
vertical-align: middle;
display: inline-block;
background: url(../images/explorer_icons.png) no-repeat;
}
.swagger-section .api-ic .api_information_panel {
position: relative;
margin-top: 20px;
margin-left: -5px;
background: #FFF;
border: 1px solid #ccc;
border-radius: 5px;
Expand All @@ -1167,34 +1178,32 @@
color: black;
padding: 5px;
}
.swagger-section #api_information_panel p .api-msg-enabled {
.swagger-section .api-ic .api_information_panel p .api-msg-enabled {
color: green;
}
.swagger-section #api_information_panel p .api-msg-disabled {
.swagger-section .api-ic .api_information_panel p .api-msg-disabled {
color: red;
}
.swagger-section .api-ic {
height: 18px;
vertical-align: middle;
display: inline-block;
background: url(../images/explorer_icons.png) no-repeat;
.swagger-section .api-ic:hover .api_information_panel {
position: absolute;
display: block;
}
.swagger-section .ic-info {
background-position: 0 0;
width: 18px;
margin-top: -7px;
margin-top: -6px;
margin-left: 4px;
}
.swagger-section .ic-warning {
background-position: -60px 0;
width: 18px;
margin-top: -7px;
margin-top: -6px;
margin-left: 4px;
}
.swagger-section .ic-error {
background-position: -30px 0;
width: 18px;
margin-top: -7px;
margin-top: -6px;
margin-left: 4px;
}
.swagger-section .ic-off {
Expand Down
23 changes: 20 additions & 3 deletions Resources/public/index.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<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-16x16.png" sizes="16x16" />
Expand All @@ -21,6 +22,11 @@
<script src='lib/marked.js' type='text/javascript'></script>
<script src='lib/swagger-oauth.js' type='text/javascript'></script>

<!-- Some basic translations -->
<!-- <script src='lang/translator.js' type='text/javascript'></script> -->
<!-- <script src='lang/ru.js' type='text/javascript'></script> -->
<!-- <script src='lang/en.js' type='text/javascript'></script> -->

<script type="text/javascript">
$(function () {
var url = window.location.search.match(/url=([^&]+)/);
Expand All @@ -29,6 +35,11 @@
} else {
url = "http://petstore.swagger.io/v2/swagger.json";
}

// Pre load translate...
if(window.SwaggerTranslator) {
window.SwaggerTranslator.translate();
}
window.swaggerUi = new SwaggerUi({
url: url,
dom_id: "swagger-ui-container",
Expand All @@ -37,11 +48,17 @@
if(typeof initOAuth == "function") {
initOAuth({
clientId: "your-client-id",
clientSecret: "your-client-secret",
realm: "your-realms",
appName: "your-app-name"
appName: "your-app-name",
scopeSeparator: ","
});
}

if(window.SwaggerTranslator) {
window.SwaggerTranslator.translate();
}

$('pre code').each(function(i, e) {
hljs.highlightBlock(e)
});
Expand Down Expand Up @@ -91,12 +108,12 @@
<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="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="#" data-sw-translate>Explore</a></div>
</form>
</div>
</div>

<div id="message-bar" class="swagger-ui-wrap">&nbsp;</div>
<div id="message-bar" class="swagger-ui-wrap" data-sw-translate>&nbsp;</div>
<div id="swagger-ui-container" class="swagger-ui-wrap"></div>
</body>
</html>
18 changes: 12 additions & 6 deletions Resources/public/lib/swagger-oauth.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ var clientId;
var realm;
var oauth2KeyName;
var redirect_uri;
var clientSecret;
var scopeSeparator;

function handleLogin() {
var scopes = [];
Expand Down Expand Up @@ -40,6 +42,7 @@ function handleLogin() {
appName = window.swaggerUi.api.info.title;
}

$('.api-popup-dialog').remove();
popupDialog = $(
[
'<div class="api-popup-dialog">',
Expand Down Expand Up @@ -151,7 +154,7 @@ function handleLogin() {
url += '&redirect_uri=' + encodeURIComponent(redirectUrl);
url += '&realm=' + encodeURIComponent(realm);
url += '&client_id=' + encodeURIComponent(clientId);
url += '&scope=' + encodeURIComponent(scopes.join(' '));
url += '&scope=' + encodeURIComponent(scopes.join(scopeSeparator));
url += '&state=' + encodeURIComponent(state);

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


function handleLogout() {
for(key in window.authorizations.authz){
window.authorizations.remove(key)
for(key in window.swaggerUi.api.clientAuthorizations.authz){
window.swaggerUi.api.clientAuthorizations.remove(key)
}
window.enabledScopes = null;
$('.api-ic.ic-on').addClass('ic-off');
Expand All @@ -184,7 +187,9 @@ function initOAuth(opts) {
popupMask = (o.popupMask||$('#api-common-mask'));
popupDialog = (o.popupDialog||$('.api-popup-dialog'));
clientId = (o.clientId||errors.push('missing client id'));
clientSecret = (o.clientSecret||errors.push('missing client secret'));
realm = (o.realm||errors.push('missing realm'));
scopeSeparator = (o.scopeSeparator||' ');

if(errors.length > 0){
log('auth unable initialize oauth: ' + errors);
Expand All @@ -206,6 +211,7 @@ function initOAuth(opts) {
window.processOAuthCode = function processOAuthCode(data) {
var params = {
'client_id': clientId,
'client_secret': clientSecret,
'code': data.code,
'grant_type': 'authorization_code',
'redirect_uri': redirect_uri
Expand Down Expand Up @@ -240,7 +246,7 @@ window.onOAuthComplete = function onOAuthComplete(token) {
if(b){
// if all roles are satisfied
var o = null;
$.each($('.auth #api_information_panel'), function(k, v) {
$.each($('.auth .api-ic .api_information_panel'), function(k, v) {
var children = v;
if(children && children.childNodes) {
var requiredScopes = [];
Expand All @@ -257,7 +263,7 @@ window.onOAuthComplete = function onOAuthComplete(token) {
}
}
if(diff.length > 0){
o = v.parentNode;
o = v.parentNode.parentNode;
$(o.parentNode).find('.api-ic.ic-on').addClass('ic-off');
$(o.parentNode).find('.api-ic.ic-on').removeClass('ic-on');

Expand All @@ -266,7 +272,7 @@ window.onOAuthComplete = function onOAuthComplete(token) {
$(o).find('.api-ic').removeClass('ic-error');
}
else {
o = v.parentNode;
o = v.parentNode.parentNode;
$(o.parentNode).find('.api-ic.ic-off').addClass('ic-on');
$(o.parentNode).find('.api-ic.ic-off').removeClass('ic-off');

Expand Down
Loading