Last active
July 19, 2023 02:49
-
-
Save jkrasnay/7fbdda198561f5ca924edb9c5d7188ce to your computer and use it in GitHub Desktop.
Processing Swagger with jq
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Convert to TSV | |
# Note -r flag | |
# to_entries creates an array of key,value maps, the trailing [] converts this array to stream items | |
cat api-docs.json | jq -r '.paths | to_entries[] | .key as $path | .value | to_entries[] | [.key,$path,.value.tags[0]] | @tsv' | |
# Transform into different JSON... | |
cat api-docs.json | jq '[ .paths | to_entries[] | .key as $path | .value | to_entries[] | { path:$path, method:.key, tag:.value.tags[0] } ]' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
TIL,
to_entries[]
, thank you!