diff --git a/test/data/internal_ref_schema_data.json b/test/data/internal_ref_schema_data.json new file mode 100644 index 00000000..9292d84a --- /dev/null +++ b/test/data/internal_ref_schema_data.json @@ -0,0 +1,8 @@ +{ + "top_level_attribute": false, + "objects_of_subtypes": { + "name_of_subtype": { + "some_attribute": "value" + } + } +} \ No newline at end of file diff --git a/test/files_test.rb b/test/files_test.rb index addcc32d..06d37b9b 100644 --- a/test/files_test.rb +++ b/test/files_test.rb @@ -48,4 +48,9 @@ def test_file_extends assert_valid schema_fixture_path('good_schema_extends1.json'), { 'a' => 5 } assert_valid schema_fixture_path('good_schema_extends2.json'), { 'a' => 5, 'b' => { 'a' => 5 } } end + + def test_internal_ref_schema + assert_valid schema_fixture_path('internal_ref_schema.json'), { 'top_level_attribute' => true } + assert_valid schema_fixture_path('internal_ref_schema.json'), data_fixture_path('internal_ref_schema_data.json'), uri: true + end end diff --git a/test/schemas/internal_ref_schema.json b/test/schemas/internal_ref_schema.json new file mode 100644 index 00000000..e67a7102 --- /dev/null +++ b/test/schemas/internal_ref_schema.json @@ -0,0 +1,37 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "$ref": "#/definitions/Toplevel", + "definitions": { + "Toplevel": { + "properties": { + "top_level_attribute": { + "type": "boolean", + "description": "A toplevel boolean attribute" + }, + "objects_of_subtypes": { + "additionalProperties": { + "$ref": "#/definitions/some.Subtype", + "additionalProperties": false + }, + "type": "object" + } + }, + "additionalProperties": false, + "type": "object", + "title": "Toplevel", + "description": "Toplevel type with some attributes and objects of subtypes." + }, + "some.Subtype": { + "properties": { + "some_attribute": { + "type": "string", + "description": "A string attribute for the sub type" + } + }, + "additionalProperties": false, + "type": "object", + "title": "Subtype", + "description": "Subtype can be used inside toplevel." + } + } +} \ No newline at end of file