Skip to content

Commit

Permalink
mint: annotate post_restore for Swagger UI
Browse files Browse the repository at this point in the history
  • Loading branch information
ok300 committed Oct 10, 2024
1 parent 7a01ccc commit 3c795d6
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
6 changes: 5 additions & 1 deletion crates/cdk-axum/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ use cdk::nuts::nut05::{
};
use cdk::nuts::nut06::{ContactInfo, MintInfo, MintVersion, Nuts, SupportedSettings};
use cdk::nuts::nut07::{CheckStateRequest, CheckStateResponse, ProofState, State};
use cdk::nuts::nut09::{RestoreRequest, RestoreResponse};
use cdk::nuts::nut11::P2PKWitness;
use cdk::nuts::nut12::{BlindSignatureDleq, ProofDleq};
use cdk::nuts::nut14::HTLCWitness;
Expand Down Expand Up @@ -91,6 +92,8 @@ pub struct MintState {
ProofDleq,
ProofState,
PublicKey,
RestoreRequest,
RestoreResponse,
SecretKey,
State,
SupportedSettings,
Expand All @@ -114,7 +117,8 @@ pub struct MintState {
get_check_melt_bolt11_quote,
post_melt_bolt11,
post_swap,
post_check
post_check,
post_restore
)
)]
/// OpenAPI spec for the mint's v1 APIs
Expand Down
11 changes: 11 additions & 0 deletions crates/cdk-axum/src/router_handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,17 @@ pub async fn post_swap(
Ok(Json(swap_response))
}

#[utoipa::path(
post,
context_path = "/v1",
path = "/restore",
request_body(content = RestoreRequest, description = "Restore params", content_type = "application/json"),
responses(
(status = 200, description = "Successful response", body = RestoreResponse, content_type = "application/json"),
(status = 500, description = "Server error", body = ErrorResponse, content_type = "application/json")
)
)]
/// Restores blind signature for a set of outputs.
pub async fn post_restore(
State(state): State<MintState>,
Json(payload): Json<RestoreRequest>,
Expand Down
2 changes: 2 additions & 0 deletions crates/cdk/src/nuts/nut09.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ use super::nut00::{BlindSignature, BlindedMessage};

/// Restore Request [NUT-09]
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[cfg_attr(feature = "mint", derive(utoipa::ToSchema))]
pub struct RestoreRequest {
/// Outputs
pub outputs: Vec<BlindedMessage>,
}

/// Restore Response [NUT-09]
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[cfg_attr(feature = "mint", derive(utoipa::ToSchema))]
pub struct RestoreResponse {
/// Outputs
pub outputs: Vec<BlindedMessage>,
Expand Down
2 changes: 2 additions & 0 deletions crates/cdk/src/nuts/nut12.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@ pub enum Error {
#[cfg_attr(feature = "mint", derive(utoipa::ToSchema))]
pub struct BlindSignatureDleq {
/// e
#[cfg_attr(feature = "mint", schema(value_type = String))]
pub e: SecretKey,
/// s
#[cfg_attr(feature = "mint", schema(value_type = String))]
pub s: SecretKey,
}

Expand Down

0 comments on commit 3c795d6

Please sign in to comment.