Parcourir la source

updated oauth2 support into a single config

bubble
Tony Tam il y a 10 ans
Parent
révision
a36da91d7e
2 fichiers modifiés avec 19 ajouts et 13 suppressions
  1. +11
    -7
      dist/index.html
  2. +8
    -6
      dist/lib/swagger-oauth.js

+ 11
- 7
dist/index.html Voir le fichier

@@ -17,6 +17,7 @@
<script src='swagger-ui.js' type='text/javascript'></script>
<script src='lib/highlight.7.3.pack.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">
@@ -28,12 +29,18 @@
onComplete: function(swaggerApi, swaggerUi){
log("Loaded SwaggerUI");
if(typeof initOAuth == "function")
if(typeof initOAuth == "function") {
/*
initOAuth({
clientId: "me",
realm: "realms"
clientId: "your-client-id",
realm: "your-realms",
appName: "your-app-name"
});
$('pre code').each(function(i, e) {hljs.highlightBlock(e)});
*/
}
$('pre code').each(function(i, e) {
hljs.highlightBlock(e)
});
},
onFailure: function(data) {
log("Unable to Load SwaggerUI");
@@ -51,7 +58,6 @@
})
window.swaggerUi.load();
});
</script>
</head>
@@ -59,7 +65,6 @@
<div id='header'>
<div class="swagger-ui-wrap">
<a id="logo" href="http://swagger.wordnik.com">swagger</a>
<form id='api_selector'>
<div class='input icon-btn'>
<img id="show-pet-store-icon" src="images/pet_store_api.png" title="Show Swagger Petstore Example Apis">
@@ -75,7 +80,6 @@
</div>
<div id="message-bar" class="swagger-ui-wrap">&nbsp;</div>
<div id="swagger-ui-container" class="swagger-ui-wrap"></div>
</body>
</html>

+ 8
- 6
dist/lib/swagger-oauth.js Voir le fichier

@@ -1,10 +1,11 @@
var appName;
var popupMask;
var popupDialog;
var clientId;
var realm;

function handleLogin() {
var scopes = [];
var appName;
var popupMask;
var popupDialog;
var clientId;
var realm;

if(window.swaggerUi.api.authSchemes
&& window.swaggerUi.api.authSchemes.oauth2
@@ -17,7 +18,8 @@ function handleLogin() {
appName = window.swaggerUi.api.info.title;
}

if(popupDialog.length > 0) popupDialog = popupDialog.last();
if(popupDialog.length > 0)
popupDialog = popupDialog.last();
else {
popupDialog = $(
[


Chargement…
Annuler
Enregistrer