nori/capability

Capability registry — detect OpenAPI features nori does not yet support.

Walk a parsed Document and surface anything the codegen would either silently drop, generate broken output for, or interpret incorrectly. Run this before generate (or alongside validate) so users hit a clear error instead of mysterious runtime / compile failures.

Example

let assert Ok(doc) = nori.parse_file("api.yaml")
case nori/capability.check(doc) {
  Ok(_) -> generate(doc)
  Error(issues) -> {
    list.each(issues, fn(i) { io.println(capability.issue_to_string(i)) })
    panic as "spec uses unsupported features"
  }
}

Types

A single unsupported-feature occurrence in a spec.

pub type Issue {
  Issue(
    name: String,
    location: String,
    reason: String,
    severity: Severity,
  )
}

Constructors

  • Issue(
      name: String,
      location: String,
      reason: String,
      severity: Severity,
    )

    Arguments

    name

    Short identifier for the unsupported capability (e.g. "discriminator").

    location

    JSON-pointer-style location in the document (e.g. "#/paths/~1users/get/parameters/0/style").

    reason

    Human-readable explanation suitable for CLI output.

    severity

    Severity tier — Blocking aborts codegen, Warning allows it with --allow-unsupported.

How seriously to treat a detected issue.

pub type Severity {
  Blocking
  Warning
}

Constructors

  • Blocking

    Generated code would be broken or incorrect — must not proceed.

  • Warning

    Spec uses something nori interprets loosely or partially.

Values

pub fn blocking(issues: List(Issue)) -> List(Issue)

Convenience: only the blocking issues.

pub fn check(
  doc: document.Document,
) -> Result(document.Document, List(Issue))

Walk the document and collect every unsupported-feature occurrence.

Returns the document unchanged if nothing was flagged, otherwise a list of issues sorted by severity (blocking first).

pub fn issue_to_string(issue: Issue) -> String

Format a single issue for CLI output.

Search Document