Upgrade to strong-swagger-ui@21.0 (swagger-ui@2.1)
This commit is contained in:
parent
8c82f17930
commit
30017c8242
2
index.js
2
index.js
|
@ -7,7 +7,7 @@ var path = require('path');
|
|||
var urlJoin = require('./lib/url-join');
|
||||
var _defaults = require('lodash').defaults;
|
||||
var swagger = require('./lib/swagger');
|
||||
var SWAGGER_UI_ROOT = require('strong-swagger-ui').dist;
|
||||
var SWAGGER_UI_ROOT = require('strong-swagger-ui/index').dist;
|
||||
var STATIC_ROOT = path.join(__dirname, 'public');
|
||||
|
||||
module.exports = explorer;
|
||||
|
|
|
@ -34,6 +34,6 @@
|
|||
"cors": "^2.7.1",
|
||||
"debug": "^2.2.0",
|
||||
"lodash": "^3.10.0",
|
||||
"strong-swagger-ui": "^20.0.2"
|
||||
"strong-swagger-ui": "^21.0.0-dev.1"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,22 +1,26 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<title>StrongLoop API Explorer</title>
|
||||
<link href='css/reset.css' media='screen,print' rel='stylesheet' type='text/css'/>
|
||||
<link href='css/screen.css' media='screen,print' rel='stylesheet' type='text/css'/>
|
||||
<link href='css/loopbackStyles.css' rel='stylesheet' type='text/css'/>
|
||||
<script type="text/javascript" src="lib/shred.bundle.js"></script>
|
||||
<link href='css/typography.css' media='screen' rel='stylesheet' type='text/css'/>
|
||||
<link href='css/reset.css' media='screen' rel='stylesheet' type='text/css'/>
|
||||
<link href='css/screen.css' media='screen' rel='stylesheet' type='text/css'/>
|
||||
<link href='css/loopbackStyles.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'/>
|
||||
<link href='css/loopbackStyles.css' media='print' rel='stylesheet' type='text/css'/>
|
||||
<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>
|
||||
<script src='lib/jquery.ba-bbq.min.js' type='text/javascript'></script>
|
||||
<script src='lib/handlebars-1.0.0.js' type='text/javascript'></script>
|
||||
<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.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/marked.js' type='text/javascript'></script>
|
||||
|
||||
<!-- enabling this will enable oauth2 implicit scope support -->
|
||||
<script src='lib/swagger-oauth.js' type='text/javascript'></script>
|
||||
|
|
|
@ -3,6 +3,11 @@
|
|||
// Refactoring of inline script from index.html.
|
||||
/*global SwaggerUi, log, ApiKeyAuthorization, hljs, window, $ */
|
||||
$(function() {
|
||||
// Pre load translate...
|
||||
if(window.SwaggerTranslator) {
|
||||
window.SwaggerTranslator.translate();
|
||||
}
|
||||
|
||||
var lsKey = 'swagger_accessToken';
|
||||
$.getJSON('config.json', function(config) {
|
||||
log(config);
|
||||
|
@ -16,12 +21,26 @@ $(function() {
|
|||
apiKey: '',
|
||||
dom_id: 'swagger-ui-container',
|
||||
supportHeaderParams: true,
|
||||
supportedSubmitMethods: ['get', 'post', 'put', 'delete'],
|
||||
onComplete: function(swaggerApi, swaggerUi) {
|
||||
log('Loaded SwaggerUI');
|
||||
log(swaggerApi);
|
||||
log(swaggerUi);
|
||||
$('pre code').each(function(i, e) {hljs.highlightBlock(e); });
|
||||
|
||||
if(window.SwaggerTranslator) {
|
||||
window.SwaggerTranslator.translate();
|
||||
}
|
||||
|
||||
$('pre code').each(function(i, e) {
|
||||
hljs.highlightBlock(e);
|
||||
});
|
||||
|
||||
// Recover accessToken from localStorage if present.
|
||||
if (window.localStorage) {
|
||||
var key = window.localStorage.getItem(lsKey);
|
||||
if (key) {
|
||||
$('#input_accessToken').val(key).submit();
|
||||
}
|
||||
}
|
||||
},
|
||||
onFailure: function(data) {
|
||||
log('Unable to Load SwaggerUI');
|
||||
|
@ -36,14 +55,6 @@ $(function() {
|
|||
$('#api_selector').submit(setAccessToken);
|
||||
$('#input_accessToken').keyup(onInputChange);
|
||||
|
||||
// Recover accessToken from localStorage if present.
|
||||
if (window.localStorage) {
|
||||
var key = window.localStorage.getItem(lsKey);
|
||||
if (key) {
|
||||
$('#input_accessToken').val(key).submit();
|
||||
}
|
||||
}
|
||||
|
||||
window.swaggerUi.load();
|
||||
}
|
||||
|
||||
|
@ -54,23 +65,26 @@ $(function() {
|
|||
log('key: ' + key);
|
||||
if(key && key.trim() !== '') {
|
||||
log('added accessToken ' + key);
|
||||
window.authorizations.add('key', new ApiKeyAuthorization('access_token', key, 'query'));
|
||||
var apiKeyAuth = new SwaggerClient.ApiKeyAuthorization('access_token', key, 'query');
|
||||
window.swaggerUi.api.clientAuthorizations.add('key', apiKeyAuth);
|
||||
accessToken = key;
|
||||
$('.accessTokenDisplay').text('Token Set.').addClass('set');
|
||||
$('.accessTokenDisplay').attr('data-tooltip', 'Current Token: ' + key);
|
||||
|
||||
// Save this token to localStorage if we can to make it persist on refresh.
|
||||
|
||||
// Save this token to localStorage if we can to make it persist on refresh.
|
||||
if (window.localStorage) {
|
||||
window.localStorage.setItem(lsKey, key);
|
||||
}
|
||||
}
|
||||
// If submitted with an empty token, remove the current token. Can be
|
||||
// If submitted with an empty token, remove the current token. Can be
|
||||
// useful to intentionally remove authorization.
|
||||
else {
|
||||
log('removed accessToken.');
|
||||
$('.accessTokenDisplay').text('Token Not Set.').removeClass('set');
|
||||
$('.accessTokenDisplay').removeAttr('data-tooltip');
|
||||
window.authorizations.remove('key');
|
||||
if (window.swaggerUi) {
|
||||
window.swaggerUi.api.clientAuthorizations.remove('key');
|
||||
}
|
||||
if (window.localStorage) {
|
||||
window.localStorage.removeItem(lsKey);
|
||||
}
|
||||
|
@ -87,6 +101,12 @@ $(function() {
|
|||
$('.accessTokenDisplay').text('Token Set.');
|
||||
}
|
||||
}
|
||||
|
||||
function log() {
|
||||
if ('console' in window) {
|
||||
console.log.apply(console, arguments);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue