Skip to content

Commit

Permalink
Upgrade Swagger UI to the newest version.
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelhoral committed Sep 25, 2023
1 parent 6cb16c3 commit a07c4d8
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 96 deletions.
15 changes: 4 additions & 11 deletions openam-ui/openam-ui-api/Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* information: "Portions copyright [year] [name of copyright owner]".
*
* Copyright 2016 ForgeRock AS.
* Portions Copyright 2023 Wren Security
*/
module.exports = function (grunt) {
var serverDeployDirectory = process.env.OPENAM_HOME + '/api',
Expand All @@ -21,22 +22,14 @@ module.exports = function (grunt) {
swagger: {
files: [{
expand: true,
cwd: 'node_modules/swagger-ui/dist/',
src: ['swagger-ui.js', 'css/*', 'fonts/*', 'images/*', 'lang/*', 'lib/*'],
cwd: 'node_modules/swagger-ui-dist/',
src: ['swagger-ui-bundle.{js,js.map}', 'swagger-ui-standalone-preset.{js,js.map}', '*.css'],
dest: compiledDirectory
}],
options: {
noProcess: ['**/*.{png,gif,jpg,ico,svg,ttf,eot,woff}']
}
},
swaggerThemes: {
files: [{
expand: true,
cwd: 'node_modules/swagger-ui-themes/themes/',
src: ['theme-flattop.css'],
dest: compiledDirectory
}]
},
resources: {
files: [{
expand: true,
Expand All @@ -59,7 +52,7 @@ module.exports = function (grunt) {
grunt.loadNpmTasks('grunt-contrib-copy');

grunt.registerTask('build:dev', ['build:prod', 'copy:server']);
grunt.registerTask('build:prod', ['copy:swagger', 'copy:swaggerThemes', 'copy:resources']);
grunt.registerTask('build:prod', ['copy:swagger', 'copy:resources']);

grunt.registerTask("default", ["build:dev"]);
};
20 changes: 5 additions & 15 deletions openam-ui/openam-ui-api/npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions openam-ui/openam-ui-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
"grunt-contrib-copy": "1.0.0"
},
"dependencies": {
"swagger-ui": "2.2.4",
"swagger-ui-themes": "2.0.1"
"swagger-ui-dist": "5.7.2"
}
}
111 changes: 43 additions & 68 deletions openam-ui/openam-ui-api/src/main/resources/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,84 +13,59 @@
information: "Portions Copyrighted [year] [name of copyright owner]".
Copyright 2016-2017 ForgeRock AS.
Portions Copyright 2023 Wren Security
-->
<html>
<head>
<meta charset="UTF-8">
<title>API Explorer</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" />
<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/reset.css" media="print" rel="stylesheet" type="text/css"/>
<link href="css/print.css" media="print" rel="stylesheet" type="text/css"/>

<script src="lib/object-assign-pollyfill.js" type="text/javascript"></script>
<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-4.0.5.js" type="text/javascript"></script>
<script src="lib/lodash.min.js" type="text/javascript"></script>
<script src="lib/backbone-min.js" type="text/javascript"></script>
<script src="swagger-ui.js" type="text/javascript"></script>
<script src="lib/highlight.9.1.0.pack.js" type="text/javascript"></script>
<script src="lib/highlight.9.1.0.pack_extended.js" type="text/javascript"></script>
<script src="lib/jsoneditor.min.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 type="text/javascript">
$(function () {
var path = window.location.pathname.replace(new RegExp("^/|/$", "g"), "").split("/");
path.splice(-1);
var joinedPath = path.join("/");

var url = window.location.search.match(/url=([^&]+)/);
if (url && url.length > 1) {
url = decodeURIComponent(url[1]);
} else {
url = "/" + joinedPath + "/json?_api";
}

var getCookie = function (c_name) {
var i, x, y, cookies = document.cookie.split(";");
for (i = 0; i < cookies.length; i++) {
x = cookies[i].substr(0, cookies[i].indexOf("="));
y = cookies[i].substr(cookies[i].indexOf("=") + 1);
x = x.replace(/^\s+|\s+$/g, "");
if (x === c_name) {
return unescape(y);
}
}
};

window.swaggerUi = new SwaggerUi({
url: url,
validatorUrl : null,
dom_id: "swagger-ui-div",
defaultModelRendering: 'schema',
supportedSubmitMethods: ['get', 'delete', 'patch', 'post', 'put'],
docExpansion: "list",
onComplete: function (swaggerApi, swaggerUi) {
$('pre code').each(function (i, e) {
hljs.highlightBlock(e)
});
<link href="swagger-ui.css" media="screen" rel="stylesheet" type="text/css"/>
</head>
<body style="margin:0">
<div id="swagger-ui"></div>
<script src="swagger-ui-bundle.js" charset="UTF-8"></script>
<script src="swagger-ui-standalone-preset.js" charset="UTF-8"></script>
<script type="text/javascript">
setTimeout(function () {
var path = window.location.pathname.replace(new RegExp("^/|/$", "g"), "").split("/");
path.splice(-1);
var joinedPath = path.join("/");

var cookieValue = getCookie("iPlanetDirectoryPro");
var url = window.location.search.match(/url=([^&]+)/);
if (url && url.length > 1) {
url = decodeURIComponent(url[1]);
} else {
url = "/" + joinedPath + "/json?_api";
}

window.swaggerUi.api.clientAuthorizations.add("iPlanetDirectoryPro",
new SwaggerClient.ApiKeyAuthorization("iPlanetDirectoryPro", cookieValue, "header"));
var getCookie = function (c_name) {
var i, x, y, cookies = document.cookie.split(";");
for (i = 0; i < cookies.length; i++) {
x = cookies[i].substr(0, cookies[i].indexOf("="));
y = cookies[i].substr(cookies[i].indexOf("=") + 1);
x = x.replace(/^\s+|\s+$/g, "");
if (x === c_name) {
return unescape(y);
}
});
}
};

window.swaggerUi.load();
window.swaggerUi = SwaggerUIBundle({
url: url,
dom_id: "#swagger-ui",
validatorUrl: "none",
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIStandalonePreset
],
layout: "StandaloneLayout",
requestInterceptor: function (request) {
request.headers["iPlanetDirectoryPro"] = getCookie("iPlanetDirectoryPro");
}
});
</script>
</head>
<body class="swagger-section">
<div id="swagger-ui-div" class="swagger-ui-wrap" style="margin-left: 0px; min-width: 0px">
</div>
});
</script>
</body>
</html>
</html>

0 comments on commit a07c4d8

Please sign in to comment.