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

[Client] Inconsistent Default vs skip_serializing_none usage for status pages #45

Closed
CommanderStorm opened this issue May 23, 2024 · 2 comments

Comments

@CommanderStorm
Copy link

CommanderStorm commented May 23, 2024

Hi, I just tried to use the client and I came across a bit of a weird API-decision.

I wanted to ask if the partial usage of skip_serializing_none and the partial usage of Default is intentional and If you'd like a PR for this (in either direction)

here Default is not implemented

#[serde_inline_default]
#[skip_serializing_none]
#[serde_as]
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct StatusPage {

vs here Default is implemented

impl Default for $struct_name {
fn default() -> Self {
serde_json::from_value(json!({})).unwrap()
}
}

The result is that the handy ..Default::default() shorthand does not work for all models.

PS:
during trying the stus page I came acros this design decision:

pub icon: Option<String>,

=> this should be icon: String with a data:..-url. there is a patch for this in an upcoming release where we are going to accept urls there, but currently only data:

@BigBoot
Copy link
Owner

BigBoot commented May 27, 2024

Hi

I wanted to ask if the partial usage of skip_serializing_none and the partial usage of Default is intentional and If you'd like a PR for this (in either direction)

here Default is not implemented

#[serde_inline_default]
#[skip_serializing_none]
#[serde_as]
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct StatusPage {

vs here Default is implemented

impl Default for $struct_name {
fn default() -> Self {
serde_json::from_value(json!({})).unwrap()
}
}

The result is that the handy ..Default::default() shorthand does not work for all models.

I've added a Default implementation for all of the models now. Since there is no formal definition of the models in Uptime Kuma I went with Option and skip_serializing_none everywhere to directly relay missing property error message from server.

PS: during trying the stus page I came acros this design decision:

pub icon: Option<String>,

=> this should be icon: String with a data:..-url. there is a patch for this in an upcoming release where we are going to accept urls there, but currently only data:

See my reasoning above for the decision to use Option. I've also added a small workaround for setting urls as icons, so this should work now.

@CommanderStorm
Copy link
Author

thanks 😍 🎉

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

No branches or pull requests

2 participants