oaspec/codegen/context

Types

Context for code generation, carrying all needed state. Only accepts a resolved spec — codegen must not operate on unresolved ASTs.

Opaque: external callers construct via new/2 and read fields via the accessors spec/1 / config/1. This keeps the internal shape free to evolve (e.g. add derived caches) without rippling into every pattern match across the codebase.

pub opaque type Context

Target for a generated file, indicating where it should be written.

pub type FileTarget {
  SharedTarget
  ServerTarget
  ClientTarget
}

Constructors

  • SharedTarget
  • ServerTarget
  • ClientTarget

A generated file with its path, content, and output target.

pub type GeneratedFile {
  GeneratedFile(
    path: String,
    content: String,
    target: FileTarget,
  )
}

Constructors

  • GeneratedFile(path: String, content: String, target: FileTarget)

Values

pub fn config(ctx: Context) -> config.Config

The generation config this context wraps.

pub fn new(
  spec: spec.OpenApiSpec(spec.Resolved),
  config: config.Config,
) -> Context

Create a new generation context from a resolved spec.

pub fn spec(ctx: Context) -> spec.OpenApiSpec(spec.Resolved)

The resolved OpenAPI spec this context wraps.

pub const version: String

The version of oaspec used for generated code headers.

Search Document