openapi-deref
Lightweight OpenAPI / JSON Schema $ref resolver for Rust.
Recursively expands all $ref pointers in a serde_json::Value, producing a self-contained document with no unresolved references.
Features
- Resolves internal
$refvia JSON Pointer (RFC 6901) - OpenAPI 3.1 compatible: sibling keys alongside
$refare merged - Cycle detection with a visited-path set
- Typed error model: fatal
ResolveErrorvs non-fatalRefError resolve_strictfor zero-tolerance mode- Diagnostics: inspect cycles, missing refs, and external refs individually
- Zero dependencies beyond
serde_jsonandthiserror
Quick start
use json;
let value = resolve_strict.unwrap;
assert_eq!;
API levels
| Function | Returns | Use when |
|---|---|---|
resolve_strict |
Result<Value, StrictResolveError> |
Any unresolved ref is unacceptable |
resolve |
Result<ResolvedDoc, ResolveError> |
You need to inspect partial results or diagnostics |
resolve_with_root |
Result<ResolvedDoc, ResolveError> |
The ref lookup root differs from the target value |
Error handling
Non-fatal ref errors are collected in ResolvedDoc and can be inspected:
use json;
use resolve;
let spec = json!;
let doc = resolve.unwrap;
assert_eq!;
assert_eq!;
assert_eq!;
License
Licensed under either of
- MIT license (LICENSE-MIT)
- Apache License, Version 2.0 (LICENSE-APACHE)
at your option.