Expand description
§blazingly-openapi
Deterministic OpenAPI 3.1 document generation for the Blazingly operation model.
This crate projects a blazingly_core::AppDefinition — the framework’s
validated operation graph — into an OpenAPI 3.1 / JSON Schema 2020-12
document (to_value, to_value_with_config) and precompiles the
/openapi.json and Scalar or Swagger UI responses as ready HTTP assets
(OpenApiService), so nothing is generated on the request hot path. It is an
A validation failure is documented automatically as a 422 marked
x-blazingly-automatic, and a value type’s constraints reach the item schema
of a collection that uses it, at any nesting depth. It is an
ordinary library and works standalone: it depends only on blazingly-core
and blazingly-json, performs no I/O, and needs neither the facade nor a
server. The Blazingly
framework facade re-exports it as blazingly::openapi and mounts
OpenApiService through HttpApp::with_openapi; the optional validation
feature projects declarative blazingly-validation bounds into the generated
schemas.
§Direct use
[dependencies]
blazingly-core = "0.2"
blazingly-openapi = "0.2"use blazingly_core::App;
use blazingly_openapi::{OpenApiConfig, to_value_with_config};
fn main() -> Result<(), Box<dyn std::error::Error>> {
// An application built with the framework macros supplies a populated
// definition; an empty one keeps this example self-contained.
let definition = App::new().build()?;
let document =
to_value_with_config(&definition, &OpenApiConfig::new("Users API", "1.0.0"));
println!("{document}");
Ok(())
}In a framework application, definition() on an ExecutableApp supplies the
populated definition.
§Links
- API documentation
- Getting started — the framework picture
- Repository
Structs§
- Open
ApiAsset Response - One runtime-neutral
OpenAPIHTTP asset. - Open
ApiConfig OpenAPIdocument metadata and well-known HTTP paths.- Open
ApiService - Precompiled
/openapi.jsonand Scalar/Swagger UI assets.
Enums§
- Open
ApiUi - Browser UI rendered by
OpenApiService.
Functions§
- to_
value - Generates a deterministic
OpenAPI3.1 document from the application model. - to_
value_ with_ config - Generates a deterministic
OpenAPIdocument with explicit application info.