oaisp/schema

A schema reference for an endpoint’s body, response, or parameter.

oaisp is non-intrusive: it never sees your decoders or encoders. You point an endpoint at a type by name with type_ref — resolved from the package interface at build time — or at an inline scalar via oaisp/param. How your handlers read and write that type is entirely yours.

Types

The primitive kinds an inline Scalar schema can take.

pub type ScalarKind {
  StringKind
  IntKind
  BoolKind
  FloatKind
}

Constructors

  • StringKind
  • IntKind
  • BoolKind
  • FloatKind

How an endpoint element’s schema is described in the document.

pub type Schema {
  TypeRef(module: String, name: String)
  Scalar(kind: ScalarKind, description: option.Option(String))
}

Constructors

  • TypeRef(module: String, name: String)

    A reference to a public Gleam type, resolved at merge time from the package interface. module is the full module path (e.g. "myapp/types") and name the type’s name ("Todo").

  • Scalar(kind: ScalarKind, description: option.Option(String))

    An inline scalar, used for path and query parameters where a full type reference would be overkill.

Values

pub fn type_ref(
  module module: String,
  name name: String,
) -> Schema

A Schema referring to a public Gleam type, resolved at merge time from the package interface.

Search Document