oaspec/openapi/value

Types

A JSON-compatible value type for preserving arbitrary data from OpenAPI specs. Used for example, default, const, and other values that aren’t necessarily strings.

pub type JsonValue {
  JsonNull
  JsonBool(Bool)
  JsonInt(Int)
  JsonFloat(Float)
  JsonString(String)
  JsonArray(List(JsonValue))
  JsonObject(dict.Dict(String, JsonValue))
}

Constructors

  • JsonNull
  • JsonBool(Bool)
  • JsonInt(Int)
  • JsonFloat(Float)
  • JsonString(String)
  • JsonArray(List(JsonValue))
  • JsonObject(dict.Dict(String, JsonValue))

Values

pub fn extract_map(
  node: yay.Node,
  key: String,
) -> dict.Dict(String, JsonValue)

Extract a dict of JsonValues from a node at a given key. Returns empty dict if key is absent.

pub fn extract_optional(
  node: yay.Node,
  key: String,
) -> option.Option(JsonValue)

Try to extract a JsonValue from a node at a given key. Returns None if the key is absent or nil.

pub fn from_node(node: yay.Node) -> JsonValue

Convert a yay.Node to a JsonValue.

pub fn to_display_string(value: JsonValue) -> String

Convert a JsonValue to a display string (for error messages, not serialization).

Search Document