Repository navigation
Conversation
03c70d5 to
e7c73b3
Compare
|
I haven't looked at this closely, but first:
|
Actually I haven't, feature flag was my initial gut feeling. But you may be right. As chrono is only a dev dependency it wouldn't pollute consumer code when the generated code doesn't need it. I'll change it to a generation input setting.
schemars has an open PR GREsau/schemars#547 for adding jiff support, but this would only work if we update schemars to 1.x (as far as I can see), which has its own difficulties. |
| (format, _) => { | ||
| self.convert_format(type_name, original_schema, metadata, format, validation) |
There was a problem hiding this comment.
this seems a bit odd. convert_format is convert_string minus date and date-time?
| .into_iter() | ||
| .collect::<TypespaceTraitSet>(), | ||
| ), | ||
| TypeEntry::new_native(date_path(format, library), date_traits(library)), |
There was a problem hiding this comment.
perhaps date_path and date_traits and be in the same function that just returns the TypeEntry
| value_parser = ["chrono", "jiff", "string"], | ||
| default_value = "chrono" | ||
| )] | ||
| date_library: String, |
There was a problem hiding this comment.
I bet this could be the enum rather than a string
| /// The crates needed for native types: `uuid` and the date library | ||
| /// (`chrono` or `jiff`) for the string formats they map to, and each crate an `x-rust-type` extension | ||
| /// names, at the version [`TypeSpaceSettings::with_crate`] declared for | ||
| /// it. Recorded on the `TypespaceBuilder` so the finalized typespace | ||
| /// reports them with the crates of what typespace renders itself. |
| /// Plain `String`s. Length and pattern constraints still apply; the format | ||
| /// itself is not validated. | ||
| String, |
There was a problem hiding this comment.
explain that the benefit is no dependency
| @@ -0,0 +1,176 @@ | |||
| #![deny(warnings)] | |||
There was a problem hiding this comment.
let's not make a new subdirectory; follow an existing pattern for this
| * The `date` and `date-time` string formats can be represented by `chrono` | ||
| (the default), `jiff`, or plain `String`s, chosen per generation with | ||
| `DateLibrary` (`date_library` in the macro, `--date-library` in the CLI). | ||
| Types from `jiff` do not implement `JsonSchema`. |
There was a problem hiding this comment.
| * The `date` and `date-time` string formats can be represented by `chrono` | |
| (the default), `jiff`, or plain `String`s, chosen per generation with | |
| `DateLibrary` (`date_library` in the macro, `--date-library` in the CLI). | |
| Types from `jiff` do not implement `JsonSchema`. | |
| * The `date` and `date-time` string formats can be represented using `chrono` | |
| (the default) or `jiff`, or as `String`s, chosen via generation settings | |
| `DateLibrary` (`date_library` in the macro, `--date-library` in the CLI). | |
| NB: types from `jiff` do not implement `JsonSchema`. |
resolves #1111
dateanddate-timestring formats are now mapped to a date library chosen by Cargo feature.chronostays the default, so existing output is unchanged.jiffis available as an alternative, and it takes precedence when both are enabled. With neither feature, dates are plain Strings.Changes:
typify-implhaschrono(default) andjiffmarker features. typify emits the paths and never links either crate, so these only select which path is generatedtypify,typify-macro, andcargo-typifyforward the features.typify,typify-impl, andtypify-macronow setdefault-features = false. Cargo doesn't allow a member to override default-features on an inherited dependency, so this is the only way to let each crate choose.Remarks:
jifftypes omitJsonSchema.schemars0.8, which typify uses, has nojiffimpl.JsonSchemaand holds ajiffdateis refused when rendered, with an error naming::jiff::Timestamp.chronogolden files only run under chronojiffsTimestampis notchronosDateTime, API differs