Maybe use jq to generate JSON body #13
Labels
No Label
@license
bug
duplicate
enhancement
Feature
help wanted
invalid
Matrix API
Meta
question
release blocker
Synapse API
task
tech debt
wontfix
No Milestone
No project
No Assignees
1 Participants
Notifications
Total Time Spent: 4 hours 10 minutes
Due Date
joe
4 hours 10 minutes
No due date set.
Dependencies
No dependencies set.
Reference: joe/axon.sh#13
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Rather than manually specifying the JSON body for each request, jq could be used to dynamically generate it. This might make updating easier when the target API changes.
Manually defining the JSON body for each request will be especially cumbersome for some APIs which accept optional parameters with no defaults. In these cases a separate body would have to be defined to account for the optional parameter.
For example the Room Deletion API (See #16) accepts an optional parameter
new_room_user_id
which defines a user account to use to invite users from a deleted room to a new notification room, but if the parameter is passed in the body, it cannot simply be left empty.An alternative in this specific case — but not necessarily future cases — would be to specify a default user, with a name unlikely to be already taken, but this would force admins using axon.sh to invite users from a deleted room to a new notification room, while Synapse allows admins to simply remove them from the room.
jo is likely a better option for generating JSON https://github.com/jpmens/jo
Dynamically constructing JSON with jo turns out to be just as — and sometimes more — verbose than using jq and a simple wrapper. There is little reason to add an additional dependency.