Skip to main content

relocate_refs

Function relocate_refs 

Source
pub fn relocate_refs(value: &mut Value, prefix: &str)
Expand description

Rewrites #/$defs/X to {prefix}X throughout value, in place.

Recurses through objects and arrays, and only touches string values under a $ref key — a description that happens to mention #/$defs/ is left alone. Refs that do not start with #/$defs/ (absolute URLs, refs already relocated) are untouched, which makes this idempotent.

Termination: this walks the finished Value tree, not the type graph. to_json_schema reserves a $defs slot before recursing into struct fields, so recursive types produce a finite tree containing a $ref back to themselves, not an infinite one.