Skip to content

Instantly share code, notes, and snippets.

View vglebov's full-sized avatar

Vadim Glebov vglebov

  • Kyrgyzstan, Bishkek
View GitHub Profile
@jkrasnay
jkrasnay / swagger-jq.sh
Last active July 19, 2023 02:49
Processing Swagger with jq
# 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] } ]'