From f5bfd8974ebb12eb0abb896085ead8a7d4b21f9c Mon Sep 17 00:00:00 2001 From: iliana etaoin Date: Thu, 2 Jul 2026 21:44:37 -0700 Subject: [PATCH] add ArtifactHash::v1_json_schema --- artifact/src/artifact.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/artifact/src/artifact.rs b/artifact/src/artifact.rs index 0de3073..6646eb8 100644 --- a/artifact/src/artifact.rs +++ b/artifact/src/artifact.rs @@ -93,6 +93,27 @@ pub struct ArtifactHash( pub [u8; 32], ); +impl ArtifactHash { + /// Return the JSON `Schema` that Tufaceous v1 formerly generated. + /// + /// This can be used with + /// `#[schemars(schema_with = "ArtifactHash::v1_json_schema")]`. + /// + /// This is intended to be used during the Tufaceous v2 transition period + /// and eventually will be removed. + #[cfg(feature = "schemars")] + pub fn v1_json_schema( + generator: &mut schemars::SchemaGenerator, + ) -> schemars::schema::Schema { + use schemars::JsonSchema; + + let mut schema: schemars::schema::SchemaObject = + ::json_schema(generator).into(); + schema.format = Some("hex string (32 bytes)".to_owned()); + schema.into() + } +} + impl AsRef<[u8]> for ArtifactHash { fn as_ref(&self) -> &[u8] { self.0.as_slice()