Skip to content

Commit

Permalink
Merge pull request #9 from Game-as-a-Service/doc/api-ref-site
Browse files Browse the repository at this point in the history
Doc/api ref site
  • Loading branch information
wingtkw authored Oct 24, 2023
2 parents 9b1154d + d61d4e0 commit 8c12619
Show file tree
Hide file tree
Showing 21 changed files with 360 additions and 0 deletions.
Binary file added doc/api/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 doc/api/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.
16 changes: 16 additions & 0 deletions doc/api/dist/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
html {
box-sizing: border-box;
overflow: -moz-scrollbars-vertical;
overflow-y: scroll;
}

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

body {
margin: 0;
background: #fafafa;
}
79 changes: 79 additions & 0 deletions doc/api/dist/oauth2-redirect.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<!doctype html>
<html lang="en-US">
<head>
<title>Swagger UI: OAuth2 Redirect</title>
</head>
<body>
<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).replace('?', '&');
} 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.schema.get("flow") === "authorization_code"
) && !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. The 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();
}

if (document.readyState !== 'loading') {
run();
} else {
document.addEventListener('DOMContentLoaded', function () {
run();
});
}
</script>
</body>
</html>
20 changes: 20 additions & 0 deletions doc/api/dist/swagger-initializer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
window.onload = function() {
//<editor-fold desc="Changeable Configuration Block">

// the following lines will be replaced by docker/configurator, when it runs in a docker-container
window.ui = SwaggerUIBundle({
url: "swagger.yaml",
dom_id: '#swagger-ui',
deepLinking: true,
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIStandalonePreset
],
plugins: [
SwaggerUIBundle.plugins.DownloadUrl
],
layout: "StandaloneLayout"
});

//</editor-fold>
};
3 changes: 3 additions & 0 deletions doc/api/dist/swagger-ui-bundle.js

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions doc/api/dist/swagger-ui-es-bundle.js

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions doc/api/dist/swagger-ui-standalone-preset.js

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions doc/api/dist/swagger-ui.css

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions doc/api/dist/swagger-ui.js

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions doc/api/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!-- HTML for static distribution bundle build -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Swagger UI</title>
<link rel="stylesheet" type="text/css" href="dist/swagger-ui.css" />
<link rel="stylesheet" type="text/css" href="dist/index.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" />
</head>

<body>
<div id="swagger-ui"></div>
<script src="dist/swagger-ui-bundle.js" charset="UTF-8"> </script>
<script src="dist/swagger-ui-standalone-preset.js" charset="UTF-8"> </script>
<script src="dist/swagger-initializer.js" charset="UTF-8"> </script>
</body>
</html>
1 change: 1 addition & 0 deletions doc/api/swagger-ui.version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v5.9.0
148 changes: 148 additions & 0 deletions doc/api/swagger.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
openapi: 3.0.3
info:
title: Pandemic - Reign of Cthulhu
version: 1.0.0
externalDocs:
description: Discussion Docs
url: https://miro.com/app/board/uXjVMO8BrcQ=/?share_link_id=645659989265
servers:
- url: https://petstore3.swagger.io/api/v3
tags:
- name: init
- name: investigator
- name: action
security:
- bearerAuth: []

paths:
/games:
post:
summary: Create / initialize a new game
operationId: createGame
tags:
- init
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/CreateGameReq"
required: true
responses:
"200":
description: Successful operation
content:
application/json:
schema:
$ref: "#/components/schemas/CreateGameRes"

/games/{gameId}/investigator/order:
get:
summary: Get random users order in choosing the investigator
operationId: findGameInvestigatorOrder
tags:
- init
- investigator
parameters:
- in: path
name: gameId
schema:
type: string
format: uuid
required: true
responses:
"200":
description: Successful operation
content:
application/json:
schema:
$ref: "#/components/schemas/FindGameInvestigatorOrderRes"

