nori/ref/types
Types for $ref resolution across OpenAPI specification files.
Types
A parsed $ref value.
pub type ParsedRef {
LocalRef(pointer: List(String))
FileRef(path: String)
FileRefWithPointer(path: String, pointer: List(String))
}
Constructors
-
LocalRef(pointer: List(String))Local ref: #/components/schemas/User
-
FileRef(path: String)File ref: ./components/schemas/user.yaml
-
FileRefWithPointer(path: String, pointer: List(String))File ref with pointer: ./schemas.yaml#/User
Context for $ref resolution, tracking state across recursive resolution.
pub type RefContext {
RefContext(
base_dir: String,
file_cache: dict.Dict(String, value.YamlValue),
visited: set.Set(String),
root: value.YamlValue,
)
}
Constructors
-
RefContext( base_dir: String, file_cache: dict.Dict(String, value.YamlValue), visited: set.Set(String), root: value.YamlValue, )Arguments
- base_dir
-
Base directory for resolving relative file paths
- file_cache
-
Cache of already-loaded and parsed files (filepath → YamlValue)
- visited
-
Set of $ref strings currently being resolved (cycle detection)
- root
-
The root document’s YamlValue (for local #/ refs)
Errors that can occur during $ref resolution.
pub type RefError {
FileNotFound(path: String)
ParseError(path: String, message: String)
CircularReference(ref_chain: List(String))
InvalidRefFormat(ref: String)
RefTargetNotFound(ref: String, pointer: String)
}
Constructors
-
FileNotFound(path: String)Referenced file could not be found or read
-
ParseError(path: String, message: String)File could not be parsed as YAML
-
CircularReference(ref_chain: List(String))Circular $ref chain detected
-
InvalidRefFormat(ref: String)$ref string format is invalid
-
RefTargetNotFound(ref: String, pointer: String)Target path within a document could not be found
Values
pub fn new_context(
base_dir: String,
root: value.YamlValue,
) -> RefContext
Creates a new RefContext for resolving refs from a given base directory.