Skip to main content

Crate blazingly_openapi

Crate blazingly_openapi 

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

Structs§

OpenApiAssetResponse
One runtime-neutral OpenAPI HTTP asset.
OpenApiConfig
OpenAPI document metadata and well-known HTTP paths.
OpenApiService
Precompiled /openapi.json and Scalar/Swagger UI assets.

Enums§

OpenApiUi
Browser UI rendered by OpenApiService.

Functions§

to_value
Generates a deterministic OpenAPI 3.1 document from the application model.
to_value_with_config
Generates a deterministic OpenAPI document with explicit application info.