Skip to content

Commit 9b9da60

Browse files
committed
Also add tests for refs with URN+pointer and URN+fragment.
1 parent 96255ef commit 9b9da60

File tree

5 files changed

+255
-0
lines changed

5 files changed

+255
-0
lines changed

tests/draft-next/ref.json

+51
Original file line numberDiff line numberDiff line change
@@ -779,5 +779,56 @@
779779
"valid": false
780780
}
781781
]
782+
},
783+
{
784+
"description": "URN base URI with URN and JSON pointer ref",
785+
"schema": {
786+
"$id": "urn:uuid:deadbeef-1234-0000-0000-4321feebdaed",
787+
"properties": {
788+
"foo": {"$ref": "urn:uuid:deadbeef-1234-0000-0000-4321feebdaed#/$defs/bar"}
789+
},
790+
"$defs": {
791+
"bar": {"type": "string"}
792+
}
793+
},
794+
"tests": [
795+
{
796+
"description": "a string is valid",
797+
"data": {"foo": "bar"},
798+
"valid": true
799+
},
800+
{
801+
"description": "a non-string is invalid",
802+
"data": {"foo": 12},
803+
"valid": false
804+
}
805+
]
806+
},
807+
{
808+
"description": "URN base URI with URN and anchor ref",
809+
"schema": {
810+
"$id": "urn:uuid:deadbeef-1234-0000-0000-4321feebdaed",
811+
"properties": {
812+
"foo": {"$ref": "urn:uuid:deadbeef-1234-0000-0000-4321feebdaed#something"}
813+
},
814+
"$defs": {
815+
"bar": {
816+
"$anchor": "something",
817+
"type": "string"
818+
}
819+
}
820+
},
821+
"tests": [
822+
{
823+
"description": "a string is valid",
824+
"data": {"foo": "bar"},
825+
"valid": true
826+
},
827+
{
828+
"description": "a non-string is invalid",
829+
"data": {"foo": 12},
830+
"valid": false
831+
}
832+
]
782833
}
783834
]

tests/draft2019-09/ref.json

+51
Original file line numberDiff line numberDiff line change
@@ -779,5 +779,56 @@
779779
"valid": false
780780
}
781781
]
782+
},
783+
{
784+
"description": "URN base URI with URN and JSON pointer ref",
785+
"schema": {
786+
"$id": "urn:uuid:deadbeef-1234-0000-0000-4321feebdaed",
787+
"properties": {
788+
"foo": {"$ref": "urn:uuid:deadbeef-1234-0000-0000-4321feebdaed#/$defs/bar"}
789+
},
790+
"$defs": {
791+
"bar": {"type": "string"}
792+
}
793+
},
794+
"tests": [
795+
{
796+
"description": "a string is valid",
797+
"data": {"foo": "bar"},
798+
"valid": true
799+
},
800+
{
801+
"description": "a non-string is invalid",
802+
"data": {"foo": 12},
803+
"valid": false
804+
}
805+
]
806+
},
807+
{
808+
"description": "URN base URI with URN and anchor ref",
809+
"schema": {
810+
"$id": "urn:uuid:deadbeef-1234-0000-0000-4321feebdaed",
811+
"properties": {
812+
"foo": {"$ref": "urn:uuid:deadbeef-1234-0000-0000-4321feebdaed#something"}
813+
},
814+
"$defs": {
815+
"bar": {
816+
"$anchor": "something",
817+
"type": "string"
818+
}
819+
}
820+
},
821+
"tests": [
822+
{
823+
"description": "a string is valid",
824+
"data": {"foo": "bar"},
825+
"valid": true
826+
},
827+
{
828+
"description": "a non-string is invalid",
829+
"data": {"foo": 12},
830+
"valid": false
831+
}
832+
]
782833
}
783834
]

tests/draft2020-12/ref.json

+51
Original file line numberDiff line numberDiff line change
@@ -779,5 +779,56 @@
779779
"valid": false
780780
}
781781
]
782+
},
783+
{
784+
"description": "URN base URI with URN and JSON pointer ref",
785+
"schema": {
786+
"$id": "urn:uuid:deadbeef-1234-0000-0000-4321feebdaed",
787+
"properties": {
788+
"foo": {"$ref": "urn:uuid:deadbeef-1234-0000-0000-4321feebdaed#/$defs/bar"}
789+
},
790+
"$defs": {
791+
"bar": {"type": "string"}
792+
}
793+
},
794+
"tests": [
795+
{
796+
"description": "a string is valid",
797+
"data": {"foo": "bar"},
798+
"valid": true
799+
},
800+
{
801+
"description": "a non-string is invalid",
802+
"data": {"foo": 12},
803+
"valid": false
804+
}
805+
]
806+
},
807+
{
808+
"description": "URN base URI with URN and anchor ref",
809+
"schema": {
810+
"$id": "urn:uuid:deadbeef-1234-0000-0000-4321feebdaed",
811+
"properties": {
812+
"foo": {"$ref": "urn:uuid:deadbeef-1234-0000-0000-4321feebdaed#something"}
813+
},
814+
"$defs": {
815+
"bar": {
816+
"$anchor": "something",
817+
"type": "string"
818+
}
819+
}
820+
},
821+
"tests": [
822+
{
823+
"description": "a string is valid",
824+
"data": {"foo": "bar"},
825+
"valid": true
826+
},
827+
{
828+
"description": "a non-string is invalid",
829+
"data": {"foo": 12},
830+
"valid": false
831+
}
832+
]
782833
}
783834
]

tests/draft6/ref.json

+51
Original file line numberDiff line numberDiff line change
@@ -731,5 +731,56 @@
731731
"valid": false
732732
}
733733
]
734+
},
735+
{
736+
"description": "URN base URI with URN and JSON pointer ref",
737+
"schema": {
738+
"$id": "urn:uuid:deadbeef-1234-0000-0000-4321feebdaed",
739+
"properties": {
740+
"foo": {"$ref": "urn:uuid:deadbeef-1234-0000-0000-4321feebdaed#/$defs/bar"}
741+
},
742+
"$defs": {
743+
"bar": {"type": "string"}
744+
}
745+
},
746+
"tests": [
747+
{
748+
"description": "a string is valid",
749+
"data": {"foo": "bar"},
750+
"valid": true
751+
},
752+
{
753+
"description": "a non-string is invalid",
754+
"data": {"foo": 12},
755+
"valid": false
756+
}
757+
]
758+
},
759+
{
760+
"description": "URN base URI with URN and anchor ref",
761+
"schema": {
762+
"$id": "urn:uuid:deadbeef-1234-0000-0000-4321feebdaed",
763+
"properties": {
764+
"foo": {"$ref": "urn:uuid:deadbeef-1234-0000-0000-4321feebdaed#something"}
765+
},
766+
"$defs": {
767+
"bar": {
768+
"$id": "something",
769+
"type": "string"
770+
}
771+
}
772+
},
773+
"tests": [
774+
{
775+
"description": "a string is valid",
776+
"data": {"foo": "bar"},
777+
"valid": true
778+
},
779+
{
780+
"description": "a non-string is invalid",
781+
"data": {"foo": 12},
782+
"valid": false
783+
}
784+
]
734785
}
735786
]

tests/draft7/ref.json

+51
Original file line numberDiff line numberDiff line change
@@ -767,5 +767,56 @@
767767
"valid": false
768768
}
769769
]
770+
},
771+
{
772+
"description": "URN base URI with URN and JSON pointer ref",
773+
"schema": {
774+
"$id": "urn:uuid:deadbeef-1234-0000-0000-4321feebdaed",
775+
"properties": {
776+
"foo": {"$ref": "urn:uuid:deadbeef-1234-0000-0000-4321feebdaed#/$defs/bar"}
777+
},
778+
"$defs": {
779+
"bar": {"type": "string"}
780+
}
781+
},
782+
"tests": [
783+
{
784+
"description": "a string is valid",
785+
"data": {"foo": "bar"},
786+
"valid": true
787+
},
788+
{
789+
"description": "a non-string is invalid",
790+
"data": {"foo": 12},
791+
"valid": false
792+
}
793+
]
794+
},
795+
{
796+
"description": "URN base URI with URN and anchor ref",
797+
"schema": {
798+
"$id": "urn:uuid:deadbeef-1234-0000-0000-4321feebdaed",
799+
"properties": {
800+
"foo": {"$ref": "urn:uuid:deadbeef-1234-0000-0000-4321feebdaed#something"}
801+
},
802+
"$defs": {
803+
"bar": {
804+
"$id": "#something",
805+
"type": "string"
806+
}
807+
}
808+
},
809+
"tests": [
810+
{
811+
"description": "a string is valid",
812+
"data": {"foo": "bar"},
813+
"valid": true
814+
},
815+
{
816+
"description": "a non-string is invalid",
817+
"data": {"foo": 12},
818+
"valid": false
819+
}
820+
]
770821
}
771822
]

0 commit comments

Comments
 (0)