Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle odd cases where schema is inaccurate #24

Merged
merged 2 commits into from
Feb 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/bindgen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,18 +154,23 @@ pub fn type_to_string(ty: &ReferenceOr<Schema>) -> String {
}
None => "i64",
};
return int_size.to_owned();
int_size.to_owned()
}
// JSON object, but Rust has no easy way to support this, so just ask for a string.
Type::Object(_) => "String".to_owned(),
Type::Object(_) => {
"Option<std::collections::HashMap<String, serde_json::Value>>".to_owned()
}
Type::Boolean(_) => "bool".to_owned(),
Type::Array(x) => {
let items = x.items.as_ref().unwrap().clone().unbox();
format!("Vec<{}>", type_to_string(&items))
}
},
SchemaKind::AllOf { all_of } => {
format!("Option<{}>", type_to_string(&all_of[0].clone()))
}
// Very likely a JSON object.
_ => "String".to_owned(),
_ => "serde_json::Value".to_owned(),
};
// If property is nullable, we treat it as an optional argument.
if item.schema_data.nullable {
Expand Down
Loading