nori_asyncapi/config

Configuration for code generation.

An asyncapi.config.yaml lets the two targets write to different places — the TypeScript client to a frontend project, the Gleam handlers to a backend one — which a single output directory cannot express. The CLI auto-detects the file, or takes --config=path. With no config it falls back to a default built from positional args.

spec: ./asyncapi.yaml
output:
  gleam:
    enabled: true
    dir: ./backend/src/generated
    types_module: generated/types
  typescript:
    enabled: true
    dir: ./frontend/src/api
    stores: true
    client_module: ./client

Types

Resolved generation config.

pub type Config {
  Config(
    spec: String,
    gleam: option.Option(GleamTarget),
    typescript: option.Option(TsTarget),
  )
}

Constructors

pub type ConfigError {
  ReadError(path: String)
  ParseError(message: String)
  DecodeErrors(errors: List(decode.DecodeError))
}

Constructors

  • ReadError(path: String)
  • ParseError(message: String)
  • DecodeErrors(errors: List(decode.DecodeError))

Gleam target: types + handler stubs.

pub type GleamTarget {
  GleamTarget(dir: String, types_module: String)
}

Constructors

  • GleamTarget(dir: String, types_module: String)

TypeScript target: client, and optionally the store layer.

pub type TsTarget {
  TsTarget(
    dir: String,
    stores: Bool,
    stores_dir: String,
    client_module: String,
    transport: String,
  )
}

Constructors

  • TsTarget(
      dir: String,
      stores: Bool,
      stores_dir: String,
      client_module: String,
      transport: String,
    )

    Arguments

    transport

    “channel” (per-channel clients, default) or “gateway” (one /ws, {type,payload} envelope — matches the Gleam server dispatcher).

Values

pub fn default(
  spec: String,
  out_dir: String,
  stores: Bool,
) -> Config

Default config from positional CLI args: both targets enabled, everything in one directory. Matches the pre-config CLI behaviour.

pub fn load(path: String) -> Result(Config, ConfigError)

Load and parse a config file.

Search Document