-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(agora): add OpenAPI description and docs site (#2766)
- Loading branch information
1 parent
7643b94
commit 0313887
Showing
27 changed files
with
511 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
PORT=8010 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
FROM redocly/redoc:v2.0.0 | ||
|
||
HEALTHCHECK --interval=2s --timeout=3s --retries=5 --start-period=2s \ | ||
CMD curl --fail --silent "localhost:8010" || exit 1 | ||
|
||
COPY build/redoc-static.html /usr/share/nginx/html/index.html | ||
COPY favicon.ico /usr/share/nginx/html/ | ||
|
||
EXPOSE 8010 |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<html> | ||
<head> | ||
<meta charset='utf8' /> | ||
<title>{{title}}</title> | ||
<!-- needed for adaptive design --> | ||
{{!-- <meta description='{{{templateOptions.metaDescription}}}' /> --}} | ||
<meta name='viewport' content='width=device-width, initial-scale=1' /> | ||
<style> | ||
body { padding: 0; margin: 0; } | ||
</style> | ||
{{{redocHead}}} | ||
{{#unless disableGoogleFont}}<link | ||
href='https://fonts.googleapis.com/css?family=Montserrat:300,400,700|Roboto:300,400,700' | ||
rel='stylesheet' | ||
/>{{/unless}} | ||
</head> | ||
<body> | ||
{{{redocHTML}}} | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
{ | ||
"name": "agora-api-docs", | ||
"$schema": "../../../node_modules/nx/schemas/project-schema.json", | ||
"projectType": "application", | ||
"targets": { | ||
"create-config": { | ||
"executor": "nx:run-commands", | ||
"options": { | ||
"command": "cp -n .env.example .env", | ||
"cwd": "{projectRoot}" | ||
} | ||
}, | ||
"build": { | ||
"executor": "nx:run-commands", | ||
"options": { | ||
"command": "redocly build-docs --config redocly.yaml --template index.hbs --output build/redoc-static.html", | ||
"cwd": "{projectRoot}" | ||
} | ||
}, | ||
"serve": { | ||
"executor": "nx:run-commands", | ||
"options": { | ||
"command": "redocly preview-docs --config redocly.yaml --port 8010", | ||
"cwd": "{projectRoot}" | ||
} | ||
}, | ||
"serve-detach": { | ||
"executor": "nx:run-commands", | ||
"options": { | ||
"command": "docker/agora/serve-detach.sh agora-api-docs" | ||
} | ||
}, | ||
"build-image": { | ||
"executor": "@nx-tools/nx-container:build", | ||
"options": { | ||
"context": "apps/agora/api-docs", | ||
"metadata": { | ||
"images": [ | ||
"ghcr.io/sage-bionetworks/agora-api-docs" | ||
], | ||
"tags": [ | ||
"type=edge,branch=main", | ||
"type=raw,value=local", | ||
"type=sha" | ||
] | ||
}, | ||
"push": false | ||
}, | ||
"dependsOn": [ | ||
"build" | ||
] | ||
}, | ||
"publish-image": { | ||
"executor": "@nx-tools/nx-container:build", | ||
"options": { | ||
"context": "apps/agora/api-docs", | ||
"metadata": { | ||
"images": [ | ||
"ghcr.io/sage-bionetworks/agora-api-docs" | ||
], | ||
"tags": [ | ||
"type=edge,branch=main", | ||
"type=sha" | ||
] | ||
}, | ||
"push": true | ||
}, | ||
"dependsOn": [ | ||
"build-image" | ||
] | ||
}, | ||
"scan-image": { | ||
"executor": "nx:run-commands", | ||
"options": { | ||
"command": "trivy image ghcr.io/sage-bionetworks/agora-api-docs:local --quiet", | ||
"color": true | ||
} | ||
} | ||
}, | ||
"tags": [ | ||
"type:docs", | ||
"scope:backend" | ||
], | ||
"implicitDependencies": [ | ||
"agora-api-description" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# See https://docs.redoc.ly/cli/configuration/ for more information. | ||
apis: | ||
main: | ||
root: '../../../libs/agora/api-description/build/openapi.yaml' | ||
# theme: | ||
# openapi: | ||
# theme: | ||
# rightPanel: | ||
# backgroundColor: '#314fa7' | ||
# sidebar: | ||
# backgroundColor: '#ffffff' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
services: | ||
agora-api-docs: | ||
image: ghcr.io/sage-bionetworks/agora-api-docs:${AGORA_VERSION:-local} | ||
container_name: agora-api-docs | ||
restart: always | ||
env_file: | ||
- ../../../apps/agora/api-docs/.env | ||
networks: | ||
- agora | ||
ports: | ||
- '8010:8010' | ||
deploy: | ||
resources: | ||
limits: | ||
memory: 200M |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
!build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# api-spec | ||
|
||
This library was generated with [Nx](https://nx.dev). | ||
|
||
## Running unit tests | ||
|
||
Run `nx test api-spec` to execute the unit tests. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
openapi: 3.0.3 | ||
info: | ||
version: 1.0.0 | ||
title: Agora REST API | ||
license: | ||
name: Apache 2.0 | ||
url: https://github.com/Sage-Bionetworks/sage-monorepo/blob/main/LICENSE.txt | ||
contact: | ||
name: Support | ||
url: https://github.com/Sage-Bionetworks/sage-monorepo | ||
x-logo: | ||
url: https://dev.openchallenges.io/img/unsafe/logo/OpenChallenges-logo.png | ||
servers: | ||
- url: http://localhost/v1 | ||
tags: | ||
- name: Dataversion | ||
description: Operations about dataversion. | ||
paths: | ||
/dataversion: | ||
get: | ||
tags: | ||
- Dataversion | ||
summary: Get dataversion | ||
description: Get dataversion | ||
operationId: getDataversion | ||
responses: | ||
'200': | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/Dataversion' | ||
description: Success | ||
'400': | ||
$ref: '#/components/responses/BadRequest' | ||
'500': | ||
$ref: '#/components/responses/InternalServerError' | ||
components: | ||
schemas: | ||
Dataversion: | ||
type: object | ||
description: A dataversion | ||
properties: | ||
data_file: | ||
type: string | ||
data_version: | ||
type: string | ||
team_images_id: | ||
type: string | ||
required: | ||
- data_file | ||
- data_version | ||
- team_images_id | ||
BasicError: | ||
type: object | ||
description: Problem details (tools.ietf.org/html/rfc7807) | ||
properties: | ||
title: | ||
type: string | ||
description: A human readable documentation for the problem type | ||
status: | ||
type: integer | ||
description: The HTTP status code | ||
detail: | ||
type: string | ||
description: A human readable explanation specific to this occurrence of the problem | ||
type: | ||
type: string | ||
description: An absolute URI that identifies the problem type | ||
required: | ||
- title | ||
- status | ||
x-java-class-annotations: | ||
- '@lombok.AllArgsConstructor' | ||
- '@lombok.Builder' | ||
responses: | ||
BadRequest: | ||
description: Invalid request | ||
content: | ||
application/problem+json: | ||
schema: | ||
$ref: '#/components/schemas/BasicError' | ||
InternalServerError: | ||
description: The request cannot be fulfilled due to an unexpected server error | ||
content: | ||
application/problem+json: | ||
schema: | ||
$ref: '#/components/schemas/BasicError' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
errorsOnly: true | ||
summaryOnly: false | ||
limits: | ||
warnings: 25 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{ | ||
"name": "agora-api-description", | ||
"$schema": "../../../node_modules/nx/schemas/project-schema.json", | ||
"sourceRoot": "libs/agora/api-description/src", | ||
"projectType": "library", | ||
"targets": { | ||
"build": { | ||
"executor": "nx:run-commands", | ||
"options": { | ||
"command": "redocly bundle --output build/openapi.yaml src/openapi.yaml", | ||
"cwd": "{projectRoot}" | ||
} | ||
}, | ||
"lint": { | ||
"executor": "nx:run-commands", | ||
"options": { | ||
"command": "lint-openapi --config openapi-lint-config.yaml --ruleset spectral.yaml build/openapi.yaml", | ||
"cwd": "{projectRoot}" | ||
}, | ||
"dependsOn": ["build"] | ||
}, | ||
"format": { | ||
"executor": "nx:run-commands", | ||
"options": { | ||
"command": "prettier --write {projectRoot}" | ||
} | ||
}, | ||
"format-check": { | ||
"executor": "nx:run-commands", | ||
"options": { | ||
"command": "prettier --check {projectRoot}" | ||
} | ||
} | ||
}, | ||
"tags": [], | ||
"implicitDependencies": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
extends: '@ibm-cloud/openapi-ruleset' | ||
rules: | ||
ibm-enum-casing-convention: off | ||
ibm-parameter-casing-convention: off | ||
ibm-path-segment-casing-convention: off | ||
ibm-property-casing-convention: off |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Reusable components | ||
|
||
- You can create the following folders here: | ||
- `schemas` - reusable [Schema Objects](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#schemaObject) | ||
- `responses` - reusable [Response Objects](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#responseObject) | ||
- `parameters` - reusable [Parameter Objects](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#parameterObject) | ||
- `examples` - reusable [Example Objects](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#exampleObject) | ||
- `headers` - reusable [Header Objects](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#headerObject) | ||
- `requestBodies` - reusable [Request Body Objects](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#requestBodyObject) | ||
- `links` - reusable [Link Objects](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#linkObject) | ||
- `callbacks` - reusable [Callback Objects](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#callbackObject) | ||
- `securitySchemes` - reusable [Security Scheme Objects](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#securitySchemeObject) | ||
- Filename of files inside the folders represent component name, e.g. `Customer.yaml` |
4 changes: 4 additions & 0 deletions
4
libs/agora/api-description/src/components/headers/ExpiresAfter.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
description: date in UTC when token expires | ||
schema: | ||
type: string | ||
format: date-time |
5 changes: 5 additions & 0 deletions
5
libs/agora/api-description/src/components/responses/BadRequest.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
description: Invalid request | ||
content: | ||
application/problem+json: | ||
schema: | ||
$ref: ../schemas/BasicError.yaml |
5 changes: 5 additions & 0 deletions
5
libs/agora/api-description/src/components/responses/Conflict.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
description: The request conflicts with current state of the target resource | ||
content: | ||
application/problem+json: | ||
schema: | ||
$ref: ../schemas/BasicError.yaml |
5 changes: 5 additions & 0 deletions
5
libs/agora/api-description/src/components/responses/InternalServerError.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
description: The request cannot be fulfilled due to an unexpected server error | ||
content: | ||
application/problem+json: | ||
schema: | ||
$ref: ../schemas/BasicError.yaml |
5 changes: 5 additions & 0 deletions
5
libs/agora/api-description/src/components/responses/NotFound.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
description: The specified resource was not found | ||
content: | ||
application/problem+json: | ||
schema: | ||
$ref: ../schemas/BasicError.yaml |
5 changes: 5 additions & 0 deletions
5
libs/agora/api-description/src/components/responses/Unauthorized.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
description: Unauthorized | ||
content: | ||
application/problem+json: | ||
schema: | ||
$ref: ../schemas/BasicError.yaml |
22 changes: 22 additions & 0 deletions
22
libs/agora/api-description/src/components/schemas/BasicError.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
type: object | ||
description: Problem details (tools.ietf.org/html/rfc7807) | ||
properties: | ||
title: | ||
type: string | ||
description: A human readable documentation for the problem type | ||
status: | ||
type: integer | ||
description: The HTTP status code | ||
detail: | ||
type: string | ||
description: A human readable explanation specific to this occurrence of | ||
the problem | ||
type: | ||
type: string | ||
description: An absolute URI that identifies the problem type | ||
required: | ||
- title | ||
- status | ||
x-java-class-annotations: | ||
- '@lombok.AllArgsConstructor' | ||
- '@lombok.Builder' |
13 changes: 13 additions & 0 deletions
13
libs/agora/api-description/src/components/schemas/Dataversion.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
type: object | ||
description: A dataversion | ||
properties: | ||
data_file: | ||
type: string | ||
data_version: | ||
type: string | ||
team_images_id: | ||
type: string | ||
required: | ||
- data_file | ||
- data_version | ||
- team_images_id |
2 changes: 2 additions & 0 deletions
2
libs/agora/api-description/src/components/schemas/EmptyObject.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
type: object | ||
description: Empty JSON object |
Oops, something went wrong.