Maybe use jq to generate JSON body #13

Closed
opened 2021-09-22 19:54:15 -05:00 by joe · 3 comments
Owner

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.

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.
joe added the
enhancement
label 2021-09-22 19:54:15 -05:00
Author
Owner

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.

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.
joe added reference dev 2022-02-04 22:43:42 -06:00
joe removed reference dev 2022-02-04 22:43:45 -06:00
Author
Owner

jo is likely a better option for generating JSON https://github.com/jpmens/jo

jo is likely a better option for generating JSON https://github.com/jpmens/jo
joe added spent time 2022-06-06 04:54:19 -05:00
2h 30min
Author
Owner

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.

> 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.
joe added spent time 2022-06-06 07:18:23 -05:00
1h 40min
joe closed this issue 2022-06-06 07:18:33 -05:00
joe added this to the Release 1.0.0 milestone 2022-06-06 08:30:29 -05:00
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Total Time Spent: 4 hours 10 minutes
joe
4 hours 10 minutes
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: joe/axon.sh#13
No description provided.