Skip to main content

Crate alux_http_openapi

Crate alux_http_openapi 

Source
Expand description

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

Interprets typed HTTP programs as the OpenAPI document that describes them.

This interpretation applies nothing. It reads each endpoint for what a caller states and what they are answered with, which is why it asks for shapes where an executing interpretation asks for extractors, and why it reads a failure’s statuses from the type rather than from a value it never holds.

Structs§

OpenApiAnswer
One answer an endpoint states, as a document describes it.
OpenApiArgument
One argument, as a document describes it.
OpenApiBodyInput
Describes a request body read as a document in a document.
OpenApiBytesOutput
Describes raw-byte answers in a document.
OpenApiCookieInput
Describes a cookie the caller sent in a document.
OpenApiEmptyOutput
Describes an answer with no body in a document.
OpenApiEndpoint
One endpoint, as a document describes it.
OpenApiFileOutput
Describes streamed-file answers in a document.
OpenApiFormInput
Describes a form-encoded request body in a document.
OpenApiHandlerImpl
Interprets typed HTTP programs as the OpenAPI document that describes them.
OpenApiHeaderInput
Describes a header the caller sent in a document.
OpenApiHeaderOutput
Describes a header an answer carries, beside the body it states.
OpenApiHtmlOutput
Describes HTML answers in a document.
OpenApiJsonOutput
Describes JSON answers in a document.
OpenApiMultipartInput
Describes a request body arriving as parts in a document.
OpenApiNamed
One named value an argument is read from.
OpenApiPathInput
Describes a segment the path binds in a document.
OpenApiQueryInput
Describes a value in the query string in a document.
OpenApiRawBodyInput
Describes a request body taken as it arrived in a document.
OpenApiRedirectOutput
Describes a redirect in a document.
OpenApiResultOutput
Describes both what an endpoint answers with and what its failures answer with.
OpenApiRoute
Carries every endpoint a program states, in declaration order.
OpenApiRouteImpl
Composes route selection as the path and method a document keys an operation by.
OpenApiSelector
Carries route-selection meaning, which a document reads as a path and a method.
OpenApiStatusOutput
Describes a declared status around the answer a kind already states.
OpenApiStreamOutput
Describes streamed answers in a document.
OpenApiTextOutput
Describes plain-text answers in a document.
OpenApiUnstatedInput
Describes an argument a caller never states.

Enums§

OpenApiSource
Where a document says one argument comes from.
OpenApiStated
What one argument states where it comes from.

Traits§

OpenApiInputAlg
States how a document describes one argument.
OpenApiInputsAlg
Describes the whole argument product one endpoint states, in declaration order.
OpenApiOutputAlg
States how a document describes what one output kind answers with.