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

JSON fixes for optional fields #15

Merged
merged 3 commits into from
Jul 6, 2021
Merged

Conversation

@umutuzgur
Copy link
Member

Hey @devillexio, thanks for sending the PR. Our APIs follow the Stripe PUT/PATCH style. This means omiting everything that is empty or null will prevent people from nulling their settings or sending an empty tags field to remove their existing tags in a check. This will sadly break, especially, our PUT requests. I will see how we can address this in the backend

@pastjean
Copy link

Hi @umutuzgur,
Stripe go SDK does make everything optional by putting everything other than slices as pointer. This makes it so the "zero-value" is the one to reset. and null is the one to not change a value. There are no omitempty in Stripe's go api though.

I believe that part of @devillexio PR is good (turning stuff into pointers). Where the omit empty might indeed not work with how you expect the API to behave.

@devillecodes
Copy link
Author

I don't mind making changes in line with what the Checkly API expects. When this is merged, my hope is to have consensus on the behaviour between this client and the Checkly API documentation. That would help prevent some of the issues we've seen in testing over the last few days, i.e. seeing API errors when a null value is passed instead of no value at all.

Also, it would be good if you would consider expanding the Checkly API documentation to provide guidance on:

  • when to set fields to empty values, and
  • when to omit them.

The way I interpreted the documentation was that anything marked with (required) would need a value in every request, and everything else could be omitted.

@kjda
Copy link
Contributor

kjda commented Jan 21, 2021

thanks for the PR. having optional fields as pointers is the way to go, we did this in a recent refactor for some fields as a first step.. I hope I can get all those as pointers in the next refactor without breaking things

@ianaya89 ianaya89 changed the base branch from master to nullable July 6, 2021 18:27
@ianaya89 ianaya89 merged commit f27cf2c into checkly:nullable Jul 6, 2021
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