Skip to content

Derived-value doc-drift checks: swagger regen + WireVersion in LOG_PLUGINS.md (+ type the 5 dynamic endpoints) #1599

Description

@svaroqui

Follow-up from #1598, which unfroze swag init and regenerated the docs. The root cause of the freeze was that nothing validated the generation step, so it silently aborted and the served docs went stale for a long time (missing the rejoin routes, etc.). Two things to harden it and one fidelity item.

1. Prevent silent refreeze (the real root cause)

  • Add a make swagger target that runs the exact working command and syncs the dashboard copy:
    swagger:
        go run github.com/swaggo/swag/cmd/swag init -g server/api_cluster.go --dir ./ --parseInternal -o docs
        cp docs/swagger.json share/dashboard/swagger.json
    
  • CI check that runs make swagger and fails if git diff --exit-code docs/ share/dashboard/swagger.json is dirty — so a change that breaks generation (or forgets to regenerate) is caught, not silently frozen.

2. Keep the two copies in sync

share/dashboard/swagger.json is committed and served directly; it drifted from docs/swagger.json before. The make swagger target above keeps them in lockstep; the CI check enforces it.

3. Type the 5 dynamic endpoints (fidelity, lower priority)

#1598 documented these as map[string]interface{} because the concrete types are live runtime structs (mutexes, os.Process, sql.Null*) that can't be represented in OpenAPI:
ReplicationManager (/api/monitor), cluster.Cluster (list/get), cluster.ServerMonitor (server views), config.Config (cluster settings), cluster.Proxy.

  • Introduce dedicated lightweight response DTOs for these so consumers/codegen get real schemas, instead of returning the internal structs directly.

Context: #1598.


4. WireVersion doc-drift (LOG_PLUGINS.md) — same class of bug

doc/implementation/cluster/LOG_PLUGINS.md restates the plugin wire version in
three hand-maintained spots (prose "current version is N", the WireVersion = N
code snippet, and the wire-vN/ signer-layout tree). Nothing checks them against
the source of truth (WireVersion in cluster/logplugin/plugins/wire/wire.go), and
they had already drifted — the doc said 2 while the code was 3 (fixed on the
plugins/schema-advisor branch).

Generalize this issue from "swagger hygiene" to derived-value doc-drift checks:

  • CI/make check: read WireVersion = N from wire.go; fail if LOG_PLUGINS.md
    states a different number or references any wire-v<other> directory.
  • (optional) De-hardcode: state the wire version once in the doc (next to the
    WireVersion pointer) and refer to it abstractly elsewhere (wire-v<WireVersion>/),
    shrinking the manual surface from 3 to 1.

Same principle as §1–§2: a derived fact restated in docs must be validated, not trusted.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions