Skip to content

Commit

Permalink
Merge pull request #34 from ywalakamar/chore/host-swagger-api-doc-gh-…
Browse files Browse the repository at this point in the history
…pages

Host the API docs in Github Pages
  • Loading branch information
maxwelbarno authored Dec 18, 2019
2 parents 732a6ea + 790a2f4 commit de01989
Show file tree
Hide file tree
Showing 14 changed files with 477 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ typings/

# Nuxt.js build / generate output
.nuxt
dist
#dist

# Gatsby files
.cache/
Expand Down
Binary file added dist/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 added dist/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.
68 changes: 68 additions & 0 deletions dist/oauth2-redirect.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<!doctype html>
<html lang="en-US">
<title>Swagger UI: OAuth2 Redirect</title>
<body onload="run()">
</body>
</html>
<script>
'use strict';
function run () {
var oauth2 = window.opener.swaggerUIRedirectOauth2;
var sentState = oauth2.state;
var redirectUrl = oauth2.redirectUrl;
var isValid, qp, arr;

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('=', '":"') + '"';})
qp = qp ? JSON.parse('{' + arr.join() + '}',
function (key, value) {
return key === "" ? value : decodeURIComponent(value)
}
) : {}

isValid = qp.state === sentState

if ((
oauth2.auth.schema.get("flow") === "accessCode"||
oauth2.auth.schema.get("flow") === "authorizationCode"
) && !oauth2.auth.code) {
if (!isValid) {
oauth2.errCb({
authId: oauth2.auth.name,
source: "auth",
level: "warning",
message: "Authorization may be unsafe, passed state was changed in server Passed state wasn't returned from auth server"
});
}

if (qp.code) {
delete oauth2.state;
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: oauthErrorMsg || "[Authorization failed]: no accessCode received from the server"
});
}
} else {
oauth2.callback({auth: oauth2.auth, token: qp, isValid: isValid, redirectUrl: redirectUrl});
}
window.close();
}
</script>
134 changes: 134 additions & 0 deletions dist/swagger-ui-bundle.js

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

22 changes: 22 additions & 0 deletions dist/swagger-ui-standalone-preset.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/swagger-ui-standalone-preset.js.map

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions dist/swagger-ui.css

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/swagger-ui.css.map

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions dist/swagger-ui.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/swagger-ui.js.map

Large diffs are not rendered by default.

60 changes: 60 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<!-- HTML for static distribution bundle build -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Auctioneer API Docs</title>
<link rel="stylesheet" type="text/css" href="./dist/swagger-ui.css" >
<link rel="icon" type="image/png" href="./dist/favicon-32x32.png" sizes="32x32" />
<link rel="icon" type="image/png" href="./dist/favicon-16x16.png" sizes="16x16" />
<style>
html
{
box-sizing: border-box;
overflow: -moz-scrollbars-vertical;
overflow-y: scroll;
}

*,
*:before,
*:after
{
box-sizing: inherit;
}

body
{
margin:0;
background: #fafafa;
}
</style>
</head>

<body>
<div id="swagger-ui"></div>

<script src="./dist/swagger-ui-bundle.js"> </script>
<script src="./dist/swagger-ui-standalone-preset.js"> </script>
<script>
window.onload = function() {
// Begin Swagger UI call region
const ui = SwaggerUIBundle({
url: "swagger.json",
dom_id: '#swagger-ui',
deepLinking: true,
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIStandalonePreset
],
plugins: [
SwaggerUIBundle.plugins.DownloadUrl
],
layout: "StandaloneLayout"
})
// End Swagger UI call region

window.ui = ui
}
</script>
</body>
</html>
175 changes: 175 additions & 0 deletions swagger.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
{
"swagger": "2.0",
"info": {
"description": "An Auctioneering System API documetation by Kipruto Barno",
"version": "1.0.0",
"title": "Auctioneering System",
"contact": {
"email": "[email protected]"
},
"license": {
"name": "MIT",
"url": "https://opensource.org/licenses/MIT"
}
},
"host": "e25af10e.ngrok.io",
"basePath": "/api/v1",
"schemes": ["https"],
"securityDefinitions": {
"Bearer": {
"type": "apiKey",
"name": "Authorization",
"in": "header"
}
},
"paths": {
"/register": {
"post": {
"tags": ["Register"],
"summary": "Create user",
"description": "Creates the auctioneering system administrator",
"operationId": "createUser",
"produces": ["application/json"],
"parameters": [
{
"in": "body",
"name": "body",
"description": "User registration request body",
"required": true,
"schema": {
"$ref": "#/definitions/User"
}
}
],
"responses": {
"201": {
"description": "Created"
},
"409": {
"description": "User already registered"
}
}
}
},
"/login": {
"post": {
"tags": ["Login"],
"summary": "User login",
"description": "System administrator user login",
"operationId": "loginUser",
"produces": ["application/json"],
"parameters": [
{
"in": "body",
"name": "body",
"description": "User login request body",
"required": true,
"schema": {
"$ref": "#/definitions/User"
}
}
],
"responses": {
"200": {
"description": "Success"
},
"400": {
"description": "Missing email or password"
}
}
}
},
"/owners": {
"get": {
"security": [
{
"Bearer": []
}
],
"tags": ["Get Owners"],
"summary": "Get all owners",
"description": "Retrieves all registered item owners",
"operationId": "getOwners",
"produces": ["application/json"],
"responses": {
"200": {
"description": "OK"
},
"401": {
"description": "Unauthorized"
}
}
},
"post": {
"security": [
{
"Bearer": []
}
],
"tags": ["Create Owner"],
"summary": "Create owner",
"description": "Creates the owner of the items to be auctioned",
"operationId": "CreateOwner",
"produces": ["application/json"],
"parameters": [
{
"in": "body",
"name": "body",
"description": "Created user object",
"required": true,
"schema": {
"$ref": "#/definitions/Owner"
}
}
],
"responses": {
"201": {
"description": "Created"
},
"401": {
"description": "Unauthorized"
},
"409": {
"description": "Owner already registered"
}
}
}
}
},
"definitions": {
"User": {
"title": "User",
"description": "A User who manages the Auctioneer System",
"type": "object",
"properties": {
"email": {
"type": "string",
"description": "Must be a valid email address"
},
"password": {
"type": "string",
"description": "An alphanumeric string that can also contain special characters"
}
}
},
"Owner": {
"title": "Owner",
"description": "The owner who owns auction items",
"type": "object",
"properties": {
"firstName": {
"type": "string",
"description": "User's first name"
},
"lastName": {
"type": "string",
"description": "User's last name"
},
"email": {
"type": "string",
"description": "A valid email address"
}
}
}
}
}

0 comments on commit de01989

Please sign in to comment.