Skip to content

OpenAPI Phase 5: docusaurus-plugin-openapi-docs + generated artifacts#3

Merged
ethanj merged 2 commits intomainfrom
openapi-phase5-plugin-install
Apr 20, 2026
Merged

OpenAPI Phase 5: docusaurus-plugin-openapi-docs + generated artifacts#3
ethanj merged 2 commits intomainfrom
openapi-phase5-plugin-install

Conversation

@ethanj
Copy link
Copy Markdown
Contributor

@ethanj ethanj commented Apr 20, 2026

Summary

Wires the HTTP API reference to the OpenAPI spec shipped inside @atomicmemory/atomicmemory-core. docusaurus-plugin-openapi-docs generates 29 .mdx pages + sidebar.ts from the spec on every prestart/prebuild; artifacts are committed so a fresh clone + npm install + npm start works without invoking gen first.

⚠️ Release coupling

This PR currently installs core via file:../Atomicmemory-core. Before merging to main we need to:

  1. Publish @atomicmemory/atomicmemory-core@1.0.1 (or equivalent) from the core repo's architecture2 branch — that branch has PR #28 merged and ships openapi.yaml + openapi.json in the npm tarball.
  2. Flip this PR's package.json to "@atomicmemory/atomicmemory-core": "^1.0.1".
  3. Regenerate the plugin output (npm run gen:api) and re-commit if any drift shows up.
  4. Then merge.

Until step 1 happens, the committed artifacts are source-of-truth — consumers without ../Atomicmemory-core nearby can still inspect the rendered site.

Config changes

docusaurus.config.ts

  • Register docusaurus-plugin-openapi-docs (id: openapi) with specPath: require.resolve('@atomicmemory/atomicmemory-core/openapi.yaml').
  • Add docusaurus-theme-openapi-docs to themes[].
  • Set docs.docItemComponent: '@theme/ApiItem' (required for the plugin's renderers).

package.json scripts

  • gen:api / clean:api (plugin CLI passthroughs).
  • prestart + prebuild both run gen:api → local dev and CI always regenerate from the latest core spec.

sidebars.ts

  • Import the generated sidebar.ts and plug it under apiReferenceSidebar → HTTP API.
  • Keep hand-authored conventions.md as the anchor intro page.

Deletions

8 hand-written markdown pages under docs/api-reference/http/ (ingest, search, list-get-delete, consolidate-decay-cap, lessons, audit, config, agents). Their content was a manual port of atomicmemory-core/docs/api-reference.md; generated pages replace them 1:1 and drift is no longer possible.

Stale-link fixes

  • docusaurus.config.ts footer → /api-reference/http/ingest-memory
  • docs/quickstart.md "Full API reference" link → ingest-memory
  • docs/sdk/guides/atomicmemory-backend.md table row links → the 5 new per-route slugs (ingest-memory, search-memories, list-memories, get-memory, delete-memory)

Test plan

  • npm install resolves (file: dep) + installs plugin
  • npm run gen:api — creates 29 api.mdx + per-route schema/params JSON + sidebar.ts
  • npm run build — completes successfully; no broken-link throws
  • build/api-reference/http/ingest-memory.html + 28 other operation pages present in dist
  • Manual smoke (local): navigate to /api-reference/http/ingest-memory → param tables, request schema, response schema all render

ethanj added 2 commits April 20, 2026 02:12
Wires the HTTP API reference to the OpenAPI spec shipped inside
@atomicmemory/atomicmemory-core. docusaurus-plugin-openapi-docs
generates 29 .mdx pages + sidebar.ts from the spec on every
prestart/prebuild; the artifacts are committed so fresh clones
render the site without invoking gen first.

Deps:
 - @atomicmemory/atomicmemory-core (file:../Atomicmemory-core for
   now — needs to switch to a published version ^1.0.x before this
   branch is merged)
 - docusaurus-plugin-openapi-docs + docusaurus-theme-openapi-docs

docusaurus.config.ts:
 - register the plugin under id 'openapi', pointing specPath at
   require.resolve('@atomicmemory/atomicmemory-core/openapi.yaml')
   so the generator tracks whatever core version is installed
 - add the theme to themes[]
 - set docs.docItemComponent='@theme/ApiItem' (required for the
   generated api.mdx renderers)

package.json scripts:
 - gen:api / clean:api (plugin CLI passthroughs)
 - prestart + prebuild both run gen:api so local dev and CI build
   always regenerate from the latest core spec

sidebars.ts:
 - import the plugin-generated sidebar.ts and plug it into
   apiReferenceSidebar under a "HTTP API" category
 - keep hand-authored conventions.md as the anchor intro page

Deletions: 8 hand-written markdown pages under docs/api-reference/
http/ (ingest, search, list-get-delete, consolidate-decay-cap,
lessons, audit, config, agents). Their content was a manual port of
atomicmemory-core/docs/api-reference.md; the generated pages replace
them 1:1 and drift is no longer possible.

Stale-link fixes:
 - docusaurus.config.ts footer → /api-reference/http/ingest-memory
 - docs/quickstart.md "Full API reference" link → ingest-memory
 - docs/sdk/guides/atomicmemory-backend.md table row links → the
   5 new per-route slugs (ingest-memory, search-memories, etc.)
Codex flagged three real issues on the Phase 5 PR:

1. file: dep broke CI / Pages. @atomicmemory/atomicmemory-core pinned
   to file:../Atomicmemory-core resolves only in this local workspace;
   deploy.yml's `npm ci` would have failed on GitHub Actions.

   Fix: vendor core's openapi.yaml into vendor/atomicmemory-core-openapi.yaml
   and point docusaurus.config.ts at the local file. Removed the
   @atomicmemory/atomicmemory-core dependency entirely. Add
   scripts/vendor-core-spec.mjs + `npm run vendor:spec` for pulling a
   refreshed spec from a newly-installed core package; workflow is:
     npm install @atomicmemory/atomicmemory-core@<version>
     npm run vendor:spec
     npm run regen:api
     git commit

2. prestart/prebuild didn't actually refresh anything. The plugin's
   gen-api-docs only writes files that don't already exist, so with
   the generated .mdx / sidebar.ts committed in the repo, rerunning
   never picked up upstream spec changes.

   Fix: add `regen:api` = `clean:api && gen:api`, and switch
   prestart/prebuild to call regen:api. Every local dev start and
   every CI build now nukes the previous artifacts before regenerating.

3. conventions.md overstated envelope consistency. The page said
   "all endpoints return a consistent { error } format" but the
   generated update-config page already documents richer 400
   (with detail + rejected) and 410 (with detail) envelopes.

   Fix: rewrite the Error responses section to (a) explicitly call
   the basic { error } shape canonical, (b) spell out the two
   richer PUT /v1/memories/config envelopes with full JSON examples,
   and (c) annotate the status table so each row notes which
   envelope applies. The hand-maintained intro page now matches
   the generated reference.

All three checks pass: clean npm ci works without ../Atomicmemory-core,
regen:api refreshes artifacts each run, build still succeeds.
@ethanj ethanj merged commit 3a4c540 into main Apr 20, 2026
@ethanj ethanj deleted the openapi-phase5-plugin-install branch April 20, 2026 09:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant