[Phase 6] Add scripts/publish-openapi.js and .gitea/workflows/publish-openapi.yaml for RapidAPI spec upload CI #100

Closed
opened 2026-05-29 15:24:47 +00:00 by AI-Manager · 1 comment
Owner

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:

  1. scripts/publish-openapi.js — Node.js script that uploads each API's openapi.yaml to the RapidAPI Platform API using the PUT /v1/apis/{apiId}/versions/{versionId} endpoint.
  2. .gitea/workflows/publish-openapi.yaml — Gitea Actions workflow that runs Redocly lint on all specs then calls the publish script when apis/*/openapi.yaml changes on main.

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.js

Node.js script (no extra dependencies beyond node-fetch + form-data):

  • Reads RAPIDAPI_KEY, ZIP_API_ID, ZIP_VERSION_ID, HOLIDAYS_API_ID, HOLIDAYS_VERSION_ID, AQI_API_ID, AQI_VERSION_ID from environment.
  • If an API ID is not set, skips that API silently (allows partial config before all listings exist).
  • Uploads each changed spec to https://platformapi1.p.rapidapi.com/v1/apis/{apiId}/versions/{versionId} via HTTP PUT with multipart/form-data.
  • Exits non-zero on any HTTP error.
  • Logs ✓ Published {api-name} spec to RapidAPI on success.

See MASTER_BUILD_PROMPT §Pipeline 2 for the exact implementation template.

2. Create .gitea/workflows/publish-openapi.yaml

Gitea Actions workflow:

on:
  push:
    branches: [main]
    paths:
      - 'apis/*/openapi.yaml'

Steps:

  1. actions/checkout@v4 with fetch-depth: 2
  2. actions/setup-node@v4 (Node 20)
  3. npx @redocly/cli lint apis/*/openapi.yaml — fails pipeline if spec invalid
  4. Detect changed openapi.yaml files: git diff --name-only HEAD~1 HEAD | grep openapi.yaml
  5. Run node scripts/publish-openapi.js

Secrets required (operator configures once per listing is live on RapidAPI):

  • RAPIDAPI_PLATFORM_KEY — RapidAPI Platform API bearer token
  • RAPIDAPI_ZIP_API_ID, RAPIDAPI_ZIP_VERSION_ID
  • RAPIDAPI_HOLIDAYS_API_ID, RAPIDAPI_HOLIDAYS_VERSION_ID
  • RAPIDAPI_AQI_API_ID, RAPIDAPI_AQI_VERSION_ID

Acceptance criteria

  • scripts/publish-openapi.js is committed and passes node --check scripts/publish-openapi.js
  • .gitea/workflows/publish-openapi.yaml is committed and passes kustomize / YAML lint
  • When an openapi.yaml changes on main and RAPIDAPI_PLATFORM_KEY is not set (or API IDs are not set), the workflow exits 0 with a skip message (no secret = no crash)
  • When API IDs are configured (post-RapidAPI listing, issue #44), a spec change on main triggers the workflow and updates the RapidAPI listing within 5 minutes
  • PR opens from leeworks-agents/api-company0xWheatyz/api-company

Dependencies

(Reference: MASTER_BUILD_PROMPT §Pipeline 2; ROADMAP.md §Phase 6)

## 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: 1. `scripts/publish-openapi.js` — Node.js script that uploads each API's `openapi.yaml` to the RapidAPI Platform API using the `PUT /v1/apis/{apiId}/versions/{versionId}` endpoint. 2. `.gitea/workflows/publish-openapi.yaml` — Gitea Actions workflow that runs Redocly lint on all specs then calls the publish script when `apis/*/openapi.yaml` changes on `main`. 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.js` Node.js script (no extra dependencies beyond `node-fetch` + `form-data`): - Reads `RAPIDAPI_KEY`, `ZIP_API_ID`, `ZIP_VERSION_ID`, `HOLIDAYS_API_ID`, `HOLIDAYS_VERSION_ID`, `AQI_API_ID`, `AQI_VERSION_ID` from environment. - If an API ID is not set, skips that API silently (allows partial config before all listings exist). - Uploads each changed spec to `https://platformapi1.p.rapidapi.com/v1/apis/{apiId}/versions/{versionId}` via HTTP PUT with `multipart/form-data`. - Exits non-zero on any HTTP error. - Logs `✓ Published {api-name} spec to RapidAPI` on success. See MASTER_BUILD_PROMPT §Pipeline 2 for the exact implementation template. ### 2. Create `.gitea/workflows/publish-openapi.yaml` Gitea Actions workflow: ```yaml on: push: branches: [main] paths: - 'apis/*/openapi.yaml' ``` Steps: 1. `actions/checkout@v4` with `fetch-depth: 2` 2. `actions/setup-node@v4` (Node 20) 3. `npx @redocly/cli lint apis/*/openapi.yaml` — fails pipeline if spec invalid 4. Detect changed `openapi.yaml` files: `git diff --name-only HEAD~1 HEAD | grep openapi.yaml` 5. Run `node scripts/publish-openapi.js` Secrets required (operator configures once per listing is live on RapidAPI): - `RAPIDAPI_PLATFORM_KEY` — RapidAPI Platform API bearer token - `RAPIDAPI_ZIP_API_ID`, `RAPIDAPI_ZIP_VERSION_ID` - `RAPIDAPI_HOLIDAYS_API_ID`, `RAPIDAPI_HOLIDAYS_VERSION_ID` - `RAPIDAPI_AQI_API_ID`, `RAPIDAPI_AQI_VERSION_ID` ## Acceptance criteria - `scripts/publish-openapi.js` is committed and passes `node --check scripts/publish-openapi.js` - `.gitea/workflows/publish-openapi.yaml` is committed and passes kustomize / YAML lint - When an `openapi.yaml` changes on `main` and `RAPIDAPI_PLATFORM_KEY` is not set (or API IDs are not set), the workflow exits 0 with a skip message (no secret = no crash) - When API IDs are configured (post-RapidAPI listing, issue #44), a spec change on `main` triggers the workflow and updates the RapidAPI listing within 5 minutes - PR opens from `leeworks-agents/api-company` → `0xWheatyz/api-company` ## Dependencies - Depends on leeworks-agents/api-company#44 (RapidAPI listing — needed for API IDs + Platform Key) - Depends on leeworks-agents/api-company#3 (Act Runner must be online to run the workflow) - Depends on leeworks-agents/api-company#47 (upstream repo must exist for deploy PR) _(Reference: MASTER_BUILD_PROMPT §Pipeline 2; ROADMAP.md §Phase 6)_
AI-Manager added the agent-readyphase-6P2small labels 2026-05-29 15:24:47 +00:00
AI-Manager added the blockedroadmap labels 2026-05-29 15:26:08 +00:00
Author
Owner

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's openapi.yaml to RapidAPI Platform API. Skips silently if RAPIDAPI_KEY or API IDs are not set (exits 0). Exits non-zero on HTTP error. Passes node --check.
  • .gitea/workflows/publish-openapi.yaml: triggers on push to main when apis/*/openapi.yaml changes. 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).

✅ **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's `openapi.yaml` to RapidAPI Platform API. Skips silently if `RAPIDAPI_KEY` or API IDs are not set (exits 0). Exits non-zero on HTTP error. Passes `node --check`. - `.gitea/workflows/publish-openapi.yaml`: triggers on push to `main` when `apis/*/openapi.yaml` changes. 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).
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/api-company#100