Skip to content

Commit

Permalink
feat: add SchemaVersionValidation middleware to existing API endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
saibatizoku committed Jan 1, 2024
1 parent 6dc6a18 commit 65180ff
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 17 deletions.
26 changes: 15 additions & 11 deletions catalyst-gateway/bin/src/service/api/registration/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,20 @@ use poem_openapi::{
};

use crate::{
service::common::{
objects::{
event_id::EventId, voter_registration::VoterRegistration,
voting_public_key::VotingPublicKey,
service::{
common::{
objects::{
event_id::EventId, voter_registration::VoterRegistration,
voting_public_key::VotingPublicKey,
},
responses::{
resp_2xx::OK,
resp_4xx::NotFound,
resp_5xx::{server_error, ServerError, ServiceUnavailable},
},
tags::ApiTags,
},
responses::{
resp_2xx::OK,
resp_4xx::NotFound,
resp_5xx::{server_error, ServerError},
},
tags::ApiTags,
utilities::middleware::schema_validation::schema_version_validation,
},
state::State,
};
Expand All @@ -36,7 +39,8 @@ impl RegistrationApi {
#[oai(
path = "/voter/:voting_key",
method = "get",
operation_id = "getVoterInfo"
operation_id = "getVoterInfo",
transform = "schema_version_validation"
)]
/// Voter's info
///
Expand Down
10 changes: 8 additions & 2 deletions catalyst-gateway/bin/src/service/api/v0/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ use std::sync::Arc;
use poem::web::Data;
use poem_openapi::{payload::Binary, OpenApi};

use crate::{service::common::tags::ApiTags, state::State};
use crate::{
service::{
common::tags::ApiTags, utilities::middleware::schema_validation::schema_version_validation,
},
state::State,
};

mod message_post;
mod plans_get;
Expand All @@ -25,7 +30,8 @@ impl V0Api {
#[oai(
path = "/vote/active/plans",
method = "get",
operation_id = "GetActivePlans"
operation_id = "GetActivePlans",
transform = "schema_version_validation"
)]
async fn plans_get(&self, state: Data<&Arc<State>>) -> plans_get::AllResponses {
plans_get::endpoint(state).await
Expand Down
14 changes: 10 additions & 4 deletions catalyst-gateway/bin/src/service/api/v1/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@ use poem::web::{Data, Path};
use poem_openapi::{param::Query, payload::Json, OpenApi};

use crate::{
service::common::{
objects::{account_votes::AccountId, fragments_batch::FragmentsBatch},
tags::ApiTags,
service::{
common::{
objects::{account_votes::AccountId, fragments_batch::FragmentsBatch},
tags::ApiTags,
},
utilities::middleware::schema_validation::schema_version_validation,
},
state::State,
};
Expand All @@ -25,7 +28,8 @@ impl V1Api {
#[oai(
path = "/votes/plan/account-votes/:account_id",
method = "get",
operation_id = "AccountVotes"
operation_id = "AccountVotes",
transform = "schema_version_validation"
)]
/// Get from all active vote plans, the index of the voted proposals
/// by th given account ID.
Expand All @@ -43,6 +47,7 @@ impl V1Api {
method = "post",
operation_id = "fragments",
tag = "ApiTags::Fragments",
transform = "schema_version_validation",
deprecated = true
)]
async fn fragments_post(
Expand All @@ -61,6 +66,7 @@ impl V1Api {
method = "get",
operation_id = "fragmentsStatuses",
tag = "ApiTags::Fragments",
transform = "schema_version_validation",
deprecated = true
)]
async fn fragments_statuses(
Expand Down

0 comments on commit 65180ff

Please sign in to comment.