MCPcopy Create free account
hub / github.com/AIScientists-Dev/Flowtrace / resolve

Function resolve

crates/flowtrace-cli/src/explain.rs:99–143  ·  view source on GitHub ↗

Follow `$ref` references through the root's definitions to land on a concrete SchemaObject. Returns the input unchanged if no ref. Also handles schemars' `allOf: [{"$ref": "..."}]` wrapping, which it emits when a field with a `#[doc = "..."]` comment has a typed reference target — the description goes on the wrapper, the actual type sits inside `allOf`.

(root: &'a RootSchema, s: &'a SchemaObject)

Source from the content-addressed store, hash-verified

97/// when a field with a `#[doc = "..."]` comment has a typed reference target —
98/// the description goes on the wrapper, the actual type sits inside `allOf`.
99fn resolve<'a>(root: &'a RootSchema, s: &'a SchemaObject) -> &'a SchemaObject {
100 let mut cur = s;
101 loop {
102 // Direct $ref.
103 if let Some(reference) = cur.reference.as_deref() {
104 let name = reference.trim_start_matches("#/definitions/");
105 match root.definitions.get(name) {
106 Some(Schema::Object(obj)) => {
107 cur = obj;
108 continue;
109 }
110 _ => return cur,
111 }
112 }
113 // allOf-wrapped ref (single ref-only entry).
114 if let Some(sub) = cur.subschemas.as_ref() {
115 if let Some(all_of) = sub.all_of.as_ref() {
116 if all_of.len() == 1 {
117 if let Schema::Object(inner) = &all_of[0] {
118 if inner.reference.is_some() {
119 cur = inner;
120 continue;
121 }
122 }
123 }
124 }
125 // anyOf-wrapped Option<T>: pick the single non-null ref.
126 if let Some(any_of) = sub.any_of.as_ref() {
127 let ref_arm = any_of.iter().find_map(|sch| {
128 if let Schema::Object(o) = sch {
129 if o.reference.is_some() {
130 return Some(o);
131 }
132 }
133 None
134 });
135 if let Some(inner) = ref_arm {
136 cur = inner;
137 continue;
138 }
139 }
140 }
141 return cur;
142 }
143}
144
145/// Descend one path segment. Handles:
146/// - object properties (`reply.headline`)

Callers 6

navigateFunction · 0.70
step_intoFunction · 0.70
tagged_variant_propertyFunction · 0.70
render_plaintextFunction · 0.70
unwrap_containerFunction · 0.70
example_forFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…