Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Http api and http testing #84

Draft
wants to merge 167 commits into
base: unstable
Choose a base branch
from
Draft

Conversation

magick93
Copy link

@magick93 magick93 commented Jan 8, 2025

Issue Addressed

This is related to #26 and related testing issues.

Proposed Changes

Proposal to use identical paths / endpoints and method names as the ssv openapi spec.

But, as these spec is incomplete in terms of response types, to improve it by being more rigorous with, in particular, response types.

hardcode docker repo, set dockerfile location
use Cargo.toml as source of truth
fix path for toml_reader.sh

/// OperatorMetadataDto model
#[derive(Debug, Serialize, Deserialize, ToSchema)]
pub struct OperatorMetadataDto {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the fields should stick with rust underscore convention and just use serde rename. Something like
#[serde(rename = "operatorName")] pub operator_name: Option<String>

use super::handlers::*;

pub fn create_router() -> Router {
Router::new()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might be nice to try to break these functions up into modules for a nice organizational hierarchy.

Something like a root handler module, than operator module, network module, cluster module, etc. Then instead of the long function name you could do handle::operator::get_operator, handle::cluster::get_id. Doesn't have to be that structure, just some separation.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Zacholme7 - yes, was thinking the same.

use utoipa::ToSchema;


#[utoipa::path(GET, path = "/api/v4/{network}/accounts", tag = "Accounts", params(("network", String),("page", String),("perPage", String),),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these macros are quite verbose. im not very familiar with utopia so im not sure if this is the convention. is there any way to simplify these?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The utoipa macro seems to be the most common way to add openapi / swagger docs.

I get it though, it is verbose. But these openapi annotations do make it easier for api consumers.

These function signatures are generated from templates. So we can tweak the templates to our liking.

@Zacholme7
Copy link
Member

Zacholme7 commented Jan 8, 2025

Nice start on this its good to get all these down and now we can start to nail down specifics! Left some early feedback with nitpick comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants