Skip to content

Commit

Permalink
feat: allow (visually) exporting the list of known API error codes (#28)
Browse files Browse the repository at this point in the history
* Allow (visually) exporting the list of known API error codes

The goal, as stated in the change, is to easy copy-pasting
to developer.kivra.com, thus reducing the chance of
inconsistency

* Move implementation to Bash script
  • Loading branch information
kivra-pauoli authored Nov 14, 2023
1 parent 29dbfe4 commit 8e879fb
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,17 @@ The following message contains the same information, but is more concise:
Run the linter to validate the error definitions in [`api-errors.json`](./api-errors.json):

make lint

## Export for use in `developer.kivra.com`

A `util` script is made available to allow copy-pasting the entire list for
acceptance in <https://developer.kivra.com>.

For this you need to have [`jq`](https://github.com/jqlang/jq#installation) installed.

```console
./util/to-developer.kivra.com.sh
```

Whatever is between `<copy-paste>` and `</copy-paste>` is deemed usable
(YML-formatted) in <https://developer.kivra.com>.
13 changes: 13 additions & 0 deletions util/to-developer.kivra.com.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

if ! command -v jq &>/dev/null; then
echo "You need 'jq' to run this script."
exit 1
fi

echo "Copy-paste to developer.kivra.com's swagger.yml"
echo "<copy-paste>"
echo " | Code | Short Message | Long Message |"
echo " | ---- | ------------- | ------------ |"
jq -r 'to_entries | sort_by(.key) | .[] | " | \(.key) | \(.value.short_message) | \(.value.long_message) |"' <api-errors.json
echo "</copy-paste>"

0 comments on commit 8e879fb

Please sign in to comment.