Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 30 additions & 21 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ object_store = { version = "0.13.0", features = ["aws", "azure", "gcp"] }
octocrab = { version = "0.44.1" }
opentelemetry = { version = "0.31" }
opentelemetry-contrib = { version = "0.23" }
opentelemetry-http = { version = "0.31" }
opentelemetry-otlp = { version = "0.31" }
opentelemetry-semantic-conventions = { version = "0.31" }
opentelemetry_sdk = { version = "0.31" }
Expand All @@ -201,7 +200,6 @@ prost-dto = { version = "0.0.4" }
prost-types = { version = "0.14.1" }
quote = "1"
rand = "0.9.2"
rangemap = "1.7.1"
regex = { version = "1.12" }
reqwest = { version = "0.12", default-features = false, features = [
"json",
Expand All @@ -215,7 +213,7 @@ rocksdb = { version = "0.43.0", package = "rust-rocksdb", features = [
], git = "https://github.com/restatedev/rust-rocksdb", rev = "de8911652d398e9bfbb6bbc42a7b4f7296f6d101" }
rstest = "0.26.1"
rustls = { version = "0.23.35", default-features = false, features = ["ring"] }
schemars = { version = "0.8", features = ["bytes", "enumset"] }
schemars = { version = "1.2", features = ["bytes1"] }
semver = { version = "1.0", features = ["serde"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
Expand Down
48 changes: 20 additions & 28 deletions crates/serde-util/src/byte_count.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,32 +23,28 @@ pub type NonZeroByteCount = ByteCount<false>;

#[cfg(feature = "schema")]
impl schemars::JsonSchema for ByteCount<true> {
fn schema_name() -> String {
"HumanBytes".to_owned()
fn schema_name() -> std::borrow::Cow<'static, str> {
"HumanBytes".into()
}

fn schema_id() -> std::borrow::Cow<'static, str> {
std::borrow::Cow::Owned(std::concat!(std::module_path!(), "::", "HumanBytes").to_owned())
}

fn json_schema(generator: &mut schemars::r#gen::SchemaGenerator) -> schemars::schema::Schema {
let mut schema: schemars::schema::SchemaObject = generator.subschema_for::<String>().into();
schema.format = Some("human-bytes".to_owned());
let validation = schema.string();
validation.pattern = Some(r"^\d+(\.\d+)? ?[KMG]B$".to_string());
validation.min_length = Some(1);
let validation = schema.number();
validation.minimum = Some(1.0);
let metadata = schema.metadata();
metadata.title = Some("Human-readable bytes".to_owned());
metadata.description = Some("Human-readable bytes".to_owned());
schema.into()
fn json_schema(_generator: &mut schemars::SchemaGenerator) -> schemars::Schema {
schemars::json_schema!({
"type": "string",
"pattern": r"^\d+(\.\d+)? ?[KMG]B$",
"minLength": 1,
"title": "Human-readable bytes",
"description": "Human-readable bytes",
})
}
}
#[cfg(feature = "schema")]
impl schemars::JsonSchema for ByteCount<false> {
fn schema_name() -> String {
"NonZeroHumanBytes".to_owned()
fn schema_name() -> std::borrow::Cow<'static, str> {
"NonZeroHumanBytes".into()
}

fn schema_id() -> std::borrow::Cow<'static, str> {
Expand All @@ -57,18 +53,14 @@ impl schemars::JsonSchema for ByteCount<false> {
)
}

fn json_schema(generator: &mut schemars::r#gen::SchemaGenerator) -> schemars::schema::Schema {
let mut schema: schemars::schema::SchemaObject = generator.subschema_for::<String>().into();
schema.format = Some("non-zero human-bytes".to_owned());
let validation = schema.string();
validation.pattern = Some(r"^\d+(\.\d+)? ?[KMG]B$".to_string());
validation.min_length = Some(1);
let validation = schema.number();
validation.minimum = Some(1.0);
let metadata = schema.metadata();
metadata.title = Some("Non-zero human-readable bytes".to_owned());
metadata.description = Some("Non-zero human-readable bytes".to_owned());
schema.into()
fn json_schema(_generator: &mut schemars::SchemaGenerator) -> schemars::Schema {
schemars::json_schema!({
"type": "string",
"pattern": r"^\d+(\.\d+)? ?[KMG]B$",
"minLength": 1,
"title": "Non-zero human-readable bytes",
"description": "Non-zero human-readable bytes",
})
}
}

Expand Down
68 changes: 33 additions & 35 deletions crates/time-util/src/duration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -586,8 +586,8 @@ impl<'de, const CAN_BE_ZERO: bool> serde::de::Deserialize<'de> for Duration<CAN_

#[cfg(feature = "schema")]
impl schemars::JsonSchema for FriendlyDuration {
fn schema_name() -> String {
"FriendlyDuration".to_owned()
fn schema_name() -> std::borrow::Cow<'static, str> {
"FriendlyDuration".into()
}

fn schema_id() -> std::borrow::Cow<'static, str> {
Expand All @@ -596,29 +596,28 @@ impl schemars::JsonSchema for FriendlyDuration {
)
}

fn json_schema(generator: &mut schemars::SchemaGenerator) -> schemars::schema::Schema {
let mut schema: schemars::schema::SchemaObject = generator.subschema_for::<String>().into();
let validation = schema.string();
validation.min_length = Some(1);
let metadata = schema.metadata();
metadata.title = Some("Human-readable duration".to_owned());
metadata.description = Some("Duration string in either jiff human friendly or ISO8601 format. Check https://docs.rs/jiff/latest/jiff/struct.Span.html#parsing-and-printing for more details.".to_owned());
metadata.examples = vec![
serde_json::Value::String("10 hours".to_owned()),
serde_json::Value::String("5 days".to_owned()),
serde_json::Value::String("5d".to_owned()),
serde_json::Value::String("1h 4m".to_owned()),
serde_json::Value::String("P40D".to_owned()),
serde_json::Value::String("0".to_owned()),
];
schema.into()
fn json_schema(_generator: &mut schemars::SchemaGenerator) -> schemars::Schema {
schemars::json_schema!({
"type": "string",
"minLength": 1,
"title": "Human-readable duration",
"description": "Duration string in either jiff human friendly or ISO8601 format. Check https://docs.rs/jiff/latest/jiff/struct.Span.html#parsing-and-printing for more details.",
"examples": [
"10 hours",
"5 days",
"5d",
"1h 4m",
"P40D",
"0"
]
})
}
}

#[cfg(feature = "schema")]
impl schemars::JsonSchema for NonZeroFriendlyDuration {
fn schema_name() -> String {
"NonZeroFriendlyDuration".to_owned()
fn schema_name() -> std::borrow::Cow<'static, str> {
"NonZeroFriendlyDuration".into()
}

fn schema_id() -> std::borrow::Cow<'static, str> {
Expand All @@ -627,21 +626,20 @@ impl schemars::JsonSchema for NonZeroFriendlyDuration {
)
}

fn json_schema(generator: &mut schemars::SchemaGenerator) -> schemars::schema::Schema {
let mut schema: schemars::schema::SchemaObject = generator.subschema_for::<String>().into();
let validation = schema.string();
validation.min_length = Some(1);
let metadata = schema.metadata();
metadata.title = Some("Non-zero human-readable duration".to_owned());
metadata.description = Some("Non-zero duration string in either jiff human friendly or ISO8601 format. Check https://docs.rs/jiff/latest/jiff/struct.Span.html#parsing-and-printing for more details.".to_owned());
metadata.examples = vec![
serde_json::Value::String("10 hours".to_owned()),
serde_json::Value::String("5 days".to_owned()),
serde_json::Value::String("5d".to_owned()),
serde_json::Value::String("1h 4m".to_owned()),
serde_json::Value::String("P40D".to_owned()),
];
schema.into()
fn json_schema(_generator: &mut schemars::SchemaGenerator) -> schemars::Schema {
schemars::json_schema!({
"type": "string",
"minLength": 1,
"title": "Non-zero human-readable duration",
"description": "Non-zero duration string in either jiff human friendly or ISO8601 format. Check https://docs.rs/jiff/latest/jiff/struct.Span.html#parsing-and-printing for more details.",
"examples": [
"10 hours",
"5 days",
"5d",
"1h 4m",
"P40D",
]
})
}
}

Expand Down
Loading
Loading