diff --git a/ssi-vc/Cargo.toml b/ssi-vc/Cargo.toml index 89b600468..7d5a7abde 100644 --- a/ssi-vc/Cargo.toml +++ b/ssi-vc/Cargo.toml @@ -37,6 +37,7 @@ ssi-core = { path = "../ssi-core", version = "0.1" } ssi-dids = { path = "../ssi-dids", version = "0.1.1" } ssi-json-ld = { path = "../ssi-json-ld", version = "0.2", default-features = false } ssi-ldp = { path = "../ssi-ldp", version = "0.3.0", default-features = false } +serde_with = "2.3.2" [target.'cfg(not(target_arch = "wasm32"))'.dependencies] chrono = { version = "0.4", features = ["serde"] } diff --git a/ssi-vc/src/lib.rs b/ssi-vc/src/lib.rs index 3647ea559..e6500e45c 100644 --- a/ssi-vc/src/lib.rs +++ b/ssi-vc/src/lib.rs @@ -8,6 +8,7 @@ mod cacao; pub mod revocation; use cacao::BindingDelegation; +use serde_with::{formats::PreferMany, serde_as, OneOrMany as SerdeWithOneOrMany}; pub use ssi_core::{one_or_many::OneOrMany, uri::URI}; use ssi_dids::did_resolve::{resolve_key, DIDResolver}; pub use ssi_dids::VerificationRelationship as ProofPurpose; @@ -49,6 +50,7 @@ pub const DEFAULT_CONTEXT_V2: &str = "https://www.w3.org/ns/credentials/v2"; // work around https://github.com/w3c/vc-test-suite/issues/103 pub const ALT_DEFAULT_CONTEXT: &str = "https://w3.org/2018/credentials/v1"; +#[serde_as] #[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] #[serde(rename_all = "camelCase")] pub struct Credential { @@ -73,6 +75,7 @@ pub struct Credential { #[serde(skip_serializing_if = "Option::is_none")] pub credential_status: Option, #[serde(skip_serializing_if = "Option::is_none")] + #[serde_as(deserialize_as = "Option>")] pub terms_of_use: Option>, #[serde(skip_serializing_if = "Option::is_none")] pub evidence: Option>,