Skip to main content

Crate soothfast_spec

Crate soothfast_spec 

Source
Expand description

Soothfast spec engine, working in both directions.

Checking. Anything that declares an external surface — an OpenAPI spec, AsyncAPI channels, a GraphQL SDL schema, MCP tool schemas — parses into a common DeclaredOp set (providers) and reconciles against #[route] annotations with one mechanism (reconcile). The spec is hand-authored and the code proves it, which is the only order that works for a contract someone else serves.

Generating. The same four dialects are also emitted from the code: schema turns rustdoc JSON into JSON Schema, and one of openapi, asyncapi, graphql or mcp renders a document from it. A generated spec cannot disagree with the code, so what is left worth gating is whether it broke a consumer — compat, through each dialect’s own diff.

SpecKind names the dialect in both directions, and dialect is where the generation half dispatches on it.

Modules§

asyncapi
AsyncAPI 3.0 documents assembled from inferred route shapes.
compat
Consumer compatibility: what changed, and whether it breaks anyone.
dialect
What every generated dialect has in common, and how one is chosen.
graphql
GraphQL SDL generated from inferred route shapes.
mcp
MCP tool manifests generated from #[route(method = "TOOL")] handlers.
openapi
OpenAPI 3.1 documents assembled from inferred route shapes.
probe
Live-response data quality: does the running server actually populate what its spec declares?
proto
.proto message field reconciliation, parallel to crate::reconcile: matches struct fields against a proto message by tag, for consumed (not served) wire formats with no handler to hang #[route] off of. Both sides are read straight from source, so neither can drift.
providers
Declared-surface providers: parse each spec dialect into DeclaredOps. YAML converts to serde_json::Value so one walker serves YAML and JSON; GraphQL SDL uses a hand-rolled field extractor (we need field names, not an AST — dependency policy).
reconcile
One reconciler for every provider: spec operations ↔ code routes, matched by operation identity, cross-checked on method/path.
schema
Rustdoc JSON → JSON Schema.
serialize
YAML and JSON rendering for generated documents.

Structs§

DeclaredOp
One operation a spec declares.
RouteDecl
One #[soothfast::route] annotation from the code.

Enums§

SpecKind
Spec dialects soothfast reads and writes.

Functions§

sniff_kind
Sniff the dialect from filename + content.