Skip to content

feat: list every endpoint of the API in its docs - #1646

Draft
jubianchi wants to merge 5 commits into
dev-null-sh:productionfrom
jubianchi:feat/api-docs-reference
Draft

jubianchi wants to merge 5 commits into
dev-null-sh:productionfrom
jubianchi:feat/api-docs-reference

Conversation

@jubianchi

@jubianchi jubianchi commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Depends on #1645, still open. Until it merges, this diff also shows its changes and the earlier ones; this pull request's own changes.

Summary

The API docs get their reference, read from the committed spec, and a search. Last of five pull requests splitting #1533; with it, the stack holds everything #1533 did, adapted to production (the new /guilds and /me/moderation-history endpoints, the guild_paused error).

Changes

  1. Groups. Endpoints are grouped by the first segment of their path (the log and starred commits under Me), in alphabetical order, in the docs and in the spec. An endpoint the docs have no group for fails the export, saying where to add one.
  2. Endpoints. Each folds to its method, path, summary and whether it is signed, and opens to its parameters, body, responses, and the errors with fields of their own (the others point to Errors).
  3. Schemas. Each part reads as fields or as its JSON schema, picked for that part alone, loaded on demand, each referred schema written once in $defs.
  4. Examples in curl, Laravel and fetch ask for JSON, send the very bytes they sign, and follow the endpoint as it scrolls; the client picked is picked everywhere.
  5. Search. ⌘K, Ctrl+K or / searches guides and endpoints.
# Pull request Depends on
0 #1642 the console layout production
1 #1643 the API docs page and its Introduction 0
2 #1644 the guides 1
3 #1645 the OpenAPI spec 2
4 this one 3

Validation

Check Result
pest --parallel --coverage --exactly=100.0 (full suite) 6596 passed, 100.0%
pest --type-coverage --min=100 100.0%
pint --test, rector --dry-run, phpstan clean
TSX tests, tsc 1179 passed, clean

A test runs each generated Laravel example against a faked client and checks it sends the bytes it signed.

Visual evidence

Playwright (Chromium) against a local dev server, emulated viewports, Inertia SSR off. The groups were captured on this branch at 1440×900, 1366×650 and 390×844, light and dark: CLS 0 on load, no horizontal overflow, no console error.

Guilds, 1440 light 390 dark
Guilds group, desktop, light Guilds group, mobile, dark

POST /commits, captured on this branch (CLS 0 on load and on switching fields → schema):

As fields, 1440 light 1366 dark 390 light
POST /commits as fields, desktop, light POST /commits as fields, laptop, dark POST /commits as fields, mobile, light
Body as JSON schema, 1440 dark 390 light
POST /commits, its body as JSON schema, desktop, dark POST /commits, its body as JSON schema, mobile, light

The states below were captured while this change was part of #1533; the code behind them is unchanged, only the sidebar lacks the Guilds group added since. CLS was 0 on moving between endpoint anchors and on a schema failing 1.5 s after the click (simulated 500).

Loading, 1440 light
Schema loading, desktop, light
Failed, 390 light Failed, 320 light Focus after Try again, 1440 light
Schema failed on a one-field table, mobile, light Schema failed on a nested answer, 320px, light Focus on the schema toggle after Try again, desktop, light
Focus on the example tabs, 1440 dark Examples pinned to the end, 1440 light Search, 1440 dark Nothing found, 1440 light
Keyboard focus on the example tabs, desktop, dark The fetch example still pinned at the end of GET /commits/{commit}, desktop, light Search, desktop, dark Search with nothing found, desktop, light

Device verification

Emulation only (390×844 and 320–375 wide, DPR 2, touch): no hardware or simulator.

Independent review

Fresh read-only reviewers, given the guidelines, the stack, the validation results and the captures. A first round on the previous heads found should-fix points (fixtures and options ahead of their PR, the Errors table hiding its meanings on a phone, the Guilds preview, captures from before production's guild fields), all fixed. Re-review on base 1aa85cf4, head dc003d2c: CODE: PASS, VISUAL: PASS, no blocker or should-fix. The reviewer also checked that the stack ends on the tree #1533 had, adapted to production (Guilds, /me/moderation-history, guild_paused), its tests moved but none lost.

Limitations

  • POST /commits and POST /scheduled-commits list a 200 with a string body: their controllers return ApiException::guildPaused()->render() from a method typed JsonResponse, which Scramble reads as a success. Throwing the exception instead would fix it, in production code, so it is left for a separate PR; the summary says a guild_paused error can come back.
  • Guilds are in preview: GET /guilds answers 404 to accounts without them (its description says so), while the spec says 403, as for every request that hides itself with denyAsNotFound. It has no summary yet, like the 22 endpoints listed in feat: describe the v1 API as an OpenAPI spec, and serve it #1645.
  • The event themes (New Year, Christmas, Halloween) recolor --primary close to the warning or destructive tones, so method and signature chips read closer to "act here" during those events. A design call.
  • A schema that loads much shorter than the fields it replaces shortens the page; an endpoint opened by back or forward pushes down what follows it.
  • Each example is sent as code and as highlighted HTML, since copying needs the raw code.
  • Left for later: response examples, endpoints open by default, rewriting the summaries for readers.

The API docs page reuses the operations console's shell: the sidebar of
grouped pages, the header naming the current one, the mobile nav that
scrolls sideways, the theme switch and the way back to /dev/null.

ConsoleLayout now draws that shell from its props: the brand chip and
label, the nav landmark's own label, whether its links prefetch, and a
title that falls back to the console's name. OperationsLayout keeps
what only operations does (polling, refreshing, the remotes dock) and
passes its pages in, with Moderation as an item elsewhere and prefetch
off, as before. Nothing changes on screen: captures before and after
differ only in the pulsing live dot.

Two things only the API docs will use come with it, as part of the
shell: links that prefetch, which operations leaves off, and the way
back for a guest on a phone, since operations only has signed-in
admins.
/docs/api opens the API docs, readable by everyone, on the console
layout: the guides in the sidebar, the section named in the header,
and the way back to /dev/null. A section the docs don't have is the
not found page.

This first step brings the page and its Introduction: what the API is
for, its base URL and format, and a first request anyone can send. Its
code is highlighted on the server and shown in the site's own code
blocks. The other guides, the OpenAPI spec and the endpoint reference
follow in their own pull requests.

The docs are linked as API from the aside, after Apps, and from the
user menu where the aside is hidden.
The API docs get the guides that tell what a reference can't.
Authentication: public and signed requests, getting a key approved with
PKCE, and signing a request, with a helper for the shell, Laravel and
Node.js under tabs that keep the client picked. Rate limits and Errors
read their budgets and code meanings from the limiters, routes and
ApiErrorCode, so they change with them; on a phone, an error's meaning
reads under its code. Pagination says which lists
page differently. The Introduction now points to Pagination and
Authentication.

The limits the guide lists move to where they are enforced and read
from there: the commits a minute to Commit, the issues a day to
CreateIssue, the failed signatures a minute to SignedRequests. A test
signs a read, a write without a body and a write with one through each
helper exactly as the guide shows it, and the API accepts them.
Nothing tells a developer what the v1 API offers but the code. Scramble
reads it (routes, form requests, resources and their docblocks) and
exports an OpenAPI 3.1 spec, committed as resources/api/openapi.json so
anyone building on the API can read it without running Scramble.
GET /api/v1/openapi.json serves it to anyone, cached for an hour with an
ETag, for Postman, Bruno, Insomnia or a client generator. The API docs
link to it from their sidebar and their Introduction.

`composer generate:openapi` writes it again; it reads the models'
columns from the database, so it needs a migrated one. A test exports
it afresh and fails when the code and the committed spec disagree. The
export doesn't depend on APP_NAME or the locale.

Scramble is a dev dependency: its provider is always listed, since
make:provider rewrites bootstrap/providers.php as a plain list, and does
nothing without it. Its own docs page is turned off: /docs/api is ours.

On top of what Scramble infers, transformers in app/OpenApi:

- leave out, by route name, what only the apps use to work: signing in,
  the Mac app's update check, live updates, the web session and the
  signed URLs of remote media;
- name path parameters after what the route reads ({handle}), described
  as that field, and refuse two parameters named alike;
- say whether an endpoint needs a signed request or only reads more with
  one, and describe its 401 accordingly, and a 429 as a message with
  rate_limited only for signed requests;
- describe a request with images as JSON, or as a signed multipart
  upload of that JSON beside them, sent as a binary file part;
- keep a commit's poll optional and nullable, its options and duration
  required only when there is one, as its rules say;
- describe a commit's author as the user or organization it is, what
  resources build with the services they resolve, and how long a
  commit's body may be as links count.

Endpoints keep Scramble's grouping by controller for now: the reference
groups them as the docs list them.
The API docs get their reference, read from the committed spec: every
endpoint by group, the groups in alphabetical order and named after the
first segment of the paths they list (the log and starred commits under
Me), which the spec now groups its endpoints by. An endpoint the docs
have no group for fails the export, saying where to add one.

Each endpoint folds to its method, tinted by what it does, its path,
summary and whether it is signed, and opens to its path and query
parameters, body, responses, and the errors with fields of their own,
the others pointing to Errors. Each part reads as fields or as its JSON
schema, picked for that part alone, loaded on demand from
/docs/api/{section}/schemas/{endpoint}, outside the web group so caches
can share it, every referred schema written once in $defs. Examples in
curl, Laravel and fetch ask for JSON and send the very bytes they sign,
a scheduled commit's date computed when they run, valid values for the
fields and query parameters that check their format, and follow the
endpoint as it scrolls. A group, the index and an endpoint's schemas
are cached under one key each, replaced when the spec or the code
reading it changes.

⌘K, Ctrl+K or / search the guides and endpoints, from an index sent
once per visit. A pick on another page closes the search once that page
arrives; closing it otherwise hands focus back to the search button.

Loading, failure and retry keep the page still: the fields stay until
a schema arrives, a failure lies over them on one line on any phone,
is announced once, and Try again keeps focus on the part it was in.
@coderabbitai

coderabbitai Bot commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@shanesmithdev

Copy link
Copy Markdown

Ooh, this looks nice!

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.

2 participants