02 · Document
Docs that run.
Write markdown beside every operation, or add Try it to any button on your existing documentation site. Readers send real requests without leaving the page, in your theme.
Write notes beside each operation
Drop a Markdown file right next to the endpoint it describes.
Looks a pet up by its id. Use this to check that a pet you added is really there.
The demo's seed pets are 1 to 3, and ones you add start at 1001.
<!-- specbook: params -->Where your notes live
- An operation: a
README.mdin its folder, likerequests/petstore/GetPetById/README.md. - Or one file per operation in the service's
docsfolder, likerequests/petstore/docs/GetPetById.md. - A request:
<name>.req.mdbeside<name>.req.ts. - A flow:
<name>.seq.mdbeside<name>.seq.ts. - Anywhere else: a markdown file whose front matter names what it documents, like
operation: petstore/GetPetById. - Where the tables go: a comment on a line of its own, like
<!-- specbook: params -->, puts the parameters,bodyorresponsesthere. Without one they follow your text.
Make any example runnable
Load one script on your documentation site and add a data attribute. A plain element gets a Play button beside it, and a button or link that carries the attribute opens the panel itself.
<p data-specbook-try="petstore/GetPetById">Fetch a pet.</p><button type="button" data-specbook-flow="adopt-pet" data-specbook-inputs='{"quantity":2}'> Adopt two</button><script type="module" src="/specbook/specbook.js"></script>Fetch a pet by its id and see the response checked against the spec.
It looks like your site
The panel is isolated from your page, so neither can break the other. It uses your colors, follows your light or dark theme as it changes, and keeps what a visitor types out of your storage. Every attribute and variable is in the reference.
:root { --sb-accent: #e11d48; --sb-accent-hover: #be123c; --sb-font-sans: "Inter", system-ui, sans-serif; --sb-radius-card: 14px;}