/games/{gameId}/investigator:
get:
summary: Get 2 investigators that are not yet chosen by users
operationId: findGameInvestigator
tags:
- init
- investigator
parameters:
- in: path
name: gameId
schema:
type: string
format: uuid
required: true
responses:
"200":
description: Successful operation
content:
application/json:
schema:
$ref: "#/components/schemas/FindGameInvestigatorRes"

components:
schemas:
CreateGameReq:
type: object
properties:
players:
type: array
items:
$ref: "#/components/schemas/Player"
CreateGameRes:
type: object
properties:
url:
type: string
FindGameInvestigatorOrderRes:
type: array
items:
$ref: "#/components/schemas/PlayerOrder"
FindGameInvestigatorRes:
type: array
items:
type: object
properties:
investigator:
$ref: "#/components/schemas/Investigator"

Player:
type: object
properties:
id:
type: string
format: uuid
nickname:
type: string
PlayerOrder:
type: object
properties:
user_id:
type: string
format: uuid
order:
type: integer

Investigator:
type: string
enum:
- detective
- doctor
- driver
- hunter
- magician
- occultist
- reporter

Clue:
type: string
enum:
- arkham
- dunwich
- kingsport
- innsmouth

securitySchemes:
bearerAuth: # arbitrary name for the security scheme
type: http
scheme: bearer
bearerFormat: JWT # optional, arbitrary value for documentation purposes
54 changes: 54 additions & 0 deletions doc/api/workflows/update-swagger.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Update Swagger UI
on:
schedule:
- cron: '0 10 * * *'
workflow_dispatch:

jobs:
updateSwagger:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Get Latest Swagger UI Release
id: swagger-ui
run: |
release_tag=$(curl -sL https://api.github.com/repos/swagger-api/swagger-ui/releases/latest | jq -r ".tag_name")
echo "release_tag=$release_tag" >> $GITHUB_OUTPUT
current_tag=$(<swagger-ui.version)
echo "current_tag=$current_tag" >> $GITHUB_OUTPUT
- name: Update Swagger UI
if: steps.swagger-ui.outputs.current_tag != steps.swagger-ui.outputs.release_tag
env:
RELEASE_TAG: ${{ steps.swagger-ui.outputs.release_tag }}
SWAGGER_YAML: "swagger.yaml"
run: |
# Delete the dist directory and index.html
rm -fr dist index.html
# Download the release
curl -sL -o $RELEASE_TAG https://api.github.com/repos/swagger-api/swagger-ui/tarball/$RELEASE_TAG
# Extract the dist directory
tar -xzf $RELEASE_TAG --strip-components=1 $(tar -tzf $RELEASE_TAG | head -1 | cut -f1 -d"/")/dist
rm $RELEASE_TAG
# Move index.html to the root
mv dist/index.html .
# Fix references in dist/swagger-initializer and index.html
sed -i "s|https://petstore.swagger.io/v2/swagger.json|$SWAGGER_YAML|g" dist/swagger-initializer.js
sed -i "s|href=\"./|href=\"dist/|g" index.html
sed -i "s|src=\"./|src=\"dist/|g" index.html
sed -i "s|href=\"index|href=\"dist/index|g" index.html
# Update current release
echo ${{ steps.swagger-ui.outputs.release_tag }} > swagger-ui.version
- name: Create Pull Request
uses: peter-evans/create-pull-request@v4
with:
commit-message: Update swagger-ui to ${{ steps.swagger-ui.outputs.release_tag }}
title: Update SwaggerUI to ${{ steps.swagger-ui.outputs.release_tag }}
body: |
Updates [swagger-ui][1] to ${{ steps.swagger-ui.outputs.release_tag }}
Auto-generated by [create-pull-request][2]
[1]: https://github.com/swagger-api/swagger-ui
[2]: https://github.com/peter-evans/create-pull-request
labels: dependencies, automated pr
branch: swagger-ui-updates

0 comments on commit 8c12619

Please sign in to comment.