Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DEPENDENCIES
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
vendorpull https://github.com/sourcemeta/vendorpull 1dcbac42809cf87cb5b045106b863e17ad84ba02
core https://github.com/sourcemeta/core 9eb79e6d10f9a141b214b29867f602bd3ec6202a
core https://github.com/sourcemeta/core 6cdc6b362fef03e3efb5b674095287d983bafffa
jsonbinpack https://github.com/sourcemeta/jsonbinpack 3898774a945ebf7392bad8a9015ead97a0518a19
blaze https://github.com/sourcemeta/blaze a7d43ba8a4de39918f44b97602950e260809cd0d
hydra https://github.com/sourcemeta/hydra 6e0ad118846ce57275bc7d6434f8440baae2c27e
Expand Down
2 changes: 1 addition & 1 deletion src/resolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ class CustomResolver {
sourcemeta::core::reidentify(subschema, key.second, entry.base_dialect);

const auto result{this->schemas.emplace(key.second, subschema)};
if (!result.second && result.first->second != schema) {
if (!result.second && result.first->second != subschema) {
throw sourcemeta::core::SchemaFrameError(
key.second, "Cannot register the same identifier twice");
}
Expand Down
1 change: 1 addition & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ add_jsonschema_test_unix(bundle/fail_invalid_id_type)
add_jsonschema_test_unix(bundle/fail_invalid_schema_uri)
add_jsonschema_test_unix(bundle/pass_config_ignore)
add_jsonschema_test_unix(bundle/pass_ref_in_bundled_resolves_against_id)
add_jsonschema_test_unix(bundle/pass_resolve_deduplicate_embedded)

# Inspect
add_jsonschema_test_unix(inspect/pass)
Expand Down
12 changes: 5 additions & 7 deletions test/bundle/pass_ref_in_bundled_resolves_against_id.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,14 @@ cat << EOF > "$TMP/expected.json"
"title": "Entry",
"\$ref": "https://example.com/schemas/parent",
"\$defs": {
"https://example.com/schemas/child": {
"\$id": "https://example.com/schemas/child",
"type": "string"
},
"https://example.com/schemas/parent": {
"\$schema": "https://json-schema.org/draft/2020-12/schema",
"\$id": "https://example.com/schemas/parent",
"\$ref": "./child",
"\$defs": {
"https://example.com/schemas/child": {
"\$id": "https://example.com/schemas/child",
"type": "string"
}
}
"\$ref": "./child"
}
}
}
Expand Down
95 changes: 95 additions & 0 deletions test/bundle/pass_resolve_deduplicate_embedded.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
#!/bin/sh

set -o errexit
set -o nounset

TMP="$(mktemp -d)"
clean() { rm -rf "$TMP"; }
trap clean EXIT

cat << 'EOF' > "$TMP/common.json"
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://example.com/common",
"type": "string"
}
EOF

cat << 'EOF' > "$TMP/a.json"
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://example.com/a",
"$ref": "common",
"$defs": {
"https://example.com/common": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://example.com/common",
"type": "string"
}
}
}
EOF

cat << 'EOF' > "$TMP/b.json"
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://example.com/b",
"$ref": "common",
"$defs": {
"https://example.com/common": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://example.com/common",
"type": "string"
}
}
}
EOF

cat << 'EOF' > "$TMP/entry.json"
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://example.com/entry",
"allOf": [
{ "$ref": "a" },
{ "$ref": "b" }
]
}
EOF

"$1" bundle "$TMP/entry.json" \
--resolve "$TMP/a.json" \
--resolve "$TMP/b.json" > "$TMP/result.json"

cat << 'EOF' > "$TMP/expected.json"
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://example.com/entry",
"allOf": [
{
"$ref": "a"
},
{
"$ref": "b"
}
],
"$defs": {
"https://example.com/common": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://example.com/common",
"type": "string"
},
"https://example.com/a": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://example.com/a",
"$ref": "common"
},
"https://example.com/b": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://example.com/b",
"$ref": "common"
}
}
}
EOF

diff "$TMP/result.json" "$TMP/expected.json"
199 changes: 135 additions & 64 deletions vendor/core/src/core/jsonschema/bundle.cc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading