Skip to content

docs(api): derive api-reference from route handlers (single source of truth) to prevent silent omissions #828

Closed

Description

@ajianaz

Problem

The auto-generated docs/api-reference.md is driven by a manually-maintained endpoint list in crates/uteke-server/src/api_registry.rs, separate from the actual route handlers in handlers.rs. When an endpoint is added to handlers.rs but not to api_registry.rs, it is silently omitted from the reference doc — there is no build-time check tying the two together.

This already happened: /doc/list, /doc/search, /doc/update exist in handlers.rs but were missing from api_registry.rs (and therefore from docs/api-reference.md) since they were added. Fixed reactively in #827, but the gap went unnoticed for weeks and misled a downstream consumer (corin) into thinking the endpoints might not exist.

Evidence

A diff of route matches in handlers.rs vs path: entries in api_registry.rs is the only way to catch this today — it must be done by hand:

comm -23 \
  <(grep -hoE "\"/[a-z][a-z/-]*\"" crates/uteke-server/src/handlers.rs | sort -u) \
  <(grep -hoE "path: \"/[a-z][a-z/-]*\"" crates/uteke-server/src/api_registry.rs | sed "s/path: //" | sort -u)

Proposal

Make the route registry the single source of truth so the doc cannot drift from reality. Options (in increasing effort):

  1. CI guard (cheapest): add a test/script that diffs handler routes against api_registry.rs paths and fails if they diverge. Catches future drift immediately.
  2. Derive registry from handlers: extract the (method, path) list from the handler match table and generate the Endpoint list automatically (descriptions/types still curated, but the path set is authoritative).
  3. Annotate handlers: attach doc metadata (description, request type) directly at each match arm via a macro/attribute, and have docgen read those — eliminating api_registry.rs entirely.

Recommendation

Start with (1) — a cargo test assertion that the registry path set ⊇ handler route set. Low effort, prevents recurrence, and unblocks a later move to (2)/(3).

Context

Activity

  1. added
    documentation
    enhancement
    scope:server
    on Aug 1, 2026
  2. tomatotomata commented on Aug 1, 2026

    @tomatotomata
    Contributor

    I’m taking the recommended CI-guard slice. I’ll replace the current registry spot-check with a test that extracts the (Method, path) arms from uteke-server/src/handlers.rs and asserts every handler path is present in ENDPOINTS, so a newly added route cannot silently disappear from the API docs. I’ll run the focused server tests and formatting checks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationenhancementscope:server

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions