I ended up writing a shell script to solve the problem:
API_ROOT_URL="http://petstore.swagger.wordnik.com/api/api-docs" OUT_DIR=`pwd` function download_json { echo "Downloading $1 to $OUT_DIR$2.json" curl -sS $1 | jq . > $OUT_DIR$2.json } download_json $API_ROOT_URL /api-index jq -r .apis[].path $OUT_DIR/api-index.json | while read -r API_PATH; do API_PATH=${API_PATH#$API_ROOT_URL} download_json $API_ROOT_URL$API_PATH $API_PATH done
It uses jq to extract the API paths from the index file, and also to beautifully print JSON as it loads. As webron mentions, this is likely to be of interest only to people who are still using the 1.x Swagger scheme, although I can see that I will adapt this script for other problems in the future.
One problem I found with this for Swagger is that the order of entries in our API docs seems to be unstable. Running the script several times in a row against our API documents (generated by swagger-springmvc) results in minor changes to property orders. This can be partially eliminated by sorting the property keys of JSON objects using the jq --sort-keys option, but this does not apply to all cases, for example. a model schema required property, which is a simple array of string property names.
source share