nori/reference
Reference handling for OpenAPI specifications.
OpenAPI allows objects to be defined inline or referenced via JSON Reference ($ref).
This module provides the generic Ref type to handle both cases uniformly.
Types
Generic type for values that can be either inline or a JSON Reference ($ref).
This pattern is used extensively in OpenAPI specs where objects can be defined inline or referenced from the components section.
Examples
// An inline schema
let inline = Inline(Schema(schema_type: Some(TypeString), ..))
// A reference to a component
let ref = Reference("#/components/schemas/User")
pub type Ref(a) {
Inline(value: a)
Reference(ref: String)
}
Constructors
-
Inline(value: a)An inline value of type
a -
Reference(ref: String)A JSON Reference string (e.g., “#/components/schemas/User”)
Values
pub fn flat_map(ref: Ref(a), f: fn(a) -> Ref(b)) -> Ref(b)
Applies a function that returns a Ref to an inline value.
pub fn get_ref(ref: Ref(a)) -> Result(String, Nil)
Gets the reference string if this is a Reference, otherwise None.
pub fn is_reference(ref: Ref(a)) -> Bool
Checks if a Ref is a reference (not inline).