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

Optional request bodies #5

Merged
merged 1 commit into from
Jan 7, 2025
Merged

Conversation

svix-onelson
Copy link
Contributor

@svix-onelson svix-onelson commented Jan 6, 2025

The idea is to identify args for the CLI that can be omitted since the entire body is technically optional.

A problem with the current approach is the optionalness is applied uniform to all cases which includes PATCH requests. Ideally, we'd be treating the PATCH bodies as required, but there's no real harm in letting these flow through as-is.
Today, a user can happily pass an empty object as a body to any PATCH request. This will update the updatedAt timestamp but leave all other fields as-is.

The code for this is a little clumsy. We can likely optimize a bit, remove some clones. I'll leave that for someone with the appetite. I hear there is a different approach we might take anyway. Something involving passing the full component schemas to the template.

Here's the (gently modified) output from these template updates: svix/svix-webhooks#1621

@svix-onelson svix-onelson force-pushed the onelson/optional-request-bodies branch from f5c8987 to 12cbd71 Compare January 6, 2025 20:53
@svix-onelson svix-onelson force-pushed the onelson/optional-request-bodies branch from 12cbd71 to 4e77274 Compare January 6, 2025 22:23
@svix-onelson svix-onelson marked this pull request as ready for review January 6, 2025 23:51
@svix-onelson svix-onelson requested a review from a team as a code owner January 6, 2025 23:51
@svix-onelson svix-onelson force-pushed the onelson/optional-request-bodies branch 2 times, most recently from 7a36da7 to e4fc077 Compare January 6, 2025 23:56
src/api.rs Outdated Show resolved Hide resolved
src/main.rs Outdated Show resolved Hide resolved
@svix-onelson svix-onelson force-pushed the onelson/optional-request-bodies branch from e4fc077 to dbb8484 Compare January 7, 2025 17:58
The idea is to identify args for the CLI that can be omitted since the
entire body is technically optional.
@svix-onelson svix-onelson force-pushed the onelson/optional-request-bodies branch from dbb8484 to 36fbdbe Compare January 7, 2025 17:59
@svix-onelson svix-onelson merged commit 13febcb into main Jan 7, 2025
3 checks passed
@svix-jplatte svix-jplatte deleted the onelson/optional-request-bodies branch January 7, 2025 19:36
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.

3 participants