1
0
Fork 0

correctly generate field type names for referenced enums

This commit is contained in:
Cyborus 2024-04-26 12:55:32 -04:00
parent de7754073b
commit a1000e31bf
No known key found for this signature in database

View file

@ -72,12 +72,21 @@ fn schema_type_name(
match ty {
SchemaType::One(prim) => {
let name = match prim {
Primitive::String => match schema.format.as_deref() {
Primitive::String if schema._enum.is_none() => match schema.format.as_deref() {
Some("date") => "time::Date",
Some("date-time") => "time::OffsetDateTime",
_ => "String",
}
.to_string(),
Primitive::String => {
match (&schema.title, definition_name) {
// Some of the titles are actually descriptions; not sure why
// Checking for a space filters that out
(Some(title), _) if !title.contains(' ') => title.to_string(),
(_, Some(definition_name)) => definition_name.to_string(),
(_, None) => "String".to_string(),
}
}
Primitive::Number => match schema.format.as_deref() {
Some("float") => "f32",
Some("double") => "f64",