Note - I'm doing this programatically, so examples are in Rust not config files.
I've got the following type mapping config:
let types = TypeMappingConfig {
date: DateStrategy::Time,
date_time: DateStrategy::Time,
time: DateStrategy::Time,
..TypeMappingConfig::default()
};
And generally this works fine. However, the OpenAPI spec I'm building from includes this:
"proration_date": {
"type": "string",
"format": "date",
"description": "The day the subscription item was prorated from. Only available in some responses."
},
And it's not a required field. As a result, the generated code is:
///The day the subscription item was prorated from. Only available in some responses.
#[serde(
skip_serializing_if = "Option::is_none",
with = "time::serde::iso8601::option"
)]
pub proration_date: Option<time::Date>,
The problem is that the time::serde::iso8601::option module only supports time::OffsetDateTime and not time::Date. As such, I get this error at build time:
error[E0308]: `?` operator has incompatible types
--> /target/debug/build/raven-76e16e45b6f09871/out/clerk/backend/types.rs:7268:16
|
7268 | with = "time::serde::iso8601::option"
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Option<Date>`, found `Option<OffsetDateTime>`
|
= note: `?` operator cannot convert from `std::option::Option<OffsetDateTime>` to `std::option::Option<time::Date>`
= note: expected enum `std::option::Option<time::Date>`
found enum `std::option::Option<OffsetDateTime>`
error[E0308]: mismatched types
--> /target/debug/build/raven-76e16e45b6f09871/out/clerk/backend/types.rs:7211:37
|
7211 | #[derive(Debug, Clone, Deserialize, Serialize)]
| ^^^^^^^^^ expected `&Option<OffsetDateTime>`, found `&Option<Date>`
...
7268 | with = "time::serde::iso8601::option"
| ------------------------------ arguments to this function are incorrect
|
= note: expected reference `&std::option::Option<OffsetDateTime>`
found reference `&'__a std::option::Option<time::Date>`
note: function defined here
--> /.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/time-0.3.53/src/serde/iso8601.rs:68:12
|
68 | pub fn serialize<S>(option: &Option<OffsetDateTime>, serializer: S) -> Result<S::Ok, S::Error>
| ^^^^^^^^^
= note: this error originates in the derive macro `Serialize` (in Nightly builds, run with -Z macro-backtrace for more info)
For more information about this error, try `rustc --explain E0308`.
error: could not compile `raven` (lib) due to 3 previous errors
As such, for now I've had to set the date field to just beDateStrategy::String for my code to build. So I've got a workaround, but it would be good if this could be fixed.
Cheers
Note - I'm doing this programatically, so examples are in Rust not config files.
I've got the following type mapping config:
And generally this works fine. However, the OpenAPI spec I'm building from includes this:
And it's not a required field. As a result, the generated code is:
The problem is that the
time::serde::iso8601::optionmodule only supportstime::OffsetDateTimeand nottime::Date. As such, I get this error at build time:As such, for now I've had to set the
datefield to just beDateStrategy::Stringfor my code to build. So I've got a workaround, but it would be good if this could be fixed.Cheers