Skip to content

Commit

Permalink
feat: Add initial output documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
petarvujovic98 committed May 8, 2024
1 parent c4703a0 commit ae71d7d
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 3 deletions.
43 changes: 41 additions & 2 deletions host/src/server/api/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use alloy_primitives::FixedBytes;
use axum::{
body::HttpBody,
extract::Request,
Expand All @@ -6,14 +7,16 @@ use axum::{
response::Response,
Router,
};
use raiko_lib::input::{GuestOutput, WrappedHeader};
use serde::Serialize;
use tower::ServiceBuilder;
use tower_http::{
compression::CompressionLayer,
cors::{self, CorsLayer},
set_header::SetResponseHeaderLayer,
trace::TraceLayer,
};
use utoipa::OpenApi;
use utoipa::{OpenApi, ToSchema};
use utoipa_swagger_ui::SwaggerUi;

use crate::ProverState;
Expand Down Expand Up @@ -42,7 +45,10 @@ mod proof;
schemas(
crate::request::ProofRequestOpt,
crate::error::HostError,
crate::request::ProverSpecificOpts
crate::request::ProverSpecificOpts,
WrappedHeaderDoc,
GuestOutputDoc,
ProofResponse,
)
),
tags(
Expand All @@ -54,6 +60,39 @@ mod proof;
/// The root API struct which is generated from the `OpenApi` derive macro.
pub struct Docs;

#[derive(Debug, Serialize, ToSchema)]
/// The response body of a proof request.
pub enum ProofResponse {
Native {
#[schema(value_type = GuestOutputDoc)]
output: GuestOutput,
},
Sgx {
proof: String,
quote: String,
},
Sp1 {
proof: String,
#[schema(value_type = GuestOutputDoc)]
output: GuestOutput,
},
Risc0 {
proof: String,
},
}

#[derive(Debug, Serialize, ToSchema)]
pub enum GuestOutputDoc {
#[schema(value_type = (WrappedHeaderDoc, String))]
Success((WrappedHeader, FixedBytes<32>)),
Failure,
}

#[derive(Debug, Serialize, ToSchema)]
pub struct WrappedHeaderDoc {
pub header: Vec<u8>,
}

#[must_use]
pub fn create_docs() -> utoipa::openapi::OpenApi {
[
Expand Down
2 changes: 1 addition & 1 deletion host/src/server/api/proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ fn set_cached_input(
#[utoipa::path(post, path = "/proof",
tag = "Proving",
responses (
(status = 200, description = "Successfully created proof for request")
(status = 200, description = "Successfully created proof for request", body = ProofResponse)
)
)]
#[debug_handler(state = ProverState)]
Expand Down

0 comments on commit ae71d7d

Please sign in to comment.