Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Swagger UI Koa 2

Forked from [swagger-ui-express](https://github.com/scottie1984/swagger-ui-express)
Forked from [swagger-ui-express](https://github.com/Darmikon/swagger-ui-koa)

Adds middleware to your koa app to serve the Swagger UI bound to your Swagger document. This acts as living documentation for your API hosted from within your app.

Updated to Swagger 3.0.17
Updated to Swagger 3.52.3

## Usage

Expand Down
2 changes: 1 addition & 1 deletion indexTemplate.html
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,4 @@
</style>
</body>

</html>
</html>
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "swagger-ui-koa",
"version": "0.0.1",
"description": "Swagger UI Koa",
"name": "swagger-ui-for-koa",
"version": "0.0.3",
"description": "Swagger UI For Koa",
"main": "./lib/index.js",
"files": [
"static",
Expand All @@ -27,17 +27,17 @@
"koa-static": "^3.0.0"
},
"author": {
"name": "Darmikon",
"email": "hellfrom@mail.ru"
"name": "Marius",
"email": "marius@osethconsult.no"
},
"repository": {
"type": "git",
"url": "git@github.com:Darmikon/swagger-ui-koa.git"
"url": "git@github.com:mariuso/swagger-ui-koa.git"
},
"license": "MIT",
"readmeFilename": "README.md",
"bugs": {
"url": "https://github.com/scottie1984/swagger-ui-koa/issues"
"url": "https://github.com/mariuso/swagger-ui-koa/issues"
},
"homepage": "https://github.com/Darmikon/swagger-ui-koa"
"homepage": "https://github.com/mariuso/swagger-ui-koa"
}
Binary file modified static/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 static/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.
44 changes: 33 additions & 11 deletions static/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 @@ -11,19 +12,27 @@
var redirectUrl = oauth2.redirectUrl;
var isValid, qp, arr;

qp = (window.location.hash || location.search).substring(1);
if (/code|token|error/.test(window.location.hash)) {
qp = window.location.hash.substring(1);
} else {
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.code) {
if ((
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({
authId: oauth2.auth.name,
Expand All @@ -38,16 +47,29 @@
oauth2.auth.code = qp.code;
oauth2.callback({auth: oauth2.auth, redirectUrl: redirectUrl});
} else {
let oauthErrorMsg;
if (qp.error) {
oauthErrorMsg = "["+qp.error+"]: " +
(qp.error_description ? qp.error_description+ ". " : "no accessCode received from the server. ") +
(qp.error_uri ? "More info: "+qp.error_uri : "");
}

oauth2.errCb({
authId: oauth2.auth.name,
source: "auth",
level: "error",
message: "Authorization failed: no accessCode received from the server"
message: oauthErrorMsg || "[Authorization failed]: no accessCode received from the server"
});
}
} else {
oauth2.callback({auth: oauth2.auth, token: qp, isValid: isValid, redirectUrl: redirectUrl});
}
window.close();
}

window.addEventListener('DOMContentLoaded', function () {
run();
});
</script>
</body>
</html>
106 changes: 2 additions & 104 deletions static/swagger-ui-bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion static/swagger-ui-bundle.js.map

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions static/swagger-ui-es-bundle-core.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions static/swagger-ui-es-bundle-core.js.map

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions static/swagger-ui-es-bundle.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions static/swagger-ui-es-bundle.js.map

Large diffs are not rendered by default.

22 changes: 2 additions & 20 deletions static/swagger-ui-standalone-preset.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion static/swagger-ui-standalone-preset.js.map

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion static/swagger-ui.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion static/swagger-ui.css.map

Large diffs are not rendered by default.

16 changes: 2 additions & 14 deletions static/swagger-ui.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion static/swagger-ui.js.map

Large diffs are not rendered by default.