diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cd3956f8..37149ba2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -46,6 +46,7 @@ jobs: -p cdk --no-default-features, -p cdk --no-default-features --features wallet, -p cdk --no-default-features --features mint, + -p cdk --no-default-features --features "mint swagger", -p cdk-redb, -p cdk-sqlite, -p cdk-axum, @@ -143,6 +144,7 @@ jobs: -p cdk --no-default-features, -p cdk --no-default-features --features wallet, -p cdk --no-default-features --features mint, + -p cdk --no-default-features --features "mint swagger", -p cdk-axum, -p cdk-strike, -p cdk-lnbits, diff --git a/crates/cdk-axum/Cargo.toml b/crates/cdk-axum/Cargo.toml index 8867df4f..241da962 100644 --- a/crates/cdk-axum/Cargo.toml +++ b/crates/cdk-axum/Cargo.toml @@ -15,8 +15,11 @@ axum = "0.6.20" cdk = { path = "../cdk", version = "0.4.0", default-features = false, features = ["mint"] } tokio = { version = "1", default-features = false } tracing = { version = "0.1", default-features = false, features = ["attributes", "log"] } -utoipa = { version = "4", features = ["preserve_order", "preserve_path_order"] } +utoipa = { version = "4", features = ["preserve_order", "preserve_path_order"], optional = true } futures = { version = "0.3.28", default-features = false } moka = { version = "0.11.1", features = ["future"] } serde_json = "1" paste = "1.0.15" + +[features] +swagger = ["cdk/swagger", "dep:utoipa"] \ No newline at end of file diff --git a/crates/cdk-axum/src/lib.rs b/crates/cdk-axum/src/lib.rs index 46ef06e4..283a0afc 100644 --- a/crates/cdk-axum/src/lib.rs +++ b/crates/cdk-axum/src/lib.rs @@ -38,7 +38,6 @@ use cdk::nuts::nut15::{Mpp, MppMethodSettings}; use cdk::nuts::{MeltQuoteState, MintQuoteState}; use moka::future::Cache; use router_handlers::*; -use utoipa::OpenApi; mod router_handlers; @@ -49,7 +48,8 @@ pub struct MintState { cache: Cache, } -#[derive(OpenApi)] +#[cfg(feature = "swagger")] +#[derive(utoipa::OpenApi)] #[openapi( components(schemas( Amount, diff --git a/crates/cdk-axum/src/router_handlers.rs b/crates/cdk-axum/src/router_handlers.rs index b0aed2c7..c4ba781a 100644 --- a/crates/cdk-axum/src/router_handlers.rs +++ b/crates/cdk-axum/src/router_handlers.rs @@ -49,14 +49,14 @@ post_cache_wrapper!(post_swap, SwapRequest, SwapResponse); post_cache_wrapper!(post_mint_bolt11, MintBolt11Request, MintBolt11Response); post_cache_wrapper!(post_melt_bolt11, MeltBolt11Request, MeltQuoteBolt11Response); -#[utoipa::path( +#[cfg_attr(feature = "swagger", utoipa::path( get, context_path = "/v1", path = "/keys", responses( (status = 200, description = "Successful response", body = KeysResponse, content_type = "application/json") ) -)] +))] /// Get the public keys of the newest mint keyset /// /// This endpoint returns a dictionary of all supported token values of the mint and their associated public key. @@ -69,7 +69,7 @@ pub async fn get_keys(State(state): State) -> Result) -> Result) -> Result) -> Result, @@ -229,7 +229,7 @@ pub async fn get_melt_bolt11_quote( Ok(Json(quote)) } -#[utoipa::path( +#[cfg_attr(feature = "swagger", utoipa::path( get, context_path = "/v1", path = "/melt/quote/bolt11/{quote_id}", @@ -240,7 +240,7 @@ pub async fn get_melt_bolt11_quote( (status = 200, description = "Successful response", body = MeltQuoteBolt11Response, content_type = "application/json"), (status = 500, description = "Server error", body = ErrorResponse, content_type = "application/json") ) -)] +))] /// Get melt quote by ID /// /// Get melt quote state. @@ -260,7 +260,7 @@ pub async fn get_check_melt_bolt11_quote( Ok(Json(quote)) } -#[utoipa::path( +#[cfg_attr(feature = "swagger", utoipa::path( post, context_path = "/v1", path = "/melt/bolt11", @@ -269,7 +269,7 @@ pub async fn get_check_melt_bolt11_quote( (status = 200, description = "Successful response", body = MeltQuoteBolt11Response, content_type = "application/json"), (status = 500, description = "Server error", body = ErrorResponse, content_type = "application/json") ) -)] +))] /// Melt tokens for a Bitcoin payment that the mint will make for the user in exchange /// /// Requests tokens to be destroyed and sent out via Lightning. @@ -286,7 +286,7 @@ pub async fn post_melt_bolt11( Ok(Json(res)) } -#[utoipa::path( +#[cfg_attr(feature = "swagger", utoipa::path( post, context_path = "/v1", path = "/checkstate", @@ -295,7 +295,7 @@ pub async fn post_melt_bolt11( (status = 200, description = "Successful response", body = CheckStateResponse, content_type = "application/json"), (status = 500, description = "Server error", body = ErrorResponse, content_type = "application/json") ) -)] +))] /// Check whether a proof is spent already or is pending in a transaction /// /// Check whether a secret has been spent already or not. @@ -311,20 +311,20 @@ pub async fn post_check( Ok(Json(state)) } -#[utoipa::path( +#[cfg_attr(feature = "swagger", utoipa::path( get, context_path = "/v1", path = "/info", responses( (status = 200, description = "Successful response", body = MintInfo) ) -)] +))] /// Mint information, operator contact information, and other info pub async fn get_mint_info(State(state): State) -> Result, Response> { Ok(Json(state.mint.mint_info().clone().time(unix_time()))) } -#[utoipa::path( +#[cfg_attr(feature = "swagger", utoipa::path( post, context_path = "/v1", path = "/swap", @@ -333,7 +333,7 @@ pub async fn get_mint_info(State(state): State) -> Result, diff --git a/crates/cdk-mintd/Cargo.toml b/crates/cdk-mintd/Cargo.toml index a201f907..34640215 100644 --- a/crates/cdk-mintd/Cargo.toml +++ b/crates/cdk-mintd/Cargo.toml @@ -34,5 +34,8 @@ tower-http = { version = "0.4.4", features = ["cors"] } lightning-invoice = { version = "0.32.0", features = ["serde", "std"] } home = "0.5.5" url = "2.3" -utoipa = "4" -utoipa-swagger-ui = { version = "4", features = ["axum"] } \ No newline at end of file +utoipa = { version = "4", optional = true } +utoipa-swagger-ui = { version = "4", features = ["axum"], optional = true } + +[features] +swagger = ["cdk-axum/swagger", "dep:utoipa", "dep:utoipa-swagger-ui"] \ No newline at end of file diff --git a/crates/cdk-mintd/src/main.rs b/crates/cdk-mintd/src/main.rs index 7947ef13..6f3c4c9f 100644 --- a/crates/cdk-mintd/src/main.rs +++ b/crates/cdk-mintd/src/main.rs @@ -36,8 +36,6 @@ use tokio::sync::{Mutex, Notify}; use tower_http::cors::CorsLayer; use tracing_subscriber::EnvFilter; use url::Url; -use utoipa::OpenApi; -use utoipa_swagger_ui::SwaggerUi; mod cli; mod config; @@ -474,13 +472,17 @@ async fn main() -> anyhow::Result<()> { let v1_service = cdk_axum::create_mint_router(Arc::clone(&mint), cache_ttl, cache_tti).await?; let mut mint_service = Router::new() - .merge( - SwaggerUi::new("/swagger-ui") - .url("/api-docs/openapi.json", cdk_axum::ApiDocV1::openapi()), - ) .merge(v1_service) .layer(CorsLayer::permissive()); + #[cfg(feature = "swagger")] + { + mint_service = mint_service.merge( + utoipa_swagger_ui::SwaggerUi::new("/swagger-ui") + .url("/api-docs/openapi.json", cdk_axum::ApiDocV1::openapi()), + ); + } + for router in ln_routers { mint_service = mint_service.merge(router); } diff --git a/crates/cdk/Cargo.toml b/crates/cdk/Cargo.toml index ae935d79..b72e50d2 100644 --- a/crates/cdk/Cargo.toml +++ b/crates/cdk/Cargo.toml @@ -12,7 +12,8 @@ license = "MIT" [features] default = ["mint", "wallet"] -mint = ["dep:futures", "dep:utoipa"] +mint = ["dep:futures"] +swagger = ["mint", "dep:utoipa"] wallet = ["dep:reqwest"] bench = [] diff --git a/crates/cdk/src/amount.rs b/crates/cdk/src/amount.rs index c612d570..d2c599d0 100644 --- a/crates/cdk/src/amount.rs +++ b/crates/cdk/src/amount.rs @@ -27,7 +27,7 @@ pub enum Error { /// Amount can be any unit #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize)] -#[cfg_attr(feature = "mint", derive(utoipa::ToSchema))] +#[cfg_attr(feature = "swagger", derive(utoipa::ToSchema))] #[serde(transparent)] pub struct Amount(u64); diff --git a/crates/cdk/src/error.rs b/crates/cdk/src/error.rs index 2aec8513..5ca14821 100644 --- a/crates/cdk/src/error.rs +++ b/crates/cdk/src/error.rs @@ -244,7 +244,7 @@ pub enum Error { /// /// See NUT definition in [00](https://github.com/cashubtc/nuts/blob/main/00.md) #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] -#[cfg_attr(feature = "mint", derive(utoipa::ToSchema))] +#[cfg_attr(feature = "swagger", derive(utoipa::ToSchema))] pub struct ErrorResponse { /// Error Code pub code: ErrorCode, @@ -400,7 +400,7 @@ impl From for Error { /// Possible Error Codes #[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)] -#[cfg_attr(feature = "mint", derive(utoipa::ToSchema))] +#[cfg_attr(feature = "swagger", derive(utoipa::ToSchema))] pub enum ErrorCode { /// Token is already spent TokenAlreadySpent, diff --git a/crates/cdk/src/nuts/nut00/mod.rs b/crates/cdk/src/nuts/nut00/mod.rs index f340328f..57117bf0 100644 --- a/crates/cdk/src/nuts/nut00/mod.rs +++ b/crates/cdk/src/nuts/nut00/mod.rs @@ -103,7 +103,7 @@ pub enum Error { /// Blinded Message (also called `output`) #[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)] -#[cfg_attr(feature = "mint", derive(utoipa::ToSchema))] +#[cfg_attr(feature = "swagger", derive(utoipa::ToSchema))] pub struct BlindedMessage { /// Amount /// @@ -118,7 +118,7 @@ pub struct BlindedMessage { /// /// The blinded secret message generated by the sender. #[serde(rename = "B_")] - #[cfg_attr(feature = "mint", schema(value_type = String))] + #[cfg_attr(feature = "swagger", schema(value_type = String))] pub blinded_secret: PublicKey, /// Witness /// @@ -148,7 +148,7 @@ impl BlindedMessage { /// Blind Signature (also called `promise`) #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] -#[cfg_attr(feature = "mint", derive(utoipa::ToSchema))] +#[cfg_attr(feature = "swagger", derive(utoipa::ToSchema))] pub struct BlindSignature { /// Amount /// @@ -163,7 +163,7 @@ pub struct BlindSignature { /// /// The blinded signature on the secret message `B_` of [BlindedMessage]. #[serde(rename = "C_")] - #[cfg_attr(feature = "mint", schema(value_type = String))] + #[cfg_attr(feature = "swagger", schema(value_type = String))] pub c: PublicKey, /// DLEQ Proof /// @@ -187,7 +187,7 @@ impl PartialOrd for BlindSignature { /// Witness #[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)] #[serde(untagged)] -#[cfg_attr(feature = "mint", derive(utoipa::ToSchema))] +#[cfg_attr(feature = "swagger", derive(utoipa::ToSchema))] pub enum Witness { /// P2PK Witness #[serde(with = "serde_p2pk_witness")] @@ -231,7 +231,7 @@ impl Witness { /// Proofs #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] -#[cfg_attr(feature = "mint", derive(utoipa::ToSchema))] +#[cfg_attr(feature = "swagger", derive(utoipa::ToSchema))] pub struct Proof { /// Amount pub amount: Amount, @@ -239,11 +239,11 @@ pub struct Proof { #[serde(rename = "id")] pub keyset_id: Id, /// Secret message - #[cfg_attr(feature = "mint", schema(value_type = String))] + #[cfg_attr(feature = "swagger", schema(value_type = String))] pub secret: Secret, /// Unblinded signature #[serde(rename = "C")] - #[cfg_attr(feature = "mint", schema(value_type = String))] + #[cfg_attr(feature = "swagger", schema(value_type = String))] pub c: PublicKey, /// Witness #[serde(skip_serializing_if = "Option::is_none")] @@ -368,7 +368,7 @@ where /// Currency Unit #[non_exhaustive] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)] -#[cfg_attr(feature = "mint", derive(utoipa::ToSchema))] +#[cfg_attr(feature = "swagger", derive(utoipa::ToSchema))] pub enum CurrencyUnit { /// Sat #[default] @@ -445,7 +445,7 @@ impl<'de> Deserialize<'de> for CurrencyUnit { /// Payment Method #[non_exhaustive] #[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash)] -#[cfg_attr(feature = "mint", derive(utoipa::ToSchema))] +#[cfg_attr(feature = "swagger", derive(utoipa::ToSchema))] pub enum PaymentMethod { /// Bolt11 payment type #[default] diff --git a/crates/cdk/src/nuts/nut01/mod.rs b/crates/cdk/src/nuts/nut01/mod.rs index ce2e1b55..bda245fd 100644 --- a/crates/cdk/src/nuts/nut01/mod.rs +++ b/crates/cdk/src/nuts/nut01/mod.rs @@ -43,7 +43,7 @@ pub enum Error { /// /// See [NUT-01] #[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)] -#[cfg_attr(feature = "mint", derive(utoipa::ToSchema))] +#[cfg_attr(feature = "swagger", derive(utoipa::ToSchema))] pub struct Keys(BTreeMap); impl From for Keys { @@ -86,7 +86,7 @@ impl Keys { /// Mint Public Keys [NUT-01] #[serde_as] #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] -#[cfg_attr(feature = "mint", derive(utoipa::ToSchema))] +#[cfg_attr(feature = "swagger", derive(utoipa::ToSchema))] pub struct KeysResponse { /// Keysets #[serde_as(as = "VecSkipError<_>")] diff --git a/crates/cdk/src/nuts/nut01/public_key.rs b/crates/cdk/src/nuts/nut01/public_key.rs index d7845722..23e2f1de 100644 --- a/crates/cdk/src/nuts/nut01/public_key.rs +++ b/crates/cdk/src/nuts/nut01/public_key.rs @@ -13,9 +13,9 @@ use crate::SECP256K1; /// PublicKey #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] -#[cfg_attr(feature = "mint", derive(utoipa::ToSchema))] +#[cfg_attr(feature = "swagger", derive(utoipa::ToSchema))] pub struct PublicKey { - #[cfg_attr(feature = "mint", schema(value_type = String))] + #[cfg_attr(feature = "swagger", schema(value_type = String))] inner: secp256k1::PublicKey, } diff --git a/crates/cdk/src/nuts/nut01/secret_key.rs b/crates/cdk/src/nuts/nut01/secret_key.rs index 58cd81f4..23eca6e3 100644 --- a/crates/cdk/src/nuts/nut01/secret_key.rs +++ b/crates/cdk/src/nuts/nut01/secret_key.rs @@ -15,9 +15,9 @@ use crate::SECP256K1; /// SecretKey #[derive(Debug, Clone, PartialEq, Eq)] -#[cfg_attr(feature = "mint", derive(utoipa::ToSchema))] +#[cfg_attr(feature = "swagger", derive(utoipa::ToSchema))] pub struct SecretKey { - #[cfg_attr(feature = "mint", schema(value_type = String))] + #[cfg_attr(feature = "swagger", schema(value_type = String))] inner: secp256k1::SecretKey, } diff --git a/crates/cdk/src/nuts/nut02.rs b/crates/cdk/src/nuts/nut02.rs index 53aa58d0..32e96190 100644 --- a/crates/cdk/src/nuts/nut02.rs +++ b/crates/cdk/src/nuts/nut02.rs @@ -53,7 +53,7 @@ pub enum Error { /// Keyset version #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] -#[cfg_attr(feature = "mint", derive(utoipa::ToSchema))] +#[cfg_attr(feature = "swagger", derive(utoipa::ToSchema))] pub enum KeySetVersion { /// Current Version 00 Version00, @@ -89,7 +89,7 @@ impl fmt::Display for KeySetVersion { /// be stored in a Cashu token such that the token can be used to identify /// which mint or keyset it was generated from. #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] -#[cfg_attr(feature = "mint", derive(utoipa::ToSchema))] +#[cfg_attr(feature = "swagger", derive(utoipa::ToSchema))] pub struct Id { version: KeySetVersion, id: [u8; Self::BYTELEN], @@ -230,7 +230,7 @@ impl From<&Keys> for Id { /// Ids of mints keyset ids #[serde_as] #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] -#[cfg_attr(feature = "mint", derive(utoipa::ToSchema))] +#[cfg_attr(feature = "swagger", derive(utoipa::ToSchema))] pub struct KeysetResponse { /// set of public key ids that the mint generates #[serde_as(as = "VecSkipError<_>")] @@ -239,7 +239,7 @@ pub struct KeysetResponse { /// Keyset #[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)] -#[cfg_attr(feature = "mint", derive(utoipa::ToSchema))] +#[cfg_attr(feature = "swagger", derive(utoipa::ToSchema))] pub struct KeySet { /// Keyset [`Id`] pub id: Id, @@ -275,7 +275,7 @@ impl From for KeySet { /// KeySetInfo #[derive(Debug, Clone, Hash, PartialEq, Eq, Deserialize, Serialize)] -#[cfg_attr(feature = "mint", derive(utoipa::ToSchema))] +#[cfg_attr(feature = "swagger", derive(utoipa::ToSchema))] pub struct KeySetInfo { /// Keyset [`Id`] pub id: Id, diff --git a/crates/cdk/src/nuts/nut03.rs b/crates/cdk/src/nuts/nut03.rs index 101a0f57..535c89a9 100644 --- a/crates/cdk/src/nuts/nut03.rs +++ b/crates/cdk/src/nuts/nut03.rs @@ -34,10 +34,10 @@ pub struct PreSwap { /// Split Request [NUT-06] #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] -#[cfg_attr(feature = "mint", derive(utoipa::ToSchema))] +#[cfg_attr(feature = "swagger", derive(utoipa::ToSchema))] pub struct SwapRequest { /// Proofs that are to be spent in `Split` - #[cfg_attr(feature = "mint", schema(value_type = Vec))] + #[cfg_attr(feature = "swagger", schema(value_type = Vec))] pub inputs: Proofs, /// Blinded Messages for Mint to sign pub outputs: Vec, @@ -66,7 +66,7 @@ impl SwapRequest { /// Split Response [NUT-06] #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] -#[cfg_attr(feature = "mint", derive(utoipa::ToSchema))] +#[cfg_attr(feature = "swagger", derive(utoipa::ToSchema))] pub struct SwapResponse { /// Promises pub signatures: Vec, diff --git a/crates/cdk/src/nuts/nut04.rs b/crates/cdk/src/nuts/nut04.rs index 008c8dd6..3067628f 100644 --- a/crates/cdk/src/nuts/nut04.rs +++ b/crates/cdk/src/nuts/nut04.rs @@ -26,7 +26,7 @@ pub enum Error { /// Mint quote request [NUT-04] #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] -#[cfg_attr(feature = "mint", derive(utoipa::ToSchema))] +#[cfg_attr(feature = "swagger", derive(utoipa::ToSchema))] pub struct MintQuoteBolt11Request { /// Amount pub amount: Amount, @@ -39,7 +39,7 @@ pub struct MintQuoteBolt11Request { /// Possible states of a quote #[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, Default, Serialize, Deserialize)] #[serde(rename_all = "UPPERCASE")] -#[cfg_attr(feature = "mint", derive(utoipa::ToSchema), schema(as = MintQuoteState))] +#[cfg_attr(feature = "swagger", derive(utoipa::ToSchema), schema(as = MintQuoteState))] pub enum QuoteState { /// Quote has not been paid #[default] @@ -81,7 +81,7 @@ impl FromStr for QuoteState { /// Mint quote response [NUT-04] #[derive(Debug, Clone, PartialEq, Eq, Serialize)] -#[cfg_attr(feature = "mint", derive(utoipa::ToSchema))] +#[cfg_attr(feature = "swagger", derive(utoipa::ToSchema))] pub struct MintQuoteBolt11Response { /// Quote Id pub quote: String, @@ -178,13 +178,13 @@ impl From for MintQuoteBolt11Response { /// Mint request [NUT-04] #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] -#[cfg_attr(feature = "mint", derive(utoipa::ToSchema))] +#[cfg_attr(feature = "swagger", derive(utoipa::ToSchema))] pub struct MintBolt11Request { /// Quote id - #[cfg_attr(feature = "mint", schema(max_length = 1_000))] + #[cfg_attr(feature = "swagger", schema(max_length = 1_000))] pub quote: String, /// Outputs - #[cfg_attr(feature = "mint", schema(max_items = 1_000))] + #[cfg_attr(feature = "swagger", schema(max_items = 1_000))] pub outputs: Vec, } @@ -202,7 +202,7 @@ impl MintBolt11Request { /// Mint response [NUT-04] #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] -#[cfg_attr(feature = "mint", derive(utoipa::ToSchema))] +#[cfg_attr(feature = "swagger", derive(utoipa::ToSchema))] pub struct MintBolt11Response { /// Blinded Signatures pub signatures: Vec, @@ -210,7 +210,7 @@ pub struct MintBolt11Response { /// Mint Method Settings #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)] -#[cfg_attr(feature = "mint", derive(utoipa::ToSchema))] +#[cfg_attr(feature = "swagger", derive(utoipa::ToSchema))] pub struct MintMethodSettings { /// Payment Method e.g. bolt11 pub method: PaymentMethod, @@ -229,7 +229,7 @@ pub struct MintMethodSettings { /// Mint Settings #[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)] -#[cfg_attr(feature = "mint", derive(utoipa::ToSchema), schema(as = nut04::Settings))] +#[cfg_attr(feature = "swagger", derive(utoipa::ToSchema), schema(as = nut04::Settings))] pub struct Settings { /// Methods to mint pub methods: Vec, diff --git a/crates/cdk/src/nuts/nut05.rs b/crates/cdk/src/nuts/nut05.rs index 2462272d..e7ac3153 100644 --- a/crates/cdk/src/nuts/nut05.rs +++ b/crates/cdk/src/nuts/nut05.rs @@ -29,10 +29,10 @@ pub enum Error { /// Melt quote request [NUT-05] #[derive(Debug, Clone, Hash, PartialEq, Eq, Serialize, Deserialize)] -#[cfg_attr(feature = "mint", derive(utoipa::ToSchema))] +#[cfg_attr(feature = "swagger", derive(utoipa::ToSchema))] pub struct MeltQuoteBolt11Request { /// Bolt11 invoice to be paid - #[cfg_attr(feature = "mint", schema(value_type = String))] + #[cfg_attr(feature = "swagger", schema(value_type = String))] pub request: Bolt11Invoice, /// Unit wallet would like to pay with pub unit: CurrencyUnit, @@ -43,7 +43,7 @@ pub struct MeltQuoteBolt11Request { /// Possible states of a quote #[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, Default, Serialize, Deserialize)] #[serde(rename_all = "UPPERCASE")] -#[cfg_attr(feature = "mint", derive(utoipa::ToSchema), schema(as = MeltQuoteState))] +#[cfg_attr(feature = "swagger", derive(utoipa::ToSchema), schema(as = MeltQuoteState))] pub enum QuoteState { /// Quote has not been paid #[default] @@ -87,7 +87,7 @@ impl FromStr for QuoteState { /// Melt quote response [NUT-05] #[derive(Debug, Clone, PartialEq, Eq, Serialize)] -#[cfg_attr(feature = "mint", derive(utoipa::ToSchema))] +#[cfg_attr(feature = "swagger", derive(utoipa::ToSchema))] pub struct MeltQuoteBolt11Response { /// Quote Id pub quote: String, @@ -214,12 +214,12 @@ impl From for MeltQuoteBolt11Response { /// Melt Bolt11 Request [NUT-05] #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] -#[cfg_attr(feature = "mint", derive(utoipa::ToSchema))] +#[cfg_attr(feature = "swagger", derive(utoipa::ToSchema))] pub struct MeltBolt11Request { /// Quote ID pub quote: String, /// Proofs - #[cfg_attr(feature = "mint", schema(value_type = Vec))] + #[cfg_attr(feature = "swagger", schema(value_type = Vec))] pub inputs: Proofs, /// Blinded Message that can be used to return change [NUT-08] /// Amount field of BlindedMessages `SHOULD` be set to zero @@ -236,7 +236,7 @@ impl MeltBolt11Request { /// Melt Method Settings #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)] -#[cfg_attr(feature = "mint", derive(utoipa::ToSchema))] +#[cfg_attr(feature = "swagger", derive(utoipa::ToSchema))] pub struct MeltMethodSettings { /// Payment Method e.g. bolt11 pub method: PaymentMethod, @@ -274,7 +274,7 @@ impl Settings { /// Melt Settings #[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)] -#[cfg_attr(feature = "mint", derive(utoipa::ToSchema), schema(as = nut05::Settings))] +#[cfg_attr(feature = "swagger", derive(utoipa::ToSchema), schema(as = nut05::Settings))] pub struct Settings { /// Methods to melt pub methods: Vec, diff --git a/crates/cdk/src/nuts/nut06.rs b/crates/cdk/src/nuts/nut06.rs index afb8b8f8..358cc4ff 100644 --- a/crates/cdk/src/nuts/nut06.rs +++ b/crates/cdk/src/nuts/nut06.rs @@ -9,7 +9,7 @@ use super::{nut04, nut05, nut15, MppMethodSettings}; /// Mint Version #[derive(Debug, Clone, PartialEq, Eq, Hash)] -#[cfg_attr(feature = "mint", derive(utoipa::ToSchema))] +#[cfg_attr(feature = "swagger", derive(utoipa::ToSchema))] pub struct MintVersion { /// Mint Software name pub name: String, @@ -53,7 +53,7 @@ impl<'de> Deserialize<'de> for MintVersion { /// Mint Info [NIP-06] #[derive(Default, Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)] -#[cfg_attr(feature = "mint", derive(utoipa::ToSchema))] +#[cfg_attr(feature = "swagger", derive(utoipa::ToSchema))] pub struct MintInfo { /// name of the mint and should be recognizable #[serde(skip_serializing_if = "Option::is_none")] @@ -190,7 +190,7 @@ impl MintInfo { /// Supported nuts and settings #[derive(Debug, Default, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)] -#[cfg_attr(feature = "mint", derive(utoipa::ToSchema))] +#[cfg_attr(feature = "swagger", derive(utoipa::ToSchema))] pub struct Nuts { /// NUT04 Settings #[serde(default)] @@ -325,14 +325,14 @@ impl Nuts { /// Check state Settings #[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Hash, Serialize, Deserialize)] -#[cfg_attr(feature = "mint", derive(utoipa::ToSchema))] +#[cfg_attr(feature = "swagger", derive(utoipa::ToSchema))] pub struct SupportedSettings { supported: bool, } /// Contact Info #[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)] -#[cfg_attr(feature = "mint", derive(utoipa::ToSchema))] +#[cfg_attr(feature = "swagger", derive(utoipa::ToSchema))] pub struct ContactInfo { /// Contact Method i.e. nostr pub method: String, diff --git a/crates/cdk/src/nuts/nut07.rs b/crates/cdk/src/nuts/nut07.rs index a8a73950..b56830ea 100644 --- a/crates/cdk/src/nuts/nut07.rs +++ b/crates/cdk/src/nuts/nut07.rs @@ -21,7 +21,7 @@ pub enum Error { /// State of Proof #[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, Serialize, Deserialize)] #[serde(rename_all = "UPPERCASE")] -#[cfg_attr(feature = "mint", derive(utoipa::ToSchema))] +#[cfg_attr(feature = "swagger", derive(utoipa::ToSchema))] pub enum State { /// Spent Spent, @@ -66,21 +66,21 @@ impl FromStr for State { /// Check spendable request [NUT-07] #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] -#[cfg_attr(feature = "mint", derive(utoipa::ToSchema))] +#[cfg_attr(feature = "swagger", derive(utoipa::ToSchema))] pub struct CheckStateRequest { /// Y's of the proofs to check #[serde(rename = "Ys")] - #[cfg_attr(feature = "mint", schema(value_type = Vec, max_items = 1_000))] + #[cfg_attr(feature = "swagger", schema(value_type = Vec, max_items = 1_000))] pub ys: Vec, } /// Proof state [NUT-07] #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] -#[cfg_attr(feature = "mint", derive(utoipa::ToSchema))] +#[cfg_attr(feature = "swagger", derive(utoipa::ToSchema))] pub struct ProofState { /// Y of proof #[serde(rename = "Y")] - #[cfg_attr(feature = "mint", schema(value_type = String))] + #[cfg_attr(feature = "swagger", schema(value_type = String))] pub y: PublicKey, /// State of proof pub state: State, @@ -90,7 +90,7 @@ pub struct ProofState { /// Check Spendable Response [NUT-07] #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] -#[cfg_attr(feature = "mint", derive(utoipa::ToSchema))] +#[cfg_attr(feature = "swagger", derive(utoipa::ToSchema))] pub struct CheckStateResponse { /// Proof states pub states: Vec, diff --git a/crates/cdk/src/nuts/nut09.rs b/crates/cdk/src/nuts/nut09.rs index 74d92915..abcd8f85 100644 --- a/crates/cdk/src/nuts/nut09.rs +++ b/crates/cdk/src/nuts/nut09.rs @@ -8,7 +8,7 @@ use super::nut00::{BlindSignature, BlindedMessage}; /// Restore Request [NUT-09] #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] -#[cfg_attr(feature = "mint", derive(utoipa::ToSchema))] +#[cfg_attr(feature = "swagger", derive(utoipa::ToSchema))] pub struct RestoreRequest { /// Outputs pub outputs: Vec, @@ -16,7 +16,7 @@ pub struct RestoreRequest { /// Restore Response [NUT-09] #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] -#[cfg_attr(feature = "mint", derive(utoipa::ToSchema))] +#[cfg_attr(feature = "swagger", derive(utoipa::ToSchema))] pub struct RestoreResponse { /// Outputs pub outputs: Vec, diff --git a/crates/cdk/src/nuts/nut11/mod.rs b/crates/cdk/src/nuts/nut11/mod.rs index dbebbe59..6d407e2b 100644 --- a/crates/cdk/src/nuts/nut11/mod.rs +++ b/crates/cdk/src/nuts/nut11/mod.rs @@ -88,7 +88,7 @@ pub enum Error { /// P2Pk Witness #[derive(Default, Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)] -#[cfg_attr(feature = "mint", derive(utoipa::ToSchema))] +#[cfg_attr(feature = "swagger", derive(utoipa::ToSchema))] pub struct P2PKWitness { /// Signatures pub signatures: Vec, diff --git a/crates/cdk/src/nuts/nut12.rs b/crates/cdk/src/nuts/nut12.rs index 368879dd..232368b0 100644 --- a/crates/cdk/src/nuts/nut12.rs +++ b/crates/cdk/src/nuts/nut12.rs @@ -41,13 +41,13 @@ pub enum Error { /// /// Defined in [NUT12](https://github.com/cashubtc/nuts/blob/main/12.md) #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] -#[cfg_attr(feature = "mint", derive(utoipa::ToSchema))] +#[cfg_attr(feature = "swagger", derive(utoipa::ToSchema))] pub struct BlindSignatureDleq { /// e - #[cfg_attr(feature = "mint", schema(value_type = String))] + #[cfg_attr(feature = "swagger", schema(value_type = String))] pub e: SecretKey, /// s - #[cfg_attr(feature = "mint", schema(value_type = String))] + #[cfg_attr(feature = "swagger", schema(value_type = String))] pub s: SecretKey, } @@ -55,16 +55,16 @@ pub struct BlindSignatureDleq { /// /// Defined in [NUT12](https://github.com/cashubtc/nuts/blob/main/12.md) #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] -#[cfg_attr(feature = "mint", derive(utoipa::ToSchema))] +#[cfg_attr(feature = "swagger", derive(utoipa::ToSchema))] pub struct ProofDleq { /// e - #[cfg_attr(feature = "mint", schema(value_type = String))] + #[cfg_attr(feature = "swagger", schema(value_type = String))] pub e: SecretKey, /// s - #[cfg_attr(feature = "mint", schema(value_type = String))] + #[cfg_attr(feature = "swagger", schema(value_type = String))] pub s: SecretKey, /// Blinding factor - #[cfg_attr(feature = "mint", schema(value_type = String))] + #[cfg_attr(feature = "swagger", schema(value_type = String))] pub r: SecretKey, } diff --git a/crates/cdk/src/nuts/nut14/mod.rs b/crates/cdk/src/nuts/nut14/mod.rs index f35d5400..07da54dc 100644 --- a/crates/cdk/src/nuts/nut14/mod.rs +++ b/crates/cdk/src/nuts/nut14/mod.rs @@ -52,7 +52,7 @@ pub enum Error { /// HTLC Witness #[derive(Default, Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)] -#[cfg_attr(feature = "mint", derive(utoipa::ToSchema))] +#[cfg_attr(feature = "swagger", derive(utoipa::ToSchema))] pub struct HTLCWitness { /// Primage pub preimage: String, diff --git a/crates/cdk/src/nuts/nut15.rs b/crates/cdk/src/nuts/nut15.rs index e918ff08..abaa5c42 100644 --- a/crates/cdk/src/nuts/nut15.rs +++ b/crates/cdk/src/nuts/nut15.rs @@ -10,7 +10,7 @@ use crate::Amount; /// Multi-part payment #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)] #[serde(rename = "lowercase")] -#[cfg_attr(feature = "mint", derive(utoipa::ToSchema))] +#[cfg_attr(feature = "swagger", derive(utoipa::ToSchema))] pub struct Mpp { /// Amount pub amount: Amount, @@ -18,7 +18,7 @@ pub struct Mpp { /// Mpp Method Settings #[derive(Debug, Default, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)] -#[cfg_attr(feature = "mint", derive(utoipa::ToSchema))] +#[cfg_attr(feature = "swagger", derive(utoipa::ToSchema))] pub struct MppMethodSettings { /// Payment Method e.g. bolt11 pub method: PaymentMethod, @@ -30,7 +30,7 @@ pub struct MppMethodSettings { /// Mpp Settings #[derive(Debug, Default, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)] -#[cfg_attr(feature = "mint", derive(utoipa::ToSchema), schema(as = nut15::Settings))] +#[cfg_attr(feature = "swagger", derive(utoipa::ToSchema), schema(as = nut15::Settings))] pub struct Settings { /// Method settings pub methods: Vec,