Skip to content

Commit

Permalink
feat: add swagger for swap
Browse files Browse the repository at this point in the history
  • Loading branch information
ngutech21 committed Dec 10, 2023
1 parent 8368bd4 commit 2707b01
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
4 changes: 2 additions & 2 deletions moksha-core/src/primitives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,13 @@ impl PostSplitResponse {
}
}

#[derive(Clone, Debug, Serialize, Deserialize)]
#[derive(Clone, Debug, Serialize, Deserialize, ToSchema)]
pub struct PostSwapRequest {
pub inputs: Proofs,
pub outputs: Vec<BlindedMessage>,
}

#[derive(Clone, Debug, Serialize, Deserialize, Default)]
#[derive(Clone, Debug, Serialize, Deserialize, Default, ToSchema)]
pub struct PostSwapResponse {
pub signatures: Vec<BlindedSignature>,
}
Expand Down
13 changes: 12 additions & 1 deletion moksha-mint/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,11 @@ pub async fn run_server(
get_keys,
get_keys_by_id,
get_keysets,
post_mint_bolt11,
post_mint_quote_bolt11,
get_mint_quote_bolt11,
post_melt_bolt11,
post_mint_bolt11,
post_swap,
get_info,
),
components(schemas(
Expand All @@ -111,6 +112,8 @@ pub async fn run_server(
PostMeltBolt11Response,
PostMintBolt11Request,
PostMintBolt11Response,
PostSwapRequest,
PostSwapResponse,
))
)]
struct ApiDoc;
Expand Down Expand Up @@ -312,6 +315,14 @@ async fn get_legacy_keysets(State(mint): State<Mint>) -> Result<Json<Keysets>, M

// ######################################################################################################

#[utoipa::path(
post,
path = "/v1/swap",
request_body = PostSwapRequest,
responses(
(status = 200, description = "post swap", body = [PostSwapResponse])
),
)]
async fn post_swap(
State(mint): State<Mint>,
Json(swap_request): Json<PostSwapRequest>,
Expand Down

0 comments on commit 2707b01

Please sign in to comment.