alux-http-openapi 0.1.0

OpenAPI interpretation of ALUX typed HTTP programs
Documentation

alux-http-openapi

alux-http-openapi interprets an alux-http program as an OpenAPI 3.1 document that describes it.

This interpreter does not execute handlers. It reads each endpoint to determine what a caller must send and what the endpoint returns, so it needs alux-shape shapes where an executing interpreter needs request extractors.

use alux_http::HttpProgramExt;
use alux_http_openapi::OpenApiHandlerImpl;

let api = OpenApiHandlerImpl::<App>::new();
let route = api.compile_http(api.status_api::<App>());
let document = api.document("status", "1.0", &route);

println!("{}", serde_json::to_string_pretty(&document)?);

An OpenAPI document can be generated only when the program states an operation's name, each argument's name and source, the shape of every value that crosses the wire, and every status an endpoint can return. All of this information comes from the same declaration that alux-http-poem and alux-http-axum compile, so a document and a running service cannot describe different surfaces.

The source declaration may write /readings/:id. The OpenAPI interpreter converts that portable path segment to the /readings/{id} spelling used in the generated document.