Skip to content

Commit 606385f

Browse files
fix openApi attributes to keyset id to present it as a string
The attribute `schema(as = String)` does not result in the expected behaviour. It does not convert Id to being represented as a simple string, but rather simply rename the type `Id` to `String`. This commit removes the attribute that implements utoipa::ToSchema trait for type `Id` and adds attribute to all the types that have a keyset id as inner type to represent it as string.
1 parent e1458b0 commit 606385f

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

crates/cashu/src/nuts/nut00/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ pub struct BlindedMessage {
116116
///
117117
/// ID from which we expect a signature.
118118
#[serde(rename = "id")]
119+
#[cfg_attr(feature = "swagger", schema(value_type = String))]
119120
pub keyset_id: Id,
120121
/// Blinded secret message (B_)
121122
///
@@ -161,6 +162,7 @@ pub struct BlindSignature {
161162
///
162163
/// ID of the mint keys that signed the token.
163164
#[serde(rename = "id")]
165+
#[cfg_attr(feature = "swagger", schema(value_type = String))]
164166
pub keyset_id: Id,
165167
/// Blinded signature (C_)
166168
///
@@ -240,6 +242,7 @@ pub struct Proof {
240242
pub amount: Amount,
241243
/// `Keyset id`
242244
#[serde(rename = "id")]
245+
#[cfg_attr(feature = "swagger", schema(value_type = String))]
243246
pub keyset_id: Id,
244247
/// Secret message
245248
#[cfg_attr(feature = "swagger", schema(value_type = String))]

crates/cashu/src/nuts/nut02.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ pub enum Error {
5151

5252
/// Keyset version
5353
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
54-
#[cfg_attr(feature = "swagger", derive(utoipa::ToSchema))]
5554
pub enum KeySetVersion {
5655
/// Current Version 00
5756
Version00,
@@ -88,7 +87,6 @@ impl fmt::Display for KeySetVersion {
8887
/// which mint or keyset it was generated from.
8988
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
9089
#[serde(into = "String", try_from = "String")]
91-
#[cfg_attr(feature = "swagger", derive(utoipa::ToSchema), schema(as = String))]
9290
pub struct Id {
9391
version: KeySetVersion,
9492
id: [u8; Self::BYTELEN],
@@ -221,6 +219,7 @@ pub struct KeysetResponse {
221219
#[cfg_attr(feature = "swagger", derive(utoipa::ToSchema))]
222220
pub struct KeySet {
223221
/// Keyset [`Id`]
222+
#[cfg_attr(feature = "swagger", schema(value_type = String))]
224223
pub id: Id,
225224
/// Keyset [`CurrencyUnit`]
226225
pub unit: CurrencyUnit,
@@ -257,6 +256,7 @@ impl From<MintKeySet> for KeySet {
257256
#[cfg_attr(feature = "swagger", derive(utoipa::ToSchema))]
258257
pub struct KeySetInfo {
259258
/// Keyset [`Id`]
259+
#[cfg_attr(feature = "swagger", schema(value_type = String))]
260260
pub id: Id,
261261
/// Keyset [`CurrencyUnit`]
262262
pub unit: CurrencyUnit,

crates/cdk-axum/src/lib.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ mod swagger_imports {
2424
BlindSignature, BlindedMessage, CurrencyUnit, PaymentMethod, Proof, Witness,
2525
};
2626
pub use cdk::nuts::nut01::{Keys, KeysResponse, PublicKey, SecretKey};
27-
pub use cdk::nuts::nut02::{Id, KeySet, KeySetInfo, KeySetVersion, KeysetResponse};
27+
pub use cdk::nuts::nut02::{KeySet, KeySetInfo, KeysetResponse};
2828
pub use cdk::nuts::nut03::{SwapRequest, SwapResponse};
2929
pub use cdk::nuts::nut04::{
3030
MintBolt11Request, MintBolt11Response, MintMethodSettings, MintQuoteBolt11Request,
@@ -70,13 +70,11 @@ pub struct MintState {
7070
ErrorCode,
7171
ErrorResponse,
7272
HTLCWitness,
73-
Id,
7473
Keys,
7574
KeysResponse,
7675
KeysetResponse,
7776
KeySet,
7877
KeySetInfo,
79-
KeySetVersion,
8078
MeltBolt11Request<Uuid>,
8179
MeltQuoteBolt11Request,
8280
MeltQuoteBolt11Response<Uuid>,

0 commit comments

Comments
 (0)