Skip to content

docs(api): OpenAPI annotations for the native API (WI-2032, r2) - #257

Merged
thedancingdeveloper merged 1 commit into
mainfrom
wi-2032-openapi-r2
Oct 21, 2026
Merged

thedancingdeveloper merged 1 commit into
mainfrom
wi-2032-openapi-r2

Conversation

@thedancingdeveloper

Copy link
Copy Markdown
Collaborator

Rebase of #250 onto current main, superseding it.

What this carries

  • The utoipa annotations for every native /api/... handler, plus apps/rustnzb/tests/openapi_document.rs which fails when a handler or route is undocumented.
  • main moved underneath the original PR, so this also documents the routes main added since:
    • GET /api/config/backup
    • POST /api/config/backup/preview
    • POST /api/config/backup/restore
    • GET /api/config/schedule
    • PUT /api/config/schedule

Version bumps

ToSchema is public API on the shared crates, so alongside the merge:

  • nzb-core 0.2.22 (main) → 0.2.23 — adds ToSchema to the schedule types
  • nzb-web 0.4.24 → 0.4.25
  • nzb-nntp 0.2.26 → 0.2.27

Verification

  • cargo fmt --all --check
  • cargo clippy --workspace --all-targets -- -D warnings
  • cargo test --workspace
  • cargo test -p rustnzb --test openapi_document (4/4)

The SABnzbd compatibility layer remains deliberately outside the OpenAPI document.

Supersedes #250.

`/swagger-ui` was mounted but documented nothing: ApiDoc carried only an
`info(...)` block, so `/api-docs/openapi.json` served empty `paths` and
`components`. AGENTS.md calls `/api/...` a compatibility surface documented
through utoipa, which was vacuous while no handler was annotated.

- Annotate every native handler with `#[utoipa::path]`, grouped by tag:
  auth, system, setup, queue, history, statistics, config, servers,
  categories, rss, groups, articles and dav.
- Derive `ToSchema` on the request/response and shared model types, with
  `#[schema(value_type = String)]` for PathBuf fields. `ApiError` describes
  the `{error_kind, human_readable, status}` body the middleware emits.
- Split ApiDoc into the always-present base and a `webdav`-gated DAV part,
  merged in a manual `OpenApi` impl, so DAV paths appear only in builds that
  serve them.
- Add `apps/rustnzb/tests/openapi_document.rs`: every route from the router
  must appear in the document, no extra routes may appear, every operation
  carries a tag, summary and response, the shared models are registered, and
  every `async fn h_*` in a handler module carries an annotation.
- Enable utoipa's `chrono` feature for the shared config and model schemas.

The SABnzbd compatibility layer keeps its separate contract and is
deliberately outside the document.

Bumps nzb-nntp to 0.2.27 and nzb-web to 0.4.25.
@thedancingdeveloper
thedancingdeveloper added this pull request to the merge queue Oct 21, 2026
Merged via the queue into main with commit 1cd9f43 Oct 21, 2026
8 of 9 checks passed
@thedancingdeveloper
thedancingdeveloper deleted the wi-2032-openapi-r2 branch October 21, 2026 01:19
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.

1 participant