#[non_exhaustive]pub enum RefError {
External {
ref_str: String,
},
TargetNotFound {
ref_str: String,
},
Cycle {
ref_str: String,
},
SiblingKeysIgnored {
ref_str: String,
},
}Expand description
Non-fatal error for a specific $ref pointer.
The resolver handled these gracefully by preserving the raw $ref object
in the output, but the reference was not expanded.
Use ref_str() to extract the $ref value without
pattern matching.
§Variants
| Variant | Cause | Raw $ref preserved? |
|---|---|---|
External | URI like https://… or ./file.json | Yes |
TargetNotFound | JSON Pointer resolves to nothing | Yes |
Cycle | Already visiting this ref (recursion loop) | Yes |
SiblingKeysIgnored | Resolved target is not an object; siblings dropped | No (ref resolved) |
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
External
External URI reference — not supported by this resolver.
Produced when a $ref value does not start with #. Examples:
https://example.com/schema.json, ./common.yaml#/Foo.
TargetNotFound
Internal reference target not found in the document.
The $ref starts with # but the JSON Pointer does not resolve to
any value in the root document.
Cycle
Circular reference detected — kept as raw $ref to break the cycle.
The target exists but is already being resolved in the current call
stack. The raw $ref object is preserved to prevent infinite recursion.
SiblingKeysIgnored
Sibling keys alongside $ref were dropped because the resolved
target is not a JSON object and merging is impossible.
The $ref itself was successfully resolved, but any sibling keys
(e.g. description, title) present in the same object were lost
because they cannot be merged into a non-object value.
Implementations§
Source§impl RefError
impl RefError
Sourcepub fn ref_str(&self) -> &str
pub fn ref_str(&self) -> &str
Returns the $ref string that caused this error.
This is a convenience accessor that avoids pattern matching when you only need the ref string regardless of the error variant.
§Example
use openapi_deref::RefError;
let err = RefError::TargetNotFound { ref_str: "#/missing".into() };
assert_eq!(err.ref_str(), "#/missing");