Skip to content

Comments

Http api and http testing#84

Closed
magick93 wants to merge 171 commits intosigp:unstablefrom
magick93:http-api-testing
Closed

Http api and http testing#84
magick93 wants to merge 171 commits intosigp:unstablefrom
magick93:http-api-testing

Conversation

@magick93
Copy link
Contributor

@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
Contributor 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
Contributor 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.

@jking-aus
Copy link
Member

closing this -- appreciate the effort but I think we should work on adding features as required for the http-api

@jking-aus jking-aus closed this Mar 10, 2025
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.

5 participants