feat: openapi spec

This commit is contained in:
Aravinth Manivannan 2022-12-11 23:42:46 +05:30
parent b8246f0fd8
commit a38411abaa
Signed by: realaravinth
GPG key ID: AD9F0F08E855ED88
19 changed files with 335 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 665 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 628 B

16
docs/openapi/index.css Normal file
View file

@ -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;
}

19
docs/openapi/index.html Normal file
View file

@ -0,0 +1,19 @@
<!-- HTML for static distribution bundle build -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>LibrePages Conductor | Swagger UI</title>
<link rel="stylesheet" type="text/css" href="/docs/openapi/swagger-ui.css" />
<link rel="stylesheet" type="text/css" href="/docs/openapi/index.css" />
<link rel="icon" type="image/png" href="/docs/openapi/favicon-32x32.png" sizes="32x32" />
<link rel="icon" type="image/png" href="/docs/openapi/favicon-16x16.png" sizes="16x16" />
</head>
<body>
<div id="swagger-ui"></div>
<script src="/docs/openapi/swagger-ui-bundle.js" charset="UTF-8"> </script>
<script src="/docs/openapi/swagger-ui-standalone-preset.js" charset="UTF-8"> </script>
<script src="/docs/openapi/swagger-initializer.js" charset="UTF-8"> </script>
</body>
</html>

View file

@ -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>

178
docs/openapi/openapi.yml Normal file
View file

@ -0,0 +1,178 @@
openapi: 3.0.3
info:
title: LibrePages Conductor - OpenAPI 3.0
description: |-
Conductor is the deployment manager used internally in LibrePages. It is
responsible for creating, updating and deleting websites that are deployed
with LibrePages
Some useful links:
- [LibrePages Conductor repository](https://git.batsense.net/LibrePages/conductor)
termsOfService: http://libreapages.org/terms/
contact:
email: contact@libreapages.org
license:
name: AGPLv3 or later version
url: https://www.gnu.org/licenses/agpl.html
version: 0.1.0
externalDocs:
description: LibrePages Conductor - internal service to update deployments
url: http://git.batsense.net/LibrePages/conductor
tags:
- name: meta
description: Information about the system
- name: site
description: Information about customer site deployments
paths:
/api/v1/events/new:
post:
tags:
- site
summary: Post new event to Conductor
description: Conductor schedules jobs based on events posted to it.
operationId: eventsNew
responses:
"201":
description: Successful operation
content:
application/json:
schema:
oneOf:
- $ref: "#/components/schemas/eventsNewPayloadNewSite"
- $ref: "#/components/schemas/eventsNewPayloadConfig"
- $ref: "#/components/schemas/eventsNewPayloadDeleteSite"
/api/v1/meta/build:
get:
tags:
- meta
summary: Get binary's build information
description: Update an existing pet by Idinformation
operationId: metaBuild
responses:
"200":
description: Successful operation
content:
application/json:
schema:
$ref: "#/components/schemas/BuildInformation"
/api/v1/meta/health:
get:
tags:
- meta
summary: Get instance's health information
description: Get instance's health information
operationId: metaHealth
responses:
"200":
description: Successful operation
content:
application/json:
schema:
$ref: "#/components/schemas/HealthInformation"
components:
schemas:
BuildInformation:
required:
- version
- git_commit_hash
- source_code
type: object
properties:
version:
type: string
example: v0.1.0
git_commit_hash:
type: string
example: 1fa28ef9b70bb04d6c76eee9e9bc5be77005b4b0
source_code:
type: string
example: https://git.batsense.net/LibrePages
HealthInformation:
required:
- conductor
type: object
properties:
conductor:
type: boolean
example: true
eventsNewPayloadConfig:
type: object
required:
- data
properties:
data:
$ref: '#/components/schemas/LibConfigConfig'
LibConfigConfig:
properties:
source:
$ref: '#/components/schemas/LibConfigSource'
forms:
$ref: '#/components/schemas/LibConfigForms'
domains:
type: array
items:
type: string
example: ["example.com", "testing.example.org"]
image_compression:
$ref: '#/components/schemas/LibConfigImageCompression'
redirects:
$ref: '#/components/schemas/LibConfigRedirects'
LibConfigSource:
properties:
production_branch:
type: string
example: "librepages"
staging_branch:
type: string
example: "librepages-staging"
LibConfigForms:
properties:
enabled:
type: boolean
example: false
LibConfigImageCompression:
properties:
enabled:
type: boolean
example: false
LibConfigRedirects:
properties:
from:
type: string
example: "/from"
to:
type: string
example: "/to"
eventsNewPayloadNewSite:
properties:
hostname:
type: string
example: "example.org"
path:
type: string
example: "/tmp/example.org"
branch:
type: string
example: "librepages"
eventsNewPayloadDeleteSite:
properties:
hostname:
type: string
example: "example.org"
securitySchemes:
basicAuth:
type: http
scheme: basic

View file

@ -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: "/docs/openapi/openapi.yml",
dom_id: '#swagger-ui',
deepLinking: true,
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIStandalonePreset
],
plugins: [
SwaggerUIBundle.plugins.DownloadUrl
],
layout: "StandaloneLayout"
});
//</editor-fold>
};

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long