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, documents error responses from product rules, offers opt-in bearer authentication metadata, manages a deterministic committed schema, and checks that property and parameter names are camelCase.
§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.
- Error
Response Rules - Error responses and response headers to document on every matching operation, as data.
- Naming
Violation - A property or parameter name that is not camelCase.
- 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, comparing, or naming-checking an OpenAPI schema.
Enums§
- IfMatch
Requirement - Whether a route rejects a write that omits
If-Match. - Name
Kind - The kind of name a
NamingViolationrefers to. - Operation
Condition - A property of an operation that decides whether a rule applies to it.
- Response
Selector - Which responses of a matching operation a header rule documents.
Constants§
- BEARER_
AUTH_ SCHEME - The component name used for Baukit’s standard HTTP bearer JWT security scheme.
- ETAG_
HEADER - The response header that carries a strong revision validator.
- IF_
MATCH_ HEADER - The request header that carries a revision precondition.
- INVALID_
IF_ MATCH_ CODE - Error code for an
If-Matchvalue that is not one strong ETag for the resource (HTTP 400). - PRECONDITION_
FAILED_ CODE - Error code for an
If-Matchrevision that is no longer current (HTTP 412). - PRECONDITION_
REQUIRED_ CODE - Error code for a required
If-Matchheader that is missing (HTTP 428). - REQUEST_
ID_ HEADER - The response header that carries the request identifier.
- RETRY_
AFTER_ HEADER - The response header that tells a client how many seconds to wait before retrying.
- WWW_
AUTHENTICATE_ HEADER - The response header that carries an authentication challenge.
Functions§
- assert_
camel_ case_ names - Asserts that every property and parameter name in a document is camelCase.
- assert_
no_ drift - Asserts that a committed schema exactly matches deterministic serialization of the document.
- check_
camel_ case_ names - Checks that every property and parameter name in a document is camelCase.
- check_
no_ drift - Checks that a committed schema exactly matches deterministic serialization of the document.
- document_
etag - Documents the
ETagheader on every inline 2xx response of one operation. - document_
if_ match - Documents a revision precondition on one operation.
- etag_
header - Returns the documented
ETagresponse header for a strong revision validator. - fill_
missing_ response_ descriptions - Fills empty response descriptions so utoipa emits OpenAPI’s required field.
- find_
naming_ violations - Finds every property and parameter name in a serialized OpenAPI document that is not camelCase.
- if_
match_ parameter - Returns the documented
If-Matchheader parameter for a revision precondition. - is_
camel_ case - Returns
truefor a lower camelCase name: an ASCII lowercase letter followed by ASCII letters and digits. - request_
id_ header - Returns the documented
X-Request-Idresponse header. - retry_
after_ header - Returns the documented
Retry-Afterresponse header in delta seconds. - 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.
- www_
authenticate_ header - Returns the documented
WWW-Authenticateresponse header for a bearer challenge.