diff --git a/test/jsonschema/frame/draft2/requires_holding_a_schema.json b/test/jsonschema/frame/draft2/requires_holding_a_schema.json new file mode 100644 index 0000000000..e23c550b0e --- /dev/null +++ b/test/jsonschema/frame/draft2/requires_holding_a_schema.json @@ -0,0 +1,159 @@ +{ + "schema": { + "$schema": "http://json-schema.org/draft-02/schema#", + "properties": { + "one": { + "requires": { + "type": "string" + } + } + } + }, + "root": { + "mode": "root", + "locations": { + "static": { + "": { + "parent": null, + "type": "subschema", + "root": null, + "base": "", + "pointer": "", + "relativePointer": "", + "dialect": "http://json-schema.org/draft-02/schema#", + "baseDialect": "http://json-schema.org/draft-02/hyper-schema#", + "propertyName": false, + "orphan": false, + "hasReferencesTo": false, + "hasReferencesThrough": false, + "vocabularies": { + "http://json-schema.org/draft-02/schema#": true + } + } + }, + "dynamic": {} + }, + "references": [] + }, + "pointers": { + "mode": "pointers", + "locations": { + "static": { + "": { + "parent": null, + "type": "subschema", + "root": null, + "base": "", + "pointer": "", + "relativePointer": "", + "dialect": "http://json-schema.org/draft-02/schema#", + "baseDialect": "http://json-schema.org/draft-02/hyper-schema#", + "propertyName": false, + "orphan": false, + "hasReferencesTo": false, + "hasReferencesThrough": false, + "vocabularies": { + "http://json-schema.org/draft-02/schema#": true + } + }, + "#/$schema": { + "parent": "", + "type": "pointer", + "root": null, + "base": "", + "pointer": "/$schema", + "relativePointer": "/$schema", + "dialect": "http://json-schema.org/draft-02/schema#", + "baseDialect": "http://json-schema.org/draft-02/hyper-schema#", + "propertyName": false, + "orphan": false, + "hasReferencesTo": false, + "hasReferencesThrough": false, + "vocabularies": { + "http://json-schema.org/draft-02/schema#": true + } + }, + "#/properties": { + "parent": "", + "type": "pointer", + "root": null, + "base": "", + "pointer": "/properties", + "relativePointer": "/properties", + "dialect": "http://json-schema.org/draft-02/schema#", + "baseDialect": "http://json-schema.org/draft-02/hyper-schema#", + "propertyName": false, + "orphan": false, + "hasReferencesTo": false, + "hasReferencesThrough": false, + "vocabularies": { + "http://json-schema.org/draft-02/schema#": true + } + }, + "#/properties/one": { + "parent": "", + "type": "subschema", + "root": null, + "base": "", + "pointer": "/properties/one", + "relativePointer": "/properties/one", + "dialect": "http://json-schema.org/draft-02/schema#", + "baseDialect": "http://json-schema.org/draft-02/hyper-schema#", + "propertyName": false, + "orphan": false, + "hasReferencesTo": false, + "hasReferencesThrough": false, + "vocabularies": { + "http://json-schema.org/draft-02/schema#": true + } + }, + "#/properties/one/requires": { + "parent": "/properties/one", + "type": "subschema", + "root": null, + "base": "", + "pointer": "/properties/one/requires", + "relativePointer": "/properties/one/requires", + "dialect": "http://json-schema.org/draft-02/schema#", + "baseDialect": "http://json-schema.org/draft-02/hyper-schema#", + "propertyName": false, + "orphan": false, + "hasReferencesTo": false, + "hasReferencesThrough": false, + "vocabularies": { + "http://json-schema.org/draft-02/schema#": true + } + }, + "#/properties/one/requires/type": { + "parent": "/properties/one/requires", + "type": "pointer", + "root": null, + "base": "", + "pointer": "/properties/one/requires/type", + "relativePointer": "/properties/one/requires/type", + "dialect": "http://json-schema.org/draft-02/schema#", + "baseDialect": "http://json-schema.org/draft-02/hyper-schema#", + "propertyName": false, + "orphan": false, + "hasReferencesTo": false, + "hasReferencesThrough": false, + "vocabularies": { + "http://json-schema.org/draft-02/schema#": true + } + } + }, + "dynamic": {} + }, + "references": [ + { + "type": "static", + "origin": "/$schema", + "original": "http://json-schema.org/draft-02/schema#", + "destination": "http://json-schema.org/draft-02/schema", + "base": "http://json-schema.org/draft-02/schema", + "fragment": null + } + ] + }, + "standalone": true +} diff --git a/test/jsonschema/frame/draft3/disallow_holding_a_schema.json b/test/jsonschema/frame/draft3/disallow_holding_a_schema.json new file mode 100644 index 0000000000..480464f799 --- /dev/null +++ b/test/jsonschema/frame/draft3/disallow_holding_a_schema.json @@ -0,0 +1,158 @@ +{ + "schema": { + "$schema": "http://json-schema.org/draft-03/schema#", + "disallow": [ + { + "type": "string" + }, + "null" + ] + }, + "root": { + "mode": "root", + "locations": { + "static": { + "": { + "parent": null, + "type": "subschema", + "root": null, + "base": "", + "pointer": "", + "relativePointer": "", + "dialect": "http://json-schema.org/draft-03/schema#", + "baseDialect": "http://json-schema.org/draft-03/schema#", + "propertyName": false, + "orphan": false, + "hasReferencesTo": false, + "hasReferencesThrough": false, + "vocabularies": { + "http://json-schema.org/draft-03/schema#": true + } + } + }, + "dynamic": {} + }, + "references": [] + }, + "pointers": { + "mode": "pointers", + "locations": { + "static": { + "": { + "parent": null, + "type": "subschema", + "root": null, + "base": "", + "pointer": "", + "relativePointer": "", + "dialect": "http://json-schema.org/draft-03/schema#", + "baseDialect": "http://json-schema.org/draft-03/schema#", + "propertyName": false, + "orphan": false, + "hasReferencesTo": false, + "hasReferencesThrough": false, + "vocabularies": { + "http://json-schema.org/draft-03/schema#": true + } + }, + "#/$schema": { + "parent": "", + "type": "pointer", + "root": null, + "base": "", + "pointer": "/$schema", + "relativePointer": "/$schema", + "dialect": "http://json-schema.org/draft-03/schema#", + "baseDialect": "http://json-schema.org/draft-03/schema#", + "propertyName": false, + "orphan": false, + "hasReferencesTo": false, + "hasReferencesThrough": false, + "vocabularies": { + "http://json-schema.org/draft-03/schema#": true + } + }, + "#/disallow": { + "parent": "", + "type": "pointer", + "root": null, + "base": "", + "pointer": "/disallow", + "relativePointer": "/disallow", + "dialect": "http://json-schema.org/draft-03/schema#", + "baseDialect": "http://json-schema.org/draft-03/schema#", + "propertyName": false, + "orphan": false, + "hasReferencesTo": false, + "hasReferencesThrough": false, + "vocabularies": { + "http://json-schema.org/draft-03/schema#": true + } + }, + "#/disallow/0": { + "parent": "", + "type": "subschema", + "root": null, + "base": "", + "pointer": "/disallow/0", + "relativePointer": "/disallow/0", + "dialect": "http://json-schema.org/draft-03/schema#", + "baseDialect": "http://json-schema.org/draft-03/schema#", + "propertyName": false, + "orphan": false, + "hasReferencesTo": false, + "hasReferencesThrough": false, + "vocabularies": { + "http://json-schema.org/draft-03/schema#": true + } + }, + "#/disallow/0/type": { + "parent": "/disallow/0", + "type": "pointer", + "root": null, + "base": "", + "pointer": "/disallow/0/type", + "relativePointer": "/disallow/0/type", + "dialect": "http://json-schema.org/draft-03/schema#", + "baseDialect": "http://json-schema.org/draft-03/schema#", + "propertyName": false, + "orphan": false, + "hasReferencesTo": false, + "hasReferencesThrough": false, + "vocabularies": { + "http://json-schema.org/draft-03/schema#": true + } + }, + "#/disallow/1": { + "parent": "", + "type": "pointer", + "root": null, + "base": "", + "pointer": "/disallow/1", + "relativePointer": "/disallow/1", + "dialect": "http://json-schema.org/draft-03/schema#", + "baseDialect": "http://json-schema.org/draft-03/schema#", + "propertyName": false, + "orphan": false, + "hasReferencesTo": false, + "hasReferencesThrough": false, + "vocabularies": { + "http://json-schema.org/draft-03/schema#": true + } + } + }, + "dynamic": {} + }, + "references": [ + { + "type": "static", + "origin": "/$schema", + "original": "http://json-schema.org/draft-03/schema#", + "destination": "http://json-schema.org/draft-03/schema", + "base": "http://json-schema.org/draft-03/schema", + "fragment": null + } + ] + }, + "standalone": true +} diff --git a/test/jsonschema/jsonschema_frame_error_test.cc b/test/jsonschema/jsonschema_frame_error_test.cc index a52be9ae89..4fd3fd889b 100644 --- a/test/jsonschema/jsonschema_frame_error_test.cc +++ b/test/jsonschema/jsonschema_frame_error_test.cc @@ -2639,3 +2639,26 @@ TEST(draft7_root_id_fragment_invalid_leading_digit_root_mode) { FAIL(); } } + +TEST(identifier_that_is_not_a_valid_uri) { + const sourcemeta::core::JSON document = sourcemeta::core::parse_json(R"JSON({ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "https://example.com/schema", + "$defs": { + "inner": { "$id": "//[::44.1" } + } + })JSON"); + + try { + [[maybe_unused]] const sourcemeta::core::SchemaFrame frame{ + sourcemeta::core::SchemaFrame::Mode::References, document, + sourcemeta::core::schema_walker, sourcemeta::core::schema_resolver}; + FAIL(); + } catch (const sourcemeta::core::SchemaKeywordError &error) { + EXPECT_STREQ(error.what(), "The identifier is not a valid URI"); + EXPECT_EQ(error.keyword(), "$id"); + EXPECT_EQ(error.value(), "//[::44.1"); + } catch (...) { + FAIL(); + } +}