Skip to content

Commit e6bc54c

Browse files
committed
fix(validate): address review feedbacks of cubic bot
Signed-off-by: Vaibhav mittal <vaibhavmittal929@gmail.com>
1 parent 7ec6e51 commit e6bc54c

File tree

1 file changed

+30
-4
lines changed

1 file changed

+30
-4
lines changed

test/validate/fail_path_ref_outside_subtree.sh

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,35 @@ cat << 'EOF' > "$TMP/instance.json"
2929
EOF
3030

3131
"$1" validate "$TMP/document.json" "$TMP/instance.json" \
32-
--path "/components/schemas/User" \
33-
> /dev/null 2>&1 \
32+
--path "/components/schemas/User" 2> "$TMP/stderr.txt" \
3433
&& EXIT_CODE="$?" || EXIT_CODE="$?"
35-
# Validation should fail when $ref points outside extracted subtree
36-
test "$EXIT_CODE" -ne "0"
34+
# Schema input error: $ref outside extracted subtree cannot be resolved during bundling
35+
test "$EXIT_CODE" = "4"
36+
37+
cat << EOF > "$TMP/expected.txt"
38+
error: Could not resolve schema reference
39+
at identifier file://$(realpath "$TMP")/document.json#/components/schemas/Address
40+
at file path $(realpath "$TMP")/document.json
41+
at location "/\$ref"
42+
EOF
43+
44+
diff "$TMP/stderr.txt" "$TMP/expected.txt"
45+
46+
# JSON error
47+
"$1" validate "$TMP/document.json" "$TMP/instance.json" \
48+
--path "/components/schemas/User" --json > "$TMP/stdout.txt" \
49+
&& EXIT_CODE="$?" || EXIT_CODE="$?"
50+
# Schema input error
51+
test "$EXIT_CODE" = "4"
52+
53+
cat << EOF > "$TMP/expected.txt"
54+
{
55+
"error": "Could not resolve schema reference",
56+
"identifier": "file://$(realpath "$TMP")/document.json#/components/schemas/Address",
57+
"filePath": "$(realpath "$TMP")/document.json",
58+
"location": "/\$ref"
59+
}
60+
EOF
61+
62+
diff "$TMP/stdout.txt" "$TMP/expected.txt"
3763

0 commit comments

Comments
 (0)