Docs: std.md now displays correct number of members of an array (#825)

* First draft up

* removed print statements

* running cargo fmt

---------

Co-authored-by: Jess Frazelle <jessfraz@users.noreply.github.com>
This commit is contained in:
Alfredo Gutierrez
2023-10-11 13:12:21 -05:00
committed by GitHub
parent 8ad1476c13
commit 03bc2eaf22
2 changed files with 602 additions and 592 deletions

File diff suppressed because it is too large Load Diff

View File

@ -316,7 +316,17 @@ pub fn get_type_string_from_schema(schema: &schemars::schema::Schema) -> Result<
if let Some(array_val) = &o.array {
if let Some(schemars::schema::SingleOrVec::Single(items)) = &array_val.items {
// Let's print out the object's properties.
return Ok((format!("[{}]", get_type_string_from_schema(items)?.0), false));
match array_val.max_items {
Some(val) => {
return Ok((
format!("[{}]", (0..val).map(|_| "number").collect::<Vec<_>>().join(", ")),
false,
));
}
None => {
return Ok((format!("[{}]", get_type_string_from_schema(items)?.0), false));
}
};
} else if let Some(items) = &array_val.contains {
return Ok((format!("[{}]", get_type_string_from_schema(items)?.0), false));
}