Skip to content

Commit 55af6c1

Browse files
committed
fix-api
1 parent ad30b6b commit 55af6c1

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

apps/fortuna/src/api.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ use {
2626
tokio::sync::RwLock,
2727
url::Url,
2828
};
29-
pub use {chain_ids::*, index::*, live::*, metrics::*, ready::*, revelation::*};
30-
use crate::api::explorer::get_requests;
29+
pub use {chain_ids::*, index::*, live::*, metrics::*, ready::*, revelation::*, explorer::*};
3130

3231
mod chain_ids;
3332
mod explorer;
@@ -322,7 +321,7 @@ pub fn routes(state: ApiState) -> Router<(), Body> {
322321
.route("/metrics", get(metrics))
323322
.route("/ready", get(ready))
324323
.route("/v1/chains", get(chain_ids))
325-
.route("/v1/explorer", get(get_requests))
324+
.route("/v1/explorer", get(explorer))
326325
.route(
327326
"/v1/chains/:chain_id/revelations/:sequence",
328327
get(revelation),

apps/fortuna/src/api/explorer.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::api::{
55
use axum::extract::{Query, State};
66
use axum::Json;
77
use ethers::types::TxHash;
8-
use utoipa::IntoParams;
8+
use utoipa::{IntoParams, ToSchema};
99

1010
#[derive(Debug, serde::Serialize, serde::Deserialize, IntoParams)]
1111
#[into_params(parameter_in=Query)]
@@ -20,7 +20,7 @@ pub struct ExplorerQueryParams {
2020
#[param(value_type = Option<String>)]
2121
pub chain_id: Option<ChainId>,
2222
}
23-
#[derive(Debug, serde::Serialize, serde::Deserialize)]
23+
#[derive(Debug, serde::Serialize, serde::Deserialize, ToSchema)]
2424
#[serde(rename_all = "kebab-case")]
2525
pub enum ExplorerQueryParamsMode {
2626
TxHash,
@@ -31,14 +31,13 @@ pub enum ExplorerQueryParamsMode {
3131

3232
#[utoipa::path(
3333
get,
34-
path = "/v1/explorer/",
34+
path = "/v1/explorer",
3535
responses(
36-
(status = 200, description = "Random value successfully retrieved", body = GetRandomValueResponse),
37-
(status = 403, description = "Random value cannot currently be retrieved", body = String)
36+
(status = 200, description = "Random value successfully retrieved", body = Vec<RequestJournal>)
3837
),
3938
params(ExplorerQueryParams)
4039
)]
41-
pub async fn get_requests(
40+
pub async fn explorer(
4241
State(state): State<crate::api::ApiState>,
4342
Query(query_params): Query<ExplorerQueryParams>,
4443
) -> anyhow::Result<Json<Vec<RequestJournal>>, RestError> {

apps/fortuna/src/command/run.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,13 @@ pub async fn run_api(
3535
paths(
3636
crate::api::revelation,
3737
crate::api::chain_ids,
38+
crate::api::explorer,
3839
),
3940
components(
4041
schemas(
4142
crate::api::GetRandomValueResponse,
43+
crate::api::RequestJournal,
44+
crate::api::ExplorerQueryParamsMode,
4245
crate::api::Blob,
4346
crate::api::BinaryEncoding,
4447
)

0 commit comments

Comments
 (0)