-
Notifications
You must be signed in to change notification settings - Fork 211
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
std::time::SystemTime
support
#1222
Comments
This is actually same issue as with any other type that does not implement There would be a need to add support for the |
@juhaku Hmm, so something like: #[derive(ToSchema)]
#[schema(as = SystemTime, value_type = SystemTime)]
struct MySystemTime(SystemTime); Or more something like: impl PrimitiveType {
pub fn new(path: &Path) -> Option<PrimitiveType> {
let last_segment = path.segments.last().unwrap_or_else(|| {
panic!(
"Path for DefaultType must have at least one segment: `{path}`",
path = path.to_token_stream()
)
});
let name = &*last_segment.ident.to_string();
let ty: syn::Type = match name {
"String" | "str" | "char" => syn::parse_quote!(#path),
"bool" => syn::parse_quote!(#path),
"i8" | "i16" | "i32" | "i64" | "i128" | "isize" | "u8" | "u16" | "u32" | "u64"
| "u128" | "usize" => syn::parse_quote!(#path),
"f32" | "f64" => syn::parse_quote!(#path),
"SystemTime" => syn::parse_quote!(#SystemTime), Or even combine the two: "SystemTime" => syn::parse_quote!(#MySystemTime), |
FWIW: In the interim; for this project; I've switched to chrono from diesel up to utoipa. |
How the [derive(ToSchema)]
#[schema(as = SystemTime, value_type = String)] // This will treat it as a String,
struct MySystemTime(SystemTime); |
But in order to make utoipa/utoipa-gen/src/schema_type.rs Line 253 in a0c3415
|
I've tried enabling crate features of
chrono
ortime
; to no avail.How do I get this to work?
The text was updated successfully, but these errors were encountered: