Skip to content

Architecture ​

axum-autodoc is a single crate built as a hexagon. Dependencies point inward:

text
adapters (axum, schemars, serde_json, garde, jsonwebtoken, Scalar, Swagger UI, TypeScript, fs)
   ↓
application (document assembly, publishing, authentication)
   ↓
domain (typed OpenAPI model, value objects, errors, ports)

Domain ​

A typed OpenAPI 3.2 model, the value objects around it (methods, route paths, operation ids, bearer tokens) and the ports. It depends only on serde and thiserror.

Application ​

The use cases:

  • Document assembly filters excluded routes, assigns and deduplicates operation ids, reconciles path parameters, collects security schemes and tags, and keeps only the schemas that published operations reach.
  • Publishing serializes the document and renders the reference page and the TypeScript client.
  • Authentication turns a bearer token into claims through a verifier port.

Adapters ​

DirectionAdapter
inboundaxum: ApiRouter, extractors, DocContext, #[api] metadata
outboundschemars schemas, serde_json serializer, Scalar and Swagger UI pages, TypeScript client, jsonwebtoken verifier, garde validation, file writer

Renderers, serializers, token verifiers and file writers are ports, so each can be swapped or tested with a mock.

Public surface ​

Only the root items, axum_autodoc::openapi and axum_autodoc::error are public. Everything else is private, so internals can change without a breaking release. Full API docs are on docs.rs.

Quality gates ​

Every push runs:

  • cargo fmt, clippy (pedantic, -D warnings) and tests across feature combinations,
  • the same with the engine compiled out,
  • a check on the minimum supported Rust version, 1.88,
  • an end-to-end run that lints the spec with Redocly, type-checks the client with tsc --strict and calls the server from Bun,
  • a cargo publish dry run,
  • a build of this site, with every Rust snippet checked against the compiled examples.

Released under the MIT or Apache-2.0 license.