Skip to content

Publish the OpenAPI document and its reference pages on the website #823

Closed

Description

@V3RON

Part of #813.

Scope

The website publishes the OpenAPI document at /simlock/openapi.json and renders it under Reference → HTTP API, one page per route grouped by tag. The site rebuilds when the HTTP code or the package version changes on main.

In short

A visitor opens Reference → HTTP API and reads each route. A tool downloads https://callstackincubator.github.io/simlock/openapi.json. The old synced "HTTP API" page stays until #812 removes it, so the sidebar shows both for a while: the new group is labelled "HTTP API reference".

flowchart LR
  P[push to main: website/**, docs/*.md, src/**, package.json *changed paths*] --> J[website job]
  J --> G[website build script: pnpm openapi first *changed*]
  G --> B[astro build + starlight-openapi *new plugin*]
  B --> S[/simlock/openapi.json + /simlock/docs/reference/http-api/]
Loading
$ curl -s https://callstackincubator.github.io/simlock/openapi.json | jq .openapi
# today: parse error (404 page)
# after: "3.1.0"

If this goes wrong: the site build fails on main and the last good site stays up.

Technical spec

Facts

# Fact Source
F1 The website job runs on pushes to main that touch website/**, docs/*.md or the workflow; it installs and builds only website/ .github/workflows/website.yml:4-7, :21-38
F2 website/ is its own pnpm root website/pnpm-workspace.yaml:2
F3 The site's base is /simlock; files in website/public/ are served at the base website/astro.config.mjs:22; website/src/site/content.ts:8
F4 The sidebar's Reference group lists docs by slug docs/<name>, including the synced http-api page website/astro.config.mjs:17, :74-86
F5 starlight-openapi 0.27.0 supports Starlight ≥0.41 and Astro ≥7.0.2, and needs @astrojs/markdown-satteri ≥0.3.2 as a peer; the site has Starlight 0.42.6 and Astro 7.4.0 starlight-openapi@0.27.0/package.json peerDependencies; website/pnpm-lock.yaml:355, :993
F6 starlight-openapi's config: base, schema (a path from the Astro root or a URL), sidebar.label, sidebar.group; it reads the schema at config:setup, so the file must exist before astro build or astro dev starlight-openapi@0.27.0/libs/schemas/schema.ts:11-60; libs/parser.ts:21, :33-35; index.ts:24-34
F7 createOpenAPISidebarGroup() places the generated pages inside a chosen sidebar group starlight-openapi@0.27.0/index.ts:54
F8 pnpm openapi <file> writes the document (#819) #813 Shared values
F9 website/.gitignore ignores node_modules, dist, .astro, src/content/docs/docs/ref/ website/.gitignore
F11 The site builds pages as files: a slug docs/x becomes dist/docs/x.html; starlight-openapi's overview slug is its base, operation pages sit under <base>/operations/ website/astro.config.mjs:24-26 (build: { format: "file" }); starlight-openapi@0.27.0/libs/route.ts:16
F12 website/ has no test runner; its scripts are sync-docs, dev, build, preview, check, og website/package.json scripts
F13 Root CI installs with --ignore-scripts (the root prepare runs lefthook install) .github/workflows/ci.yml:41; package.json prepare
F10 The root needs Node ≥22.18 and pnpm 11.22.0; the job uses Node 24 and pnpm 11.22.0 website/package.json engines, devEngines; .github/workflows/website.yml:27-34

Modules touched

Search: website.yml, astro.config.mjs sidebar, website/package.json scripts. Changed: .github/workflows/website.yml, website/astro.config.mjs, website/package.json (dependencies starlight-openapi, @astrojs/markdown-satteri; dev, build, check generate the file first) and its lockfile, website/.gitignore (public/openapi.json), new website/scripts/check-openapi.mjs, docs/internal/agent-rules/toolchain.md (a row for the website build). No src/ change.

Contract and event changes

None.

Other code on the same state

website/public/openapi.json is written by the generator and read by the plugin. It is gitignored, never committed. #812 will reshape the sidebar this task adds to.

Failure modes

Call Outcome What happens Limit, counted from
job → pnpm openapi fails job fails before deploy; the last site stays the job's default timeout
job → astro build the plugin rejects the document job fails before deploy same
pnpm dev, pnpm build, pnpm check in website/ any each first runs pnpm --dir .. openapi website/public/openapi.json (the path is resolved from the repo root, where --dir .. runs it), every time, so the pages match the code; without root deps that step fails at tsc and the script stops none
job → check script a page, the file or the sidebar group is wrong job fails before deploy same

Rules in play

  • ADR 0040 §6: "The website job builds the document at build time, publishes it at /simlock/openapi.json, and renders it with starlight-openapi under Reference → HTTP API".
  • ADR 0040 §3: "It is not served by the daemon". Nothing in src/ changes.

Tests

Seam: a post-build check script, new website/scripts/check-openapi.mjs (plain node, like website/scripts/sync-docs.mjs), run after astro build by the website job and by the toolchain command. The document itself is proven by #819's tests.

  • A visitor opens the built site, checked by check-openapi.mjs: website/dist/openapi.json equals website/public/openapi.json; website/dist/docs/reference/http-api.html (the overview) exists; website/dist/docs/reference/http-api/operations/ holds one page per operation in the document; the built sidebar shows "HTTP API reference" inside the Reference group with one sub-group per tag. The script exits non-zero naming the first check that fails.

Done when

  • docs/internal/agent-rules/toolchain.md lists the website build under the tests agents run: pnpm --dir website install && pnpm --dir website build && node website/scripts/check-openapi.mjs (the website build script generates the file), run only when the diff touches website/, src/http/, src/contract/, src/modules/ or a module's definition.ts; that command passes.
  • website/dist/openapi.json and website/dist/docs/reference/http-api.html exist after it.
  • .github/workflows/website.yml installs root deps with --ignore-scripts, runs the website build script (which generates the file first) and node scripts/check-openapi.mjs after it, and triggers on src/**, package.json and pnpm-lock.yaml too.

Out of scope

Depends on

Written by an agent.

Activity

  1. added
    task:draft
    on Oct 21, 2026
  2. changed the title [-]List the module and uplink routes in the OpenAPI document[/-] [+]Publish the OpenAPI document and its reference pages on the website[/+] on Oct 21, 2026
  3. added
    task:ready
    and removed
    task:draft
    on Oct 21, 2026
  4. self-assigned this
    on Oct 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

task:ready

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions