Skip to content
Snippets Groups Projects

Resolve "Invalid schema reference when using tuple struct"

Merged Maaz Ahmed requested to merge 4-invalid-schema-reference-when-using-tuple-struct into main
4 files
+ 35
3
Compare changes
  • Side-by-side
  • Inline
Files
4
+ 4
1
@@ -81,12 +81,15 @@ impl SchemaInspector {
@@ -81,12 +81,15 @@ impl SchemaInspector {
/// to retrieve them from the root schemas object
/// to retrieve them from the root schemas object
fn resolve_references(schemas: &Map<String, Value>, val: &mut Value) -> Result<(), InitError> {
fn resolve_references(schemas: &Map<String, Value>, val: &mut Value) -> Result<(), InitError> {
if let Some(target) = Self::extract_ref(val) {
if let Some(target) = Self::extract_ref(val) {
*val = schemas
let mut resolved_schema = schemas
.get(&target)
.get(&target)
.ok_or(InitError::ResolutionFailure(format!(
.ok_or(InitError::ResolutionFailure(format!(
"{target} not found in the given schemas"
"{target} not found in the given schemas"
)))?
)))?
.clone();
.clone();
 
// resolve any references within the resolved schema
 
Self::resolve_references(schemas, &mut resolved_schema)?;
 
*val = resolved_schema;
}
}
match val {
match val {
Value::Object(ref mut map) => {
Value::Object(ref mut map) => {
Loading