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§
- Open
ApiAnswer - One answer an endpoint states, as a document describes it.
- Open
ApiArgument - One argument, as a document describes it.
- Open
ApiBody Input - Describes a request body read as a document in a document.
- Open
ApiBytes Output - Describes raw-byte answers in a document.
- Open
ApiCookie Input - Describes a cookie the caller sent in a document.
- Open
ApiEmpty Output - Describes an answer with no body in a document.
- Open
ApiEndpoint - One endpoint, as a document describes it.
- Open
ApiFile Output - Describes streamed-file answers in a document.
- Open
ApiForm Input - Describes a form-encoded request body in a document.
- Open
ApiHandler Impl - Interprets typed HTTP programs as the
OpenAPIdocument that describes them. - Open
ApiHeader Input - Describes a header the caller sent in a document.
- Open
ApiHeader Output - Describes a header an answer carries, beside the body it states.
- Open
ApiHtml Output - Describes HTML answers in a document.
- Open
ApiJson Output - Describes JSON answers in a document.
- Open
ApiMultipart Input - Describes a request body arriving as parts in a document.
- Open
ApiNamed - One named value an argument is read from.
- Open
ApiPath Input - Describes a segment the path binds in a document.
- Open
ApiQuery Input - Describes a value in the query string in a document.
- Open
ApiRaw Body Input - Describes a request body taken as it arrived in a document.
- Open
ApiRedirect Output - Describes a redirect in a document.
- Open
ApiResult Output - Describes both what an endpoint answers with and what its failures answer with.
- Open
ApiRoute - Carries every endpoint a program states, in declaration order.
- Open
ApiRoute Impl - Composes route selection as the path and method a document keys an operation by.
- Open
ApiSelector - Carries route-selection meaning, which a document reads as a path and a method.
- Open
ApiStatus Output - Describes a declared status around the answer a kind already states.
- Open
ApiStream Output - Describes streamed answers in a document.
- Open
ApiText Output - Describes plain-text answers in a document.
- Open
ApiUnstated Input - Describes an argument a caller never states.
Enums§
- Open
ApiSource - Where a document says one argument comes from.
- Open
ApiStated - What one argument states where it comes from.
Traits§
- Open
ApiInput Alg - States how a document describes one argument.
- Open
ApiInputs Alg - Describes the whole argument product one endpoint states, in declaration order.
- Open
ApiOutput Alg - States how a document describes what one output kind answers with.