c@63: #!/bin/bash c@36: c@63: set -eu c@52: c@63: reqfile="/tmp/$$.req.json" c@63: respfile="/tmp/$$.resp.json" c@63: trap "rm -f $reqfile $respfile" 0 c@52: c@63: schema=vamp-json-schema/schema c@63: c@63: validate() { c@63: local file="$1" c@63: local schemaname="$2" c@63: jsonschema -i "$file" "$schema/$schemaname.json" 1>&2 && \ c@63: echo "validated $schemaname" 1>&2 || \ c@63: echo "failed to validate $schemaname" 1>&2 c@63: } c@63: c@63: validate_request() { c@63: local json="$1" c@63: echo "$json" > "$reqfile" c@63: validate "$reqfile" "request" c@63: type=$(grep '"type":' "$reqfile" | sed 's/^.*"type": *"\([^"]*\)".*$/\1/') c@63: if [ "$type" == "configure" ]; then type=configuration; fi c@63: if [ "$type" != "list" ]; then c@63: echo "$json" | c@63: sed 's/^.*"content"://' | c@63: sed 's/}}$/}/' > "$reqfile" c@63: validate "$reqfile" "${type}request" c@63: fi c@63: } c@63: c@63: validate_response() { c@63: local json="$1" c@63: echo "$json" > "$respfile" c@63: validate "$respfile" "response" c@63: type=$(grep '"type":' "$respfile" | sed 's/^.*"type": "\([^"]*\)".*$/\1/') c@63: if [ "$type" == "configure" ]; then type=configuration; fi c@63: echo "$json" | c@63: sed 's/^.*"content"://' | c@63: sed 's/, "error.*$//' | c@63: sed 's/, "success.*$//' > "$respfile" c@63: validate "$respfile" "${type}response" c@63: } c@63: c@63: ( while read request ; do c@63: validate_request "$request" c@63: echo "$request" c@63: done | c@63: bin/vampipe-convert request -i json -o capnp | c@63: VAMP_PATH=./vamp-plugin-sdk/examples bin/vampipe-server | c@63: bin/vampipe-convert response -i capnp -o json | c@63: while read response ; do c@63: validate_response "$response" c@63: done c@52: ) <