diff --git a/components/responses/HealthCheckFail.yaml b/components/responses/HealthCheckFail.yaml new file mode 100644 index 0000000..2472e8a --- /dev/null +++ b/components/responses/HealthCheckFail.yaml @@ -0,0 +1,10 @@ +# SPDX-FileCopyrightText: 2024 Sidings Media +# SPDX-License-Identifier: MIT + +description: Service is unhealthy +content: + text/plain: + schema: + type: string + example: + unhealthy diff --git a/components/responses/HealthCheckOK.yaml b/components/responses/HealthCheckOK.yaml new file mode 100644 index 0000000..b8b62b6 --- /dev/null +++ b/components/responses/HealthCheckOK.yaml @@ -0,0 +1,10 @@ +# SPDX-FileCopyrightText: 2024 Sidings Media +# SPDX-License-Identifier: MIT + +description: Service is healthy +content: + text/plain: + schema: + type: string + example: + healthy diff --git a/conf/conf.d/default.conf b/conf/conf.d/default.conf index 1b207ab..a04e12e 100644 --- a/conf/conf.d/default.conf +++ b/conf/conf.d/default.conf @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: 2023 Sidings Media +# SPDX-FileCopyrightText: 2023-2024 Sidings Media # SPDX-License-Identifier: CC0-1.0 server { @@ -16,12 +16,7 @@ server { alias /usr/share/nginx/html/openapi.json; } - location = /docs { - default_type "text/html"; - alias /usr/share/nginx/html/openapi.html; - } - - location /health { + location /openapi/health { return 200 "healthy\n"; default_type "text/plain"; } diff --git a/openapi.yaml b/openapi.yaml index 3077c94..9f67401 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: 2023 Sidings Media +# SPDX-FileCopyrightText: 2023-2024 Sidings Media # SPDX-License-Identifier: MIT openapi: 3.0.3 @@ -26,12 +26,12 @@ info: | Path Base | Service Name | Repository | |---|---|---| | `/messaging` | `messaging` | https://github.com/SidingsMedia/messaging.git | - | `/stats` | `stats` | https://github.com/SidingsMedia/stats.git | | `/terms` | `static` | https://github.com/SidingsMedia/static.git | + | `/openapi` | `openapi` | https://github.com/SidingsMedia/openapi.git | | `/openapi.json` | `openapi` | https://github.com/SidingsMedia/openapi.git | Each service will expose a health check endpoint that will return a - plaintext `200 OK` response when called. This is documented by the + plaintext `200 OK` response when called. This is documented by this specification. ## Operation @@ -53,7 +53,7 @@ info: that do implement a rate limit, you will receive a http `429` response with the `retry-after` header set indicating after how many seconds you should restart making requests. - version: 0.2.1 + version: 0.3.0 servers: - url: https://api.sidingsmedia.com/ @@ -74,9 +74,14 @@ tags: paths: /messaging/contact: $ref: paths/messaging/contact.yaml - - /stats/views: - $ref: paths/stats/views.yaml + /messaging/health: + $ref: paths/messaging/health.yaml + + /openapi/health: + $ref: paths/openapi/health.yaml + + /static/health: + $ref: paths/static/health.yaml /terms: $ref: paths/terms.yaml diff --git a/package.json b/package.json index 5192529..215779c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "openapi", - "version": "0.1.0", + "version": "0.3.0", "description": "API documentation for the Sidings Media API", "main": "index.js", "scripts": { diff --git a/paths/messaging/health.yaml b/paths/messaging/health.yaml new file mode 100644 index 0000000..34035e6 --- /dev/null +++ b/paths/messaging/health.yaml @@ -0,0 +1,15 @@ +# SPDX-FileCopyrightText: 2024 Sidings Media +# SPDX-License-Identifier: MIT + +get: + description: Messaging service health check + summary: Health check + tags: + - messaging + responses: + '200': + $ref: ../../components/responses/HealthCheckOK.yaml + '429': + $ref: ../../components/responses/TooManyRequests.yaml + 5XX: + $ref: ../../components/responses/HealthCheckFail.yaml \ No newline at end of file diff --git a/paths/openapi/health.yaml b/paths/openapi/health.yaml new file mode 100644 index 0000000..bbefef6 --- /dev/null +++ b/paths/openapi/health.yaml @@ -0,0 +1,15 @@ +# SPDX-FileCopyrightText: 2024 Sidings Media +# SPDX-License-Identifier: MIT + +get: + description: Static service health check + summary: Health check + tags: + - static + responses: + '200': + $ref: ../../components/responses/HealthCheckOK.yaml + '429': + $ref: ../../components/responses/TooManyRequests.yaml + 5XX: + $ref: ../../components/responses/HealthCheckFail.yaml \ No newline at end of file diff --git a/paths/static/health.yaml b/paths/static/health.yaml new file mode 100644 index 0000000..1c02103 --- /dev/null +++ b/paths/static/health.yaml @@ -0,0 +1,15 @@ +# SPDX-FileCopyrightText: 2024 Sidings Media +# SPDX-License-Identifier: MIT + +get: + description: OpenAPI service health check + summary: Health check + tags: + - openapi + responses: + '200': + $ref: ../../components/responses/HealthCheckOK.yaml + '429': + $ref: ../../components/responses/TooManyRequests.yaml + 5XX: + $ref: ../../components/responses/HealthCheckFail.yaml \ No newline at end of file diff --git a/paths/stats/views.yaml b/paths/stats/views.yaml deleted file mode 100644 index 002e0a1..0000000 --- a/paths/stats/views.yaml +++ /dev/null @@ -1,23 +0,0 @@ -# SPDX-FileCopyrightText: 2023 Sidings Media -# SPDX-License-Identifier: MIT - -post: - description: Log a view for a given page - summary: Log view for page - tags: - - stats - requestBody: - required: true - content: - application/json: - schema: - $ref: ../../components/schemas/View.yaml - responses: - '204': - description: Created - '403': - $ref: ../../components/responses/UnrecognizedPage.yaml - '429': - $ref: ../../components/responses/TooManyRequests.yaml - 5XX: - $ref: ../../components/responses/ServerError.yaml diff --git a/paths/terms.yaml b/paths/terms.yaml index 6251479..8211658 100644 --- a/paths/terms.yaml +++ b/paths/terms.yaml @@ -5,7 +5,7 @@ get: description: API terms of use summary: Get API terms of use tags: - - docs + - static responses: '200': description: Terms