oaisp
oaisp — a code-first OpenAPI 3.1 generator for Wisp applications on the BEAM.
You declare your API as a list of Routes — each
binding a path + method to a handler and carrying its OpenAPI annotations.
That single list drives both your running server (route.match) and the
emitted document, so the two can’t drift. One CLI command
(gleam run -m oaisp/cli generate) writes a truthful OpenAPI 3.1 document
at build time.
This module is the public surface. The route builders live in
oaisp/route, scalar param helpers in
oaisp/param, and the CLI in
oaisp/cli.
Types
A route: a path + method bound to a handler, plus its OpenAPI annotations.
See oaisp/route.
pub type Route(handler) =
route.Route(handler)
A schema reference for a body, response, or parameter. See
oaisp/schema.
pub type Schema =
schema.Schema
Values
pub fn add_openapi(
builder: a,
routes: List(route.Route(handler)),
info: info.Info,
) -> a
The build-time hook. Drop it into your server builder pipeline alongside the
same routes you dispatch with route.match:
wisp_mist.handler(handle(routes), secret_key_base)
|> mist.new
|> oaisp.add_openapi(routes, info)
|> mist.port(8080)
|> mist.start
Run with --emit-endpoints (as the CLI does internally) it prints the
declarations and exits; otherwise it returns builder untouched. It is
generic in the builder and never inspects it, so oaisp needs no dependency
on mist or any server library.
pub fn info(
title title: String,
version version: String,
) -> info.Info
Document metadata with no description and no servers; spread to override.
pub fn type_ref(
module module: String,
name name: String,
) -> schema.Schema
A schema referring to a public Gleam type, resolved at merge time from the package interface.