feat(torn-api): add chrono for datetime support
This commit is contained in:
parent
266122ea0e
commit
7a4f6462f5
7 changed files with 741 additions and 22 deletions
|
|
@ -15,6 +15,7 @@ pub enum PrimitiveType {
|
|||
I64,
|
||||
String,
|
||||
Float,
|
||||
DateTime,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
|
|
@ -35,6 +36,9 @@ impl PropertyType {
|
|||
Self::Primitive(PrimitiveType::String) => {
|
||||
Some(format_ident!("String").into_token_stream())
|
||||
}
|
||||
Self::Primitive(PrimitiveType::DateTime) => {
|
||||
Some(quote! { chrono::DateTime<chrono::Utc> })
|
||||
}
|
||||
Self::Primitive(PrimitiveType::Float) => Some(format_ident!("f64").into_token_stream()),
|
||||
Self::Ref(path) => {
|
||||
let name = path.strip_prefix("#/components/schemas/")?;
|
||||
|
|
@ -211,6 +215,7 @@ impl Property {
|
|||
PrimitiveType::Float
|
||||
}
|
||||
(Some("string"), None) => PrimitiveType::String,
|
||||
(Some("string"), Some("date")) => PrimitiveType::DateTime,
|
||||
(Some("boolean"), None) => PrimitiveType::Bool,
|
||||
_ => return None,
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue