correctly generate field type names for referenced enums
This commit is contained in:
parent
de7754073b
commit
a1000e31bf
|
@ -72,12 +72,21 @@ fn schema_type_name(
|
||||||
match ty {
|
match ty {
|
||||||
SchemaType::One(prim) => {
|
SchemaType::One(prim) => {
|
||||||
let name = match 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::Date",
|
||||||
Some("date-time") => "time::OffsetDateTime",
|
Some("date-time") => "time::OffsetDateTime",
|
||||||
_ => "String",
|
_ => "String",
|
||||||
}
|
}
|
||||||
.to_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() {
|
Primitive::Number => match schema.format.as_deref() {
|
||||||
Some("float") => "f32",
|
Some("float") => "f32",
|
||||||
Some("double") => "f64",
|
Some("double") => "f64",
|
||||||
|
|
Loading…
Reference in a new issue