Swagger UI
The widget below mounts Swagger UI on an OpenAPI snapshot bundled with this
site. The snapshot is generated from the code by the server’s own
openapi:dump script: it reports version 3.6.0-alpha.0 and holds 149 paths
and 202 operations. Nine of those paths are the federation routes, which a
server only serves when federation is wired at boot.
The explorer loads the bundled snapshot when you open it.
Try it out calls your local stack. The snapshot’s only servers entry
is http://localhost:3939, so requests go from your browser to a server on
your machine. Start the stack, click Authorize, paste an API key, then
use Try it out. If you set MNEMO_CORS_ORIGINS on the server, this
site’s origin has to be in the list.
The live spec
A running server serves its own spec, which always matches its code:
curl http://localhost:3939/openapi.json \
-H "Authorization: Bearer $MNEMO_KEY" \
| jq '.info.version'GET /openapi.json needs an API key. The spec bar in the widget fetches a
URL without one, so it cannot load the live spec directly: save the file
with the command above and serve it from somewhere the browser can read.
The server also has its own reference UI at /docs, behind the same
authentication.
How the spec is generated
Mnemosyne uses @hono/zod-openapi
to derive an OpenAPI 3.1 document from the same Zod schemas the server uses
to validate requests. The route definitions in packages/server/src/routes/
are the single source.
// packages/server/src/openapi.ts
app.doc("/openapi.json", {
openapi: "3.1.0",
info: { version, title: "Mnemosyne API" /* description, license */ },
servers: [{ url: "/", description: "current deployment" }],
});
app.openAPIRegistry.registerComponent("securitySchemes", "BearerAuth", {
type: "http",
scheme: "bearer",
bearerFormat: "API Key",
});The live spec lists the server as /: routes are mounted at the root, with
no /v1 prefix. The bundled snapshot replaces that entry with
http://localhost:3939 so the widget has somewhere to send requests.
Routes registered without an OpenAPI definition are not in the document.
That covers the probes (/health/live, /health/ready), the WebSocket
endpoint and the gRPC service.
Authorization
Every route in the spec requires a bearer key. Create one from the repo’s
docker/ folder:
docker compose exec server node scripts/create-api-key.cjs --label "swagger-tester"The script prints the key once. Click Authorize at the top of the widget and paste it. Every Try it out call then sends it.
Raw snapshot
curl https://<your-docs-host>/openapi-snapshot.json | jq '.info.version'The snapshot is a file in this site’s repository and is regenerated by hand, so it can lag the server you run. When they differ, trust the live spec.
Compatibility notes
- The spec is OpenAPI 3.1.0 and uses
oneOfand nullable types. - Swagger UI 5.x or later is required. Older versions do not read 3.1.