Skip to content

Commit

Permalink
disable url parameter in swagger-ui page (backport cosmos#11202) (cos…
Browse files Browse the repository at this point in the history
…mos#11207)

* disable url parameter in swagger-ui page (cosmos#11202)

Closes: cosmos#11201
Solution:
- update swagger-ui to recent release
- add option `queryConfigEnabled: false`

(cherry picked from commit cb6fea9)

# Conflicts:
#	client/docs/statik/statik.go
#	client/docs/swagger-ui/swagger-ui-bundle.js
#	client/docs/swagger-ui/swagger-ui-bundle.js.map
#	client/docs/swagger-ui/swagger-ui-es-bundle-core.js
#	client/docs/swagger-ui/swagger-ui-es-bundle-core.js.map
#	client/docs/swagger-ui/swagger-ui-es-bundle.js
#	client/docs/swagger-ui/swagger-ui-es-bundle.js.map
#	client/docs/swagger-ui/swagger-ui-standalone-preset.js
#	client/docs/swagger-ui/swagger-ui-standalone-preset.js.map
#	client/docs/swagger-ui/swagger-ui.js
#	client/docs/swagger-ui/swagger-ui.js.map

* fix conflicts

* override swagger-ui after resolve conflicts

Co-authored-by: yihuang <huang@crypto.com>
Co-authored-by: marbar3778 <marbar3778@yahoo.com>
  • Loading branch information
3 people authored and randy75828 committed Aug 10, 2022
1 parent 126ee72 commit 4e9d3bc
Show file tree
Hide file tree
Showing 18 changed files with 46 additions and 54,962 deletions.
2 changes: 1 addition & 1 deletion client/docs/statik/statik.go

Large diffs are not rendered by default.

Binary file modified client/docs/swagger-ui/favicon-16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified client/docs/swagger-ui/favicon-32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions client/docs/swagger-ui/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
url: "./swagger.yaml",
dom_id: '#swagger-ui',
deepLinking: true,
queryConfigEnabled: false,
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIStandalonePreset
Expand Down
30 changes: 19 additions & 11 deletions client/docs/swagger-ui/oauth2-redirect.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<!doctype html>
<html lang="en-US">
<body onload="run()">
</body>
</html>
<head>
<title>Swagger UI: OAuth2 Redirect</title>
</head>
<body>
<script>
'use strict';
function run () {
Expand All @@ -17,19 +18,20 @@
qp = location.search.substring(1);
}

arr = qp.split("&")
arr.forEach(function (v,i,_arr) { _arr[i] = '"' + v.replace('=', '":"') + '"';})
arr = qp.split("&");
arr.forEach(function (v,i,_arr) { _arr[i] = '"' + v.replace('=', '":"') + '"';});
qp = qp ? JSON.parse('{' + arr.join() + '}',
function (key, value) {
return key === "" ? value : decodeURIComponent(value)
return key === "" ? value : decodeURIComponent(value);
}
) : {}
) : {};

isValid = qp.state === sentState
isValid = qp.state === sentState;

if ((
oauth2.auth.schema.get("flow") === "accessCode"||
oauth2.auth.schema.get("flow") === "authorizationCode"
oauth2.auth.schema.get("flow") === "accessCode" ||
oauth2.auth.schema.get("flow") === "authorizationCode" ||
oauth2.auth.schema.get("flow") === "authorization_code"
) && !oauth2.auth.code) {
if (!isValid) {
oauth2.errCb({
Expand All @@ -45,7 +47,7 @@
oauth2.auth.code = qp.code;
oauth2.callback({auth: oauth2.auth, redirectUrl: redirectUrl});
} else {
let oauthErrorMsg
let oauthErrorMsg;
if (qp.error) {
oauthErrorMsg = "["+qp.error+"]: " +
(qp.error_description ? qp.error_description+ ". " : "no accessCode received from the server. ") +
Expand All @@ -64,4 +66,10 @@
}
window.close();
}

window.addEventListener('DOMContentLoaded', function () {
run();
});
</script>
</body>
</html>
Loading

0 comments on commit 4e9d3bc

Please sign in to comment.