Expand description
Small, product-neutral helpers for consistent OpenAPI documents.
Products continue to own paths, operations, and endpoint schemas. This crate only applies Baukit’s document conventions, provides the shared error envelope schema, offers opt-in bearer authentication metadata, and manages a deterministic committed schema.
§Example
use baukit_openapi::{ErrorEnvelope, OpenApiMetadata, serialize_schema};
use utoipa::openapi::Server;
#[derive(utoipa::OpenApi)]
#[openapi(components(schemas(ErrorEnvelope)))]
struct ApiDoc;
let mut document = <ApiDoc as utoipa::OpenApi>::openapi();
OpenApiMetadata::new("Orders API", "1.2.3", "The Orders service API")
.servers([Server::new("https://api.example.com")])
.apply_to(&mut document);
let json = serialize_schema(&document)?;
assert!(json.ends_with('\n'));Structs§
- Error
Body - The error body nested inside
ErrorEnvelope. - Error
Envelope - The shared public error response envelope.
- Open
ApiMetadata - Baukit document metadata and optional security conventions.
- Response
Envelope - A fully typed success-response envelope.
- Rfc3339
Date Time - An API timestamp with one JSON and OpenAPI representation: an RFC 3339
string with OpenAPI
date-timeformat. - Schema
Error - An error produced while serializing, writing, or comparing an OpenAPI schema.
Constants§
- BEARER_
AUTH_ SCHEME - The component name used for Baukit’s standard HTTP bearer JWT security scheme.
Functions§
- assert_
no_ drift - Asserts that a committed schema exactly matches deterministic serialization of the document.
- check_
no_ drift - Checks that a committed schema exactly matches deterministic serialization of the document.
- serialize_
schema - Serializes an OpenAPI document as deterministically ordered pretty JSON with a trailing newline.
- write_
schema - Writes a deterministic schema atomically, creating parent directories when necessary.