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

responses: make messages and errors default if not present #175

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Noah-Kennedy
Copy link
Collaborator

Both fields are often not returned by certain cloudflare APIs (the Zero Trust API is a good example). Allowing serde to default them if not present allows these APIs to be used with this crate.

Both fields are often not returned by certain cloudflare APIs (the Zero Trust API is a good example). Allowing serde to default them if not present allows these APIs to be used with this crate.
@@ -9,7 +9,9 @@ use serde_json::value::Value as JsonValue;
pub struct ApiSuccess<ResultType> {
pub result: ResultType,
pub result_info: Option<JsonValue>,
#[serde(default)]
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's more correct to make this Option<JsonValue>, rather than defaulting to JsonValue::Null. What do you think @sssilver -- one downside is that it would be a breaking change (although a very easy to fix one)

Copy link
Collaborator Author

@Noah-Kennedy Noah-Kennedy Mar 8, 2022

Choose a reason for hiding this comment

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

I agree with @adamchalmers here. The reason I chose to do it this way is that I felt that we could do just a simple patch release with the changes from this and #174 if we kept this nonbreaking. However, I think that Adam's idea is the better API, and I was originally contemplating doing that for this reason.

@Noah-Kennedy
Copy link
Collaborator Author

@adamchalmers @sssilver I'd like to get this in. Which approach do we want to go with here?

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.

None yet

2 participants