Skip to content

Commit 7d0d0be

Browse files
Add support for jiff::Timestamp (#1416)
1 parent b07397d commit 7d0d0be

File tree

7 files changed

+28
-8
lines changed

7 files changed

+28
-8
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ and the `ipa` is _api_ reversed. Aaand... `ipa` is also an awesome type of beer
8484
By default these types are parsed as `string`. `OffsetDateTime` and `PrimitiveDateTime` will use `date-time` format. `Date` will use
8585
`date` format and `Duration` will not have any format. To override default `string` representation users have to use `value_type` attribute
8686
to override the type. See [docs](https://docs.rs/utoipa/latest/utoipa/derive.ToSchema.html) for more details.
87-
- **`jiff_0_2`** Add support for [jiff 0.2](https://crates.io/crates/jiff) `Zoned`, and `civil::Date` types.
88-
By default these types are parsed as `string`. `Zoned` will use `date-time` format. `civil::Date` will use
87+
- **`jiff_0_2`** Add support for [jiff 0.2](https://crates.io/crates/jiff) `Timestamp`, `Zoned`, and `civil::Date` types.
88+
By default these types are parsed as `string`. `Timestamp` and `Zoned` will use `date-time` format. `civil::Date` will use
8989
`date` format. To override default `string` representation users have to use `value_type` attribute
9090
to override the type. See [docs](https://docs.rs/utoipa/latest/utoipa/derive.ToSchema.html) for more details.
9191
- **`decimal`**: Add support for [rust_decimal](https://crates.io/crates/rust_decimal) `Decimal` type. **By default**

utoipa-gen/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog - utoipa-gen
22

3+
## Unreleased
4+
5+
### Added
6+
7+
* Add support for jiff v0.2 `Timestamp` (https://github.com/juahku/utoipa/pull/1416)
8+
39
## 5.4.0 - Jun 16 2025
410

511
### Added

utoipa-gen/src/schema_type.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ impl SchemaType<'_> {
137137

138138
#[cfg(feature = "jiff_0_2")]
139139
if !primitive {
140-
primitive = matches!(name, "Zoned" | "Date");
140+
primitive = matches!(name, "Zoned" | "Date" | "Timestamp");
141141
}
142142

143143
primitive
@@ -301,7 +301,9 @@ impl ToTokensDiagnostics for SchemaType<'_> {
301301
schema_type_tokens(tokens, SchemaTypeInner::String, self.nullable)
302302
}
303303
#[cfg(feature = "jiff_0_2")]
304-
"Zoned" => schema_type_tokens(tokens, SchemaTypeInner::String, self.nullable),
304+
"Zoned" | "Timestamp" => {
305+
schema_type_tokens(tokens, SchemaTypeInner::String, self.nullable)
306+
}
305307
_ => schema_type_tokens(tokens, SchemaTypeInner::Object, self.nullable),
306308
};
307309

@@ -425,7 +427,7 @@ impl KnownFormat {
425427
"PrimitiveDateTime" | "OffsetDateTime" => Self::DateTime,
426428

427429
#[cfg(feature = "jiff_0_2")]
428-
"Zoned" => Self::DateTime,
430+
"Zoned" | "Timestamp" => Self::DateTime,
429431
_ => Self::Unknown,
430432
};
431433

@@ -750,7 +752,7 @@ impl PrimitiveType {
750752
}
751753

752754
#[cfg(feature = "jiff_0_2")]
753-
"Zoned" => {
755+
"Zoned" | "Timestamp" => {
754756
syn::parse_quote!(String)
755757
}
756758
_ => {

utoipa-gen/tests/schema_derive_test.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1670,6 +1670,7 @@ fn derive_component_with_time_feature() {
16701670
fn derive_component_with_jiff_0_2_feature() {
16711671
let doc = api_doc! {
16721672
struct Timetest {
1673+
timestamp: jiff::Timestamp,
16731674
civil_date: jiff::civil::Date,
16741675
zoned: jiff::Zoned,
16751676
}

utoipa-gen/tests/snapshots/schema_derive_test__derive_component_with_jiff_0_2_feature.snap

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,17 @@ expression: "&doc"
88
"format": "date",
99
"type": "string"
1010
},
11+
"timestamp": {
12+
"format": "date-time",
13+
"type": "string"
14+
},
1115
"zoned": {
1216
"format": "date-time",
1317
"type": "string"
1418
}
1519
},
1620
"required": [
21+
"timestamp",
1722
"civil_date",
1823
"zoned"
1924
],

utoipa/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
**`utoipa`** is in direct correlation with **`utoipa-gen`** ([CHANGELOG.md](../utoipa-gen/CHANGELOG.md)). You might want
44
to look into changes introduced to **`utoipa-gen`**.
55

6+
## Unreleased
7+
8+
### Added
9+
10+
* Add support for jiff v0.2 `Timestamp` (https://github.com/juahku/utoipa/pull/1416)
11+
612
## 5.4.0 - Jun 16 2025
713

814
### Added

utoipa/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@
8181
//! By default these types are parsed as `string`. `OffsetDateTime` and `PrimitiveDateTime` will use `date-time` format. `Date` will use
8282
//! `date` format and `Duration` will not have any format. To override default `string` representation users have to use `value_type` attribute
8383
//! to override the type. See [docs](https://docs.rs/utoipa/latest/utoipa/derive.ToSchema.html) for more details.
84-
//! * **`jiff_0_2`** Add support for [jiff 0.2](https://crates.io/crates/jiff) `Zoned`, and `civil::Date` types.
85-
//! By default these types are parsed as `string`. `Zoned` will use `date-time` format. `civil::Date` will use
84+
//! * **`jiff_0_2`** Add support for [jiff 0.2](https://crates.io/crates/jiff) `Timestamp`, `Zoned`, and `civil::Date` types.
85+
//! By default these types are parsed as `string`. `Timestamp` and `Zoned` will use `date-time` format. `civil::Date` will use
8686
//! `date` format. To override default `string` representation users have to use `value_type` attribute
8787
//! to override the type. See [docs](https://docs.rs/utoipa/latest/utoipa/derive.ToSchema.html) for more details.
8888
//! * **`decimal`** Add support for [rust_decimal](https://crates.io/crates/rust_decimal) `Decimal` type. **By default**

0 commit comments

Comments
 (0)