-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support bundling schemas with
?bundle=1
Signed-off-by: Juan Cruz Viotti <[email protected]>
- Loading branch information
Showing
10 changed files
with
249 additions
and
19 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
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,51 @@ | ||
#!/bin/sh | ||
|
||
set -o errexit | ||
set -o nounset | ||
|
||
TMP="$(mktemp -d)" | ||
clean() { rm -rf "$TMP"; } | ||
trap clean EXIT | ||
|
||
cat << EOF > "$TMP/configuration.json" | ||
{ | ||
"url": "https://sourcemeta.com/", | ||
"port": 8000, | ||
"schemas": { | ||
"example/schemas": { | ||
"base": "https://example.com/", | ||
"path": "./schemas" | ||
} | ||
} | ||
} | ||
EOF | ||
|
||
mkdir "$TMP/schemas" | ||
|
||
cat << 'EOF' > "$TMP/schemas/test.json" | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"$id": "https://example.com/test.json", | ||
"allOf": [ { "$ref": "https://sourcemeta.com/external" } ] | ||
} | ||
EOF | ||
|
||
"$1" "$TMP/configuration.json" "$TMP/output" 2> "$TMP/output.txt" && CODE="$?" || CODE="$?" | ||
test "$CODE" = "1" || exit 1 | ||
|
||
cat << EOF > "$TMP/expected.txt" | ||
Using configuration: $(realpath "$TMP")/configuration.json | ||
Writing output to: $(realpath "$TMP")/output | ||
Discovering schemas at: $(realpath "$TMP")/schemas | ||
-- Found schema: $(realpath "$TMP")/schemas/test.json | ||
https://example.com/test.json => https://sourcemeta.com/example/schemas/test.json | ||
-- Processing schema: https://sourcemeta.com/example/schemas/test.json | ||
Schema output: $(realpath "$TMP")/output/schemas/example/schemas/test.json | ||
Compiling metaschema: http://json-schema.org/draft-07/schema# | ||
Validating against its metaschema: https://sourcemeta.com/example/schemas/test.json | ||
Bundling: https://sourcemeta.com/example/schemas/test.json | ||
error: Could not resolve the requested schema | ||
at https://sourcemeta.com/external | ||
EOF | ||
|
||
diff "$TMP/output.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,107 @@ | ||
GET {{base}}/example/bundling/single.json?bundle=1 | ||
HTTP 200 | ||
Content-Type: application/schema+json | ||
Link: <http://json-schema.org/draft-07/schema\#>; rel="describedby" | ||
[Asserts] | ||
header "ETag" exists | ||
header "X-Request-id" exists | ||
|
||
GET {{base}}/example/bundling/single.json?bundle=1 | ||
HTTP 200 | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"$id": "{{base}}/example/bundling/single.json", | ||
"title": "Bundling", | ||
"description": "A bundling example", | ||
"properties": { | ||
"foo": { | ||
"$ref": "http://localhost:8000/example/v2.0/schema.json" | ||
} | ||
}, | ||
"definitions": { | ||
"http://localhost:8000/example/v2.0/schema.json": { | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"$id": "http://localhost:8000/example/v2.0/schema.json", | ||
"type": "integer" | ||
} | ||
} | ||
} | ||
|
||
GET {{base}}/example/bundling/single.json?bundle=0 | ||
HTTP 200 | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"$id": "{{base}}/example/bundling/single.json", | ||
"title": "Bundling", | ||
"description": "A bundling example", | ||
"properties": { | ||
"foo": { | ||
"$ref": "http://localhost:8000/example/v2.0/schema.json" | ||
} | ||
}, | ||
"definitions": { | ||
"http://localhost:8000/example/v2.0/schema.json": { | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"$id": "http://localhost:8000/example/v2.0/schema.json", | ||
"type": "integer" | ||
} | ||
} | ||
} | ||
|
||
GET {{base}}/example/bundling/single.json?bundle=foo | ||
HTTP 200 | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"$id": "{{base}}/example/bundling/single.json", | ||
"title": "Bundling", | ||
"description": "A bundling example", | ||
"properties": { | ||
"foo": { | ||
"$ref": "http://localhost:8000/example/v2.0/schema.json" | ||
} | ||
}, | ||
"definitions": { | ||
"http://localhost:8000/example/v2.0/schema.json": { | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"$id": "http://localhost:8000/example/v2.0/schema.json", | ||
"type": "integer" | ||
} | ||
} | ||
} | ||
|
||
GET {{base}}/example/v2.0/schema.json?bundle=1 | ||
HTTP 200 | ||
Content-Type: application/schema+json | ||
Link: <http://json-schema.org/draft-07/schema\#>; rel="describedby" | ||
[Asserts] | ||
header "ETag" exists | ||
header "X-Request-id" exists | ||
|
||
GET {{base}}/example/v2.0/schema.json?bundle=1 | ||
HTTP 200 | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"$id": "{{base}}/example/v2.0/schema.json", | ||
"type": "integer" | ||
} | ||
|
||
GET {{base}}/example/bundling/single.json?foo=2&bundle=1 | ||
HTTP 200 | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"$id": "{{base}}/example/bundling/single.json", | ||
"title": "Bundling", | ||
"description": "A bundling example", | ||
"properties": { | ||
"foo": { | ||
"$ref": "http://localhost:8000/example/v2.0/schema.json" | ||
} | ||
}, | ||
"definitions": { | ||
"http://localhost:8000/example/v2.0/schema.json": { | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"$id": "http://localhost:8000/example/v2.0/schema.json", | ||
"type": "integer" | ||
} | ||
} | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.