Skip to content
Open
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
8 changes: 8 additions & 0 deletions test/data/internal_ref_schema_data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"top_level_attribute": false,
"objects_of_subtypes": {
"name_of_subtype": {
"some_attribute": "value"
}
}
}
5 changes: 5 additions & 0 deletions test/files_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
37 changes: 37 additions & 0 deletions test/schemas/internal_ref_schema.json
Original file line number Diff line number Diff line change
@@ -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."
}
}
}