Files
classroomio/apps/api/scripts
fe9f8c441f feat(api): public API plan gating, docs auth, and dashboard snippets (#701)
* fix(automation): align public API plan gating across cloud and self-hosted

Add shared canUsePublicApi helper so cloud allows Early Adopter and
Enterprise while self-hosted requires Enterprise. Update the API key
dashboard page and backend key creation checks to use the same rules.

Co-authored-by: Rotimi Best <rotimi-best@users.noreply.github.com>

* docs(api): document bearer auth on public API reference

Add shared OpenAPI enrichment with bearerAuth security scheme and
authentication instructions. The interactive reference now loads an
enriched spec with Authorize support, and the API guide explains how
to create and use org API keys.

Co-authored-by: Rotimi Best <rotimi-best@users.noreply.github.com>

* feat(dashboard): add API quick-start code snippets on automation page

Mirror the MCP client setup section with cURL, JavaScript, and Python
examples that show how to authenticate public API requests with org keys.

Co-authored-by: Rotimi Best <rotimi-best@users.noreply.github.com>

* ci(openapi): republish spec when public API OpenAPI helpers change

Co-authored-by: Rotimi Best <rotimi-best@users.noreply.github.com>

* feat(dashboard): add Go snippet to API quick-start examples

Co-authored-by: Rotimi Best <rotimi-best@users.noreply.github.com>

* docs(api): use /org/*/api and clarify dashboard key generation path

Co-authored-by: Rotimi Best <rotimi-best@users.noreply.github.com>

* fix(api): escape backticks in OpenAPI description template literal

Greptile flagged that unescaped backticks around * in
PUBLIC_API_OPENAPI_DESCRIPTION evaluated to NaN and dropped auth docs
from the Scalar spec. Also use plan-specific snackbar message on upgrade.

Co-authored-by: Rotimi Best <rotimi-best@users.noreply.github.com>

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Rotimi Best <rotimi-best@users.noreply.github.com>
2026-07-02 11:24:33 +01:00
..

OpenAPI Spec Generator Script

This script generates the OpenAPI specification for the public API routes only and optionally uploads it to a Cloudflare R2 bucket.

Usage

Generate and Upload OpenAPI spec

pnpm run upload:openapi

Direct script usage

tsx scripts/upload-openapi-spec.ts

Examples

# Generate spec locally only
pnpm upload:openapi

Environment Variables

For R2 upload functionality, set these environment variables:

CLOUDFLARE_ACCESS_KEY=your_access_key
CLOUDFLARE_SECRET_ACCESS_KEY=your_secret_key
CLOUDFLARE_ACCOUNT_ID=your_account_id

Output

The script will:

  1. Generate the OpenAPI specification from your Hono app routes
  2. Filter the output to /public-api/v1/*
  3. Save locally to dist/openapi/public-api/openapi.json
  4. Upload to R2 (if credentials provided):
    • openapi/public-api/openapi-YYYY-MM-DD.json (dated version)
    • openapi/public-api/openapi-latest.json (latest version)

GitHub Action Integration

This script is integrated with a GitHub Action that automatically generates and uploads the OpenAPI spec on code changes.

Automatic Workflow

The GitHub Action runs on:

  • Push to main - Automatically uploads to R2
  • Pull Requests - Generates spec for review (no upload)
  • Manual dispatch - Allows manual triggering with custom parameters

Setup

  1. Required secrets:
    • CLOUDFLARE_ACCESS_KEY
    • CLOUDFLARE_SECRET_ACCESS_KEY
    • CLOUDFLARE_ACCOUNT_ID

Features

  • ✅ Automatic OpenAPI spec generation from Hono routes
  • ✅ Local file generation for development
  • ✅ Cloudflare R2 upload with versioning
  • ✅ GitHub Action integration
  • ✅ Environment-specific deployments
  • ✅ PR previews and artifacts
  • ✅ Error handling and logging
  • ✅ CLI help with --help flag