Skip to main content

Crate baukit_openapi

Crate baukit_openapi 

Source
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§

ErrorBody
The error body nested inside ErrorEnvelope.
ErrorEnvelope
The shared public error response envelope.
OpenApiMetadata
Baukit document metadata and optional security conventions.
ResponseEnvelope
A fully typed success-response envelope.
Rfc3339DateTime
An API timestamp with one JSON and OpenAPI representation: an RFC 3339 string with OpenAPI date-time format.
SchemaError
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.