[Phase 6] Add scripts/publish-openapi.js and .gitea/workflows/publish-openapi.yaml for RapidAPI spec upload CI #100
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Roadmap reference
MASTER_BUILD_PROMPT §Pipeline 2 — Validate and publish OpenAPI spec to RapidAPI.
Problem
The MASTER_BUILD_PROMPT specifies two artefacts that are missing from the repo:
scripts/publish-openapi.js— Node.js script that uploads each API'sopenapi.yamlto the RapidAPI Platform API using thePUT /v1/apis/{apiId}/versions/{versionId}endpoint..gitea/workflows/publish-openapi.yaml— Gitea Actions workflow that runs Redocly lint on all specs then calls the publish script whenapis/*/openapi.yamlchanges onmain.Without these, updating an OpenAPI spec never propagates to the RapidAPI marketplace listing. Stale docs on RapidAPI = fewer subscribers.
What to do
1. Create
scripts/publish-openapi.jsNode.js script (no extra dependencies beyond
node-fetch+form-data):RAPIDAPI_KEY,ZIP_API_ID,ZIP_VERSION_ID,HOLIDAYS_API_ID,HOLIDAYS_VERSION_ID,AQI_API_ID,AQI_VERSION_IDfrom environment.https://platformapi1.p.rapidapi.com/v1/apis/{apiId}/versions/{versionId}via HTTP PUT withmultipart/form-data.✓ Published {api-name} spec to RapidAPIon success.See MASTER_BUILD_PROMPT §Pipeline 2 for the exact implementation template.
2. Create
.gitea/workflows/publish-openapi.yamlGitea Actions workflow:
Steps:
actions/checkout@v4withfetch-depth: 2actions/setup-node@v4(Node 20)npx @redocly/cli lint apis/*/openapi.yaml— fails pipeline if spec invalidopenapi.yamlfiles:git diff --name-only HEAD~1 HEAD | grep openapi.yamlnode scripts/publish-openapi.jsSecrets required (operator configures once per listing is live on RapidAPI):
RAPIDAPI_PLATFORM_KEY— RapidAPI Platform API bearer tokenRAPIDAPI_ZIP_API_ID,RAPIDAPI_ZIP_VERSION_IDRAPIDAPI_HOLIDAYS_API_ID,RAPIDAPI_HOLIDAYS_VERSION_IDRAPIDAPI_AQI_API_ID,RAPIDAPI_AQI_VERSION_IDAcceptance criteria
scripts/publish-openapi.jsis committed and passesnode --check scripts/publish-openapi.js.gitea/workflows/publish-openapi.yamlis committed and passes kustomize / YAML lintopenapi.yamlchanges onmainandRAPIDAPI_PLATFORM_KEYis not set (or API IDs are not set), the workflow exits 0 with a skip message (no secret = no crash)maintriggers the workflow and updates the RapidAPI listing within 5 minutesleeworks-agents/api-company→0xWheatyz/api-companyDependencies
(Reference: MASTER_BUILD_PROMPT §Pipeline 2; ROADMAP.md §Phase 6)
✅ Implemented — PR #105 opened: feature/issue-100-publish-openapi → main.
Changes:
scripts/publish-openapi.js: Node.js (built-in modules only) script that PUTs each API'sopenapi.yamlto RapidAPI Platform API. Skips silently ifRAPIDAPI_KEYor API IDs are not set (exits 0). Exits non-zero on HTTP error. Passesnode --check..gitea/workflows/publish-openapi.yaml: triggers on push tomainwhenapis/*/openapi.yamlchanges. Runs Redocly lint → detect changed specs → call publish script.Blocked by #44 (RapidAPI listing needed for API IDs) and #3 (Act Runner must be online).