-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve output and error messages from the
validate
command
Signed-off-by: Juan Cruz Viotti <[email protected]>
- Loading branch information
Showing
50 changed files
with
1,059 additions
and
253 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
vendorpull https://github.com/sourcemeta/vendorpull dea311b5bfb53b6926a4140267959ae334d3ecf4 | ||
noa https://github.com/sourcemeta/noa 2bc3138b80e575786bec418c91fc2058c6836993 | ||
jsontoolkit https://github.com/sourcemeta/jsontoolkit 0e2ac8987382685ad6dc50ca33d2e43a6701b023 | ||
jsontoolkit https://github.com/sourcemeta/jsontoolkit 7c229e4243290ad255bba4f3775492147f3972ce | ||
hydra https://github.com/sourcemeta/hydra 3c53d3fdef79e9ba603d48470a508cc45472a0dc |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/bin/sh | ||
|
||
set -o errexit | ||
set -o nounset | ||
|
||
TMP="$(mktemp -d)" | ||
clean() { rm -rf "$TMP"; } | ||
trap clean EXIT | ||
|
||
cat << 'EOF' > "$TMP/schema.json" | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"allOf": [ { "$ref": "https://example.com" } ] | ||
} | ||
EOF | ||
|
||
cat << 'EOF' > "$TMP/instance.json" | ||
{ "type": "string" } | ||
EOF | ||
|
||
"$1" validate "$TMP/schema.json" "$TMP/instance.json" --http 2> "$TMP/stderr.txt" \ | ||
&& CODE="$?" || CODE="$?" | ||
test "$CODE" = "1" || exit 1 | ||
|
||
cat << EOF > "$TMP/expected.txt" | ||
error: 400 Bad Request | ||
at https://example.com | ||
EOF | ||
|
||
diff "$TMP/stderr.txt" "$TMP/expected.txt" |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/bin/sh | ||
|
||
set -o errexit | ||
set -o nounset | ||
|
||
TMP="$(mktemp -d)" | ||
clean() { rm -rf "$TMP"; } | ||
trap clean EXIT | ||
|
||
cat << 'EOF' > "$TMP/schema.json" | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"allOf": [ { "$ref": "https://example.com" } ] | ||
} | ||
EOF | ||
|
||
cat << 'EOF' > "$TMP/instance.json" | ||
{ "type": "string" } | ||
EOF | ||
|
||
"$1" validate "$TMP/schema.json" "$TMP/instance.json" --http --verbose 2> "$TMP/stderr.txt" \ | ||
&& CODE="$?" || CODE="$?" | ||
test "$CODE" = "1" || exit 1 | ||
|
||
cat << EOF > "$TMP/expected.txt" | ||
Resolving over HTTP: https://example.com | ||
error: 400 Bad Request | ||
at https://example.com | ||
EOF | ||
|
||
diff "$TMP/stderr.txt" "$TMP/expected.txt" |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/bin/sh | ||
|
||
set -o errexit | ||
set -o nounset | ||
|
||
TMP="$(mktemp -d)" | ||
clean() { rm -rf "$TMP"; } | ||
trap clean EXIT | ||
|
||
cat << 'EOF' > "$TMP/schema.json" | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"allOf": [ { "$ref": "https://jsonplaceholder.typicode.com/todos/1" } ] | ||
} | ||
EOF | ||
|
||
cat << 'EOF' > "$TMP/instance.json" | ||
{ "type": "string" } | ||
EOF | ||
|
||
"$1" validate "$TMP/schema.json" "$TMP/instance.json" --http 2> "$TMP/stderr.txt" \ | ||
&& CODE="$?" || CODE="$?" | ||
test "$CODE" = "1" || exit 1 | ||
|
||
cat << EOF > "$TMP/expected.txt" | ||
error: The JSON document is not a valid JSON Schema | ||
at https://jsonplaceholder.typicode.com/todos/1 | ||
EOF | ||
|
||
diff "$TMP/stderr.txt" "$TMP/expected.txt" |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/bin/sh | ||
|
||
set -o errexit | ||
set -o nounset | ||
|
||
TMP="$(mktemp -d)" | ||
clean() { rm -rf "$TMP"; } | ||
trap clean EXIT | ||
|
||
cat << 'EOF' > "$TMP/schema.json" | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"allOf": [ { "$ref": "https://jsonplaceholder.typicode.com/todos/1" } ] | ||
} | ||
EOF | ||
|
||
cat << 'EOF' > "$TMP/instance.json" | ||
{ "type": "string" } | ||
EOF | ||
|
||
"$1" validate "$TMP/schema.json" "$TMP/instance.json" --http --verbose 2> "$TMP/stderr.txt" \ | ||
&& CODE="$?" || CODE="$?" | ||
test "$CODE" = "1" || exit 1 | ||
|
||
cat << EOF > "$TMP/expected.txt" | ||
Resolving over HTTP: https://jsonplaceholder.typicode.com/todos/1 | ||
error: The JSON document is not a valid JSON Schema | ||
at https://jsonplaceholder.typicode.com/todos/1 | ||
EOF | ||
|
||
diff "$TMP/stderr.txt" "$TMP/expected.txt" |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/sh | ||
|
||
set -o errexit | ||
set -o nounset | ||
|
||
TMP="$(mktemp -d)" | ||
clean() { rm -rf "$TMP"; } | ||
trap clean EXIT | ||
|
||
cat << 'EOF' > "$TMP/schema.json" | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"allOf": [ { "$ref": "https://json.schemastore.org/mocharc.json" } ] | ||
} | ||
EOF | ||
|
||
cat << 'EOF' > "$TMP/instance.json" | ||
{ "exit": true } | ||
EOF | ||
|
||
"$1" validate "$TMP/schema.json" "$TMP/instance.json" --http 2> "$TMP/stderr.txt" | ||
|
||
cat << EOF > "$TMP/expected.txt" | ||
EOF | ||
|
||
diff "$TMP/stderr.txt" "$TMP/expected.txt" |
Oops, something went wrong.