mirror of
https://github.com/opennetworkinglab/onos.git
synced 2025-10-16 09:51:38 +02:00
Bumpup swagger ui to 2.1.4 to fix the issues in 2.1.0
This commit resolves some issues on generating REST API request, such as incorrect content-type generation for http DELETE request. Change-Id: I70bf18247f95ccf22b1fd77bc48ce9977ff57212
This commit is contained in:
parent
e10a6e9003
commit
83d87a766a
@ -21,6 +21,7 @@
|
|||||||
<script src='lib/highlight.7.3.pack.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>
|
<script src='lib/marked.js' type='text/javascript'></script>
|
||||||
<script src='lib/swagger-oauth.js' type='text/javascript'></script>
|
<script src='lib/swagger-oauth.js' type='text/javascript'></script>
|
||||||
|
<script src='lib/jsoneditor.min.js' type='text/javascript'></script>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(function () {
|
$(function () {
|
||||||
|
11
web/api/src/main/resources/docs/lib/jsoneditor.min.js
vendored
Normal file
11
web/api/src/main/resources/docs/lib/jsoneditor.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -3,8 +3,10 @@ var popupMask;
|
|||||||
var popupDialog;
|
var popupDialog;
|
||||||
var clientId;
|
var clientId;
|
||||||
var realm;
|
var realm;
|
||||||
var oauth2KeyName;
|
|
||||||
var redirect_uri;
|
var redirect_uri;
|
||||||
|
var clientSecret;
|
||||||
|
var scopeSeparator;
|
||||||
|
var additionalQueryStringParams;
|
||||||
|
|
||||||
function handleLogin() {
|
function handleLogin() {
|
||||||
var scopes = [];
|
var scopes = [];
|
||||||
@ -16,7 +18,6 @@ function handleLogin() {
|
|||||||
for(key in defs) {
|
for(key in defs) {
|
||||||
var auth = defs[key];
|
var auth = defs[key];
|
||||||
if(auth.type === 'oauth2' && auth.scopes) {
|
if(auth.type === 'oauth2' && auth.scopes) {
|
||||||
oauth2KeyName = key;
|
|
||||||
var scope;
|
var scope;
|
||||||
if(Array.isArray(auth.scopes)) {
|
if(Array.isArray(auth.scopes)) {
|
||||||
// 1.2 support
|
// 1.2 support
|
||||||
@ -28,7 +29,7 @@ function handleLogin() {
|
|||||||
else {
|
else {
|
||||||
// 2.0 support
|
// 2.0 support
|
||||||
for(scope in auth.scopes) {
|
for(scope in auth.scopes) {
|
||||||
scopes.push({scope: scope, description: auth.scopes[scope]});
|
scopes.push({scope: scope, description: auth.scopes[scope], OAuthSchemeKey: key});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -40,6 +41,7 @@ function handleLogin() {
|
|||||||
appName = window.swaggerUi.api.info.title;
|
appName = window.swaggerUi.api.info.title;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$('.api-popup-dialog').remove();
|
||||||
popupDialog = $(
|
popupDialog = $(
|
||||||
[
|
[
|
||||||
'<div class="api-popup-dialog">',
|
'<div class="api-popup-dialog">',
|
||||||
@ -57,12 +59,16 @@ function handleLogin() {
|
|||||||
'</div>'].join(''));
|
'</div>'].join(''));
|
||||||
$(document.body).append(popupDialog);
|
$(document.body).append(popupDialog);
|
||||||
|
|
||||||
|
//TODO: only display applicable scopes (will need to pass them into handleLogin)
|
||||||
popup = popupDialog.find('ul.api-popup-scopes').empty();
|
popup = popupDialog.find('ul.api-popup-scopes').empty();
|
||||||
for (i = 0; i < scopes.length; i ++) {
|
for (i = 0; i < scopes.length; i ++) {
|
||||||
scope = scopes[i];
|
scope = scopes[i];
|
||||||
str = '<li><input type="checkbox" id="scope_' + i + '" scope="' + scope.scope + '"/>' + '<label for="scope_' + i + '">' + scope.scope;
|
str = '<li><input type="checkbox" id="scope_' + i + '" scope="' + scope.scope + '"' +'" oauthtype="' + scope.OAuthSchemeKey +'"/>' + '<label for="scope_' + i + '">' + scope.scope ;
|
||||||
if (scope.description) {
|
if (scope.description) {
|
||||||
str += '<br/><span class="api-scope-desc">' + scope.description + '</span>';
|
if ($.map(auths, function(n, i) { return i; }).length > 1) //if we have more than one scheme, display schemes
|
||||||
|
str += '<br/><span class="api-scope-desc">' + scope.description + ' ('+ scope.OAuthSchemeKey+')' +'</span>';
|
||||||
|
else
|
||||||
|
str += '<br/><span class="api-scope-desc">' + scope.description + '</span>';
|
||||||
}
|
}
|
||||||
str += '</label></li>';
|
str += '</label></li>';
|
||||||
popup.append(str);
|
popup.append(str);
|
||||||
@ -100,9 +106,25 @@ function handleLogin() {
|
|||||||
var defaultRedirectUrl = host.protocol + '//' + host.host + pathname + '/o2c.html';
|
var defaultRedirectUrl = host.protocol + '//' + host.host + pathname + '/o2c.html';
|
||||||
var redirectUrl = window.oAuthRedirectUrl || defaultRedirectUrl;
|
var redirectUrl = window.oAuthRedirectUrl || defaultRedirectUrl;
|
||||||
var url = null;
|
var url = null;
|
||||||
|
var scopes = []
|
||||||
for (var key in authSchemes) {
|
var o = popup.find('input:checked');
|
||||||
if (authSchemes.hasOwnProperty(key)) {
|
var OAuthSchemeKeys = [];
|
||||||
|
var state;
|
||||||
|
for(k =0; k < o.length; k++) {
|
||||||
|
var scope = $(o[k]).attr('scope');
|
||||||
|
if (scopes.indexOf(scope) === -1)
|
||||||
|
scopes.push(scope);
|
||||||
|
var OAuthSchemeKey = $(o[k]).attr('oauthtype');
|
||||||
|
if (OAuthSchemeKeys.indexOf(OAuthSchemeKey) === -1)
|
||||||
|
OAuthSchemeKeys.push(OAuthSchemeKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO: merge not replace if scheme is different from any existing
|
||||||
|
//(needs to be aware of schemes to do so correctly)
|
||||||
|
window.enabledScopes=scopes;
|
||||||
|
|
||||||
|
for (var key in authSchemes) {
|
||||||
|
if (authSchemes.hasOwnProperty(key) && OAuthSchemeKeys.indexOf(key) != -1) { //only look at keys that match this scope.
|
||||||
var flow = authSchemes[key].flow;
|
var flow = authSchemes[key].flow;
|
||||||
|
|
||||||
if(authSchemes[key].type === 'oauth2' && flow && (flow === 'implicit' || flow === 'accessCode')) {
|
if(authSchemes[key].type === 'oauth2' && flow && (flow === 'implicit' || flow === 'accessCode')) {
|
||||||
@ -110,7 +132,14 @@ function handleLogin() {
|
|||||||
url = dets.authorizationUrl + '?response_type=' + (flow === 'implicit' ? 'token' : 'code');
|
url = dets.authorizationUrl + '?response_type=' + (flow === 'implicit' ? 'token' : 'code');
|
||||||
window.swaggerUi.tokenName = dets.tokenName || 'access_token';
|
window.swaggerUi.tokenName = dets.tokenName || 'access_token';
|
||||||
window.swaggerUi.tokenUrl = (flow === 'accessCode' ? dets.tokenUrl : null);
|
window.swaggerUi.tokenUrl = (flow === 'accessCode' ? dets.tokenUrl : null);
|
||||||
|
state = key;
|
||||||
}
|
}
|
||||||
|
else if(authSchemes[key].type === 'oauth2' && flow && (flow === 'application')) {
|
||||||
|
var dets = authSchemes[key];
|
||||||
|
window.swaggerUi.tokenName = dets.tokenName || 'access_token';
|
||||||
|
clientCredentialsFlow(scopes, dets.tokenUrl, key);
|
||||||
|
return;
|
||||||
|
}
|
||||||
else if(authSchemes[key].grantTypes) {
|
else if(authSchemes[key].grantTypes) {
|
||||||
// 1.2 support
|
// 1.2 support
|
||||||
var o = authSchemes[key].grantTypes;
|
var o = authSchemes[key].grantTypes;
|
||||||
@ -131,28 +160,17 @@ function handleLogin() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var scopes = []
|
|
||||||
var o = $('.api-popup-scopes').find('input:checked');
|
|
||||||
|
|
||||||
for(k =0; k < o.length; k++) {
|
|
||||||
var scope = $(o[k]).attr('scope');
|
|
||||||
|
|
||||||
if (scopes.indexOf(scope) === -1)
|
|
||||||
scopes.push(scope);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Implicit auth recommends a state parameter.
|
|
||||||
var state = Math.random ();
|
|
||||||
|
|
||||||
window.enabledScopes=scopes;
|
|
||||||
|
|
||||||
redirect_uri = redirectUrl;
|
redirect_uri = redirectUrl;
|
||||||
|
|
||||||
url += '&redirect_uri=' + encodeURIComponent(redirectUrl);
|
url += '&redirect_uri=' + encodeURIComponent(redirectUrl);
|
||||||
url += '&realm=' + encodeURIComponent(realm);
|
url += '&realm=' + encodeURIComponent(realm);
|
||||||
url += '&client_id=' + encodeURIComponent(clientId);
|
url += '&client_id=' + encodeURIComponent(clientId);
|
||||||
url += '&scope=' + encodeURIComponent(scopes.join(' '));
|
url += '&scope=' + encodeURIComponent(scopes.join(scopeSeparator));
|
||||||
url += '&state=' + encodeURIComponent(state);
|
url += '&state=' + encodeURIComponent(state);
|
||||||
|
for (var key in additionalQueryStringParams) {
|
||||||
|
url += '&' + key + '=' + encodeURIComponent(additionalQueryStringParams[key]);
|
||||||
|
}
|
||||||
|
|
||||||
window.open(url);
|
window.open(url);
|
||||||
});
|
});
|
||||||
@ -164,8 +182,8 @@ function handleLogin() {
|
|||||||
|
|
||||||
|
|
||||||
function handleLogout() {
|
function handleLogout() {
|
||||||
for(key in window.authorizations.authz){
|
for(key in window.swaggerUi.api.clientAuthorizations.authz){
|
||||||
window.authorizations.remove(key)
|
window.swaggerUi.api.clientAuthorizations.remove(key)
|
||||||
}
|
}
|
||||||
window.enabledScopes = null;
|
window.enabledScopes = null;
|
||||||
$('.api-ic.ic-on').addClass('ic-off');
|
$('.api-ic.ic-on').addClass('ic-off');
|
||||||
@ -184,7 +202,10 @@ function initOAuth(opts) {
|
|||||||
popupMask = (o.popupMask||$('#api-common-mask'));
|
popupMask = (o.popupMask||$('#api-common-mask'));
|
||||||
popupDialog = (o.popupDialog||$('.api-popup-dialog'));
|
popupDialog = (o.popupDialog||$('.api-popup-dialog'));
|
||||||
clientId = (o.clientId||errors.push('missing client id'));
|
clientId = (o.clientId||errors.push('missing client id'));
|
||||||
|
clientSecret = (o.clientSecret||null);
|
||||||
realm = (o.realm||errors.push('missing realm'));
|
realm = (o.realm||errors.push('missing realm'));
|
||||||
|
scopeSeparator = (o.scopeSeparator||' ');
|
||||||
|
additionalQueryStringParams = (o.additionalQueryStringParams||{});
|
||||||
|
|
||||||
if(errors.length > 0){
|
if(errors.length > 0){
|
||||||
log('auth unable initialize oauth: ' + errors);
|
log('auth unable initialize oauth: ' + errors);
|
||||||
@ -203,13 +224,43 @@ function initOAuth(opts) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function clientCredentialsFlow(scopes, tokenUrl, OAuthSchemeKey) {
|
||||||
|
var params = {
|
||||||
|
'client_id': clientId,
|
||||||
|
'client_secret': clientSecret,
|
||||||
|
'scope': scopes.join(' '),
|
||||||
|
'grant_type': 'client_credentials'
|
||||||
|
}
|
||||||
|
$.ajax(
|
||||||
|
{
|
||||||
|
url : tokenUrl,
|
||||||
|
type: "POST",
|
||||||
|
data: params,
|
||||||
|
success:function(data, textStatus, jqXHR)
|
||||||
|
{
|
||||||
|
onOAuthComplete(data,OAuthSchemeKey);
|
||||||
|
},
|
||||||
|
error: function(jqXHR, textStatus, errorThrown)
|
||||||
|
{
|
||||||
|
onOAuthComplete("");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
window.processOAuthCode = function processOAuthCode(data) {
|
window.processOAuthCode = function processOAuthCode(data) {
|
||||||
|
var OAuthSchemeKey = data.state;
|
||||||
var params = {
|
var params = {
|
||||||
'client_id': clientId,
|
'client_id': clientId,
|
||||||
'code': data.code,
|
'code': data.code,
|
||||||
'grant_type': 'authorization_code',
|
'grant_type': 'authorization_code',
|
||||||
'redirect_uri': redirect_uri
|
'redirect_uri': redirect_uri
|
||||||
|
};
|
||||||
|
|
||||||
|
if (clientSecret) {
|
||||||
|
params.client_secret = clientSecret;
|
||||||
}
|
}
|
||||||
|
|
||||||
$.ajax(
|
$.ajax(
|
||||||
{
|
{
|
||||||
url : window.swaggerUi.tokenUrl,
|
url : window.swaggerUi.tokenUrl,
|
||||||
@ -217,16 +268,16 @@ window.processOAuthCode = function processOAuthCode(data) {
|
|||||||
data: params,
|
data: params,
|
||||||
success:function(data, textStatus, jqXHR)
|
success:function(data, textStatus, jqXHR)
|
||||||
{
|
{
|
||||||
onOAuthComplete(data);
|
onOAuthComplete(data, OAuthSchemeKey);
|
||||||
},
|
},
|
||||||
error: function(jqXHR, textStatus, errorThrown)
|
error: function(jqXHR, textStatus, errorThrown)
|
||||||
{
|
{
|
||||||
onOAuthComplete("");
|
onOAuthComplete("");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
window.onOAuthComplete = function onOAuthComplete(token) {
|
window.onOAuthComplete = function onOAuthComplete(token,OAuthSchemeKey) {
|
||||||
if(token) {
|
if(token) {
|
||||||
if(token.error) {
|
if(token.error) {
|
||||||
var checkbox = $('input[type=checkbox],.secured')
|
var checkbox = $('input[type=checkbox],.secured')
|
||||||
@ -236,11 +287,14 @@ window.onOAuthComplete = function onOAuthComplete(token) {
|
|||||||
alert(token.error);
|
alert(token.error);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
var b = token[window.swaggerUi.tokenName];
|
var b = token[window.swaggerUi.tokenName];
|
||||||
|
if (!OAuthSchemeKey){
|
||||||
|
OAuthSchemeKey = token.state;
|
||||||
|
}
|
||||||
if(b){
|
if(b){
|
||||||
// if all roles are satisfied
|
// if all roles are satisfied
|
||||||
var o = null;
|
var o = null;
|
||||||
$.each($('.auth #api_information_panel'), function(k, v) {
|
$.each($('.auth .api-ic .api_information_panel'), function(k, v) {
|
||||||
var children = v;
|
var children = v;
|
||||||
if(children && children.childNodes) {
|
if(children && children.childNodes) {
|
||||||
var requiredScopes = [];
|
var requiredScopes = [];
|
||||||
@ -257,7 +311,7 @@ window.onOAuthComplete = function onOAuthComplete(token) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(diff.length > 0){
|
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').addClass('ic-off');
|
||||||
$(o.parentNode).find('.api-ic.ic-on').removeClass('ic-on');
|
$(o.parentNode).find('.api-ic.ic-on').removeClass('ic-on');
|
||||||
|
|
||||||
@ -266,7 +320,7 @@ window.onOAuthComplete = function onOAuthComplete(token) {
|
|||||||
$(o).find('.api-ic').removeClass('ic-error');
|
$(o).find('.api-ic').removeClass('ic-error');
|
||||||
}
|
}
|
||||||
else {
|
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').addClass('ic-on');
|
||||||
$(o.parentNode).find('.api-ic.ic-off').removeClass('ic-off');
|
$(o.parentNode).find('.api-ic.ic-off').removeClass('ic-off');
|
||||||
|
|
||||||
@ -277,8 +331,8 @@ window.onOAuthComplete = function onOAuthComplete(token) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
window.swaggerUi.api.clientAuthorizations.add(oauth2KeyName, new SwaggerClient.ApiKeyAuthorization('Authorization', 'Bearer ' + b, 'header'));
|
window.swaggerUi.api.clientAuthorizations.add(OAuthSchemeKey, new SwaggerClient.ApiKeyAuthorization('Authorization', 'Bearer ' + b, 'header'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
1
web/api/src/main/resources/docs/lib/underscore-min.map
Normal file
1
web/api/src/main/resources/docs/lib/underscore-min.map
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user