Skip to content

Commit ecc4643

Browse files
committed
Squashed 'json/' changes from fd9bcfbdb..685ac631d
685ac631d Merge pull request #578 from json-schema-org/urn 5347f29e4 Deduplicate URIs in the URN tests. 87cf32575 Also add tests for refs with URN+pointer and URN+fragment. 96255eff5 Add some simple tests for URN base URIs. git-subtree-dir: json git-subtree-split: 685ac631d3135dd5582710bf582b8db8ba5ba877
1 parent 999ff68 commit ecc4643

File tree

5 files changed

+912
-0
lines changed

5 files changed

+912
-0
lines changed

tests/draft-next/ref.json

+188
Original file line numberDiff line numberDiff line change
@@ -642,5 +642,193 @@
642642
"valid": false
643643
}
644644
]
645+
},
646+
{
647+
"description": "simple URN base URI with $ref via the URN",
648+
"schema": {
649+
"$comment": "URIs do not have to have HTTP(s) schemes",
650+
"$id": "urn:uuid:deadbeef-1234-ffff-ffff-4321feebdaed",
651+
"minimum": 30,
652+
"properties": {
653+
"foo": {"$ref": "urn:uuid:deadbeef-1234-ffff-ffff-4321feebdaed"}
654+
}
655+
},
656+
"tests": [
657+
{
658+
"description": "valid under the URN IDed schema",
659+
"data": {"foo": 37},
660+
"valid": true
661+
},
662+
{
663+
"description": "invalid under the URN IDed schema",
664+
"data": {"foo": 12},
665+
"valid": false
666+
}
667+
]
668+
},
669+
{
670+
"description": "simple URN base URI with JSON pointer",
671+
"schema": {
672+
"$comment": "URIs do not have to have HTTP(s) schemes",
673+
"$id": "urn:uuid:deadbeef-1234-ffff-ffff-4321feebdaed",
674+
"properties": {
675+
"foo": {"$ref": "#/$defs/bar"}
676+
},
677+
"$defs": {
678+
"bar": {"type": "string"}
679+
}
680+
},
681+
"tests": [
682+
{
683+
"description": "a string is valid",
684+
"data": {"foo": "bar"},
685+
"valid": true
686+
},
687+
{
688+
"description": "a non-string is invalid",
689+
"data": {"foo": 12},
690+
"valid": false
691+
}
692+
]
693+
},
694+
{
695+
"description": "URN base URI with NSS",
696+
"schema": {
697+
"$comment": "RFC 8141 §2.2",
698+
"$id": "urn:example:1/406/47452/2",
699+
"properties": {
700+
"foo": {"$ref": "#/$defs/bar"}
701+
},
702+
"$defs": {
703+
"bar": {"type": "string"}
704+
}
705+
},
706+
"tests": [
707+
{
708+
"description": "a string is valid",
709+
"data": {"foo": "bar"},
710+
"valid": true
711+
},
712+
{
713+
"description": "a non-string is invalid",
714+
"data": {"foo": 12},
715+
"valid": false
716+
}
717+
]
718+
},
719+
{
720+
"description": "URN base URI with r-component",
721+
"schema": {
722+
"$comment": "RFC 8141 §2.3.1",
723+
"$id": "urn:example:foo-bar-baz-qux?+CCResolve:cc=uk",
724+
"properties": {
725+
"foo": {"$ref": "#/$defs/bar"}
726+
},
727+
"$defs": {
728+
"bar": {"type": "string"}
729+
}
730+
},
731+
"tests": [
732+
{
733+
"description": "a string is valid",
734+
"data": {"foo": "bar"},
735+
"valid": true
736+
},
737+
{
738+
"description": "a non-string is invalid",
739+
"data": {"foo": 12},
740+
"valid": false
741+
}
742+
]
743+
},
744+
{
745+
"description": "URN base URI with q-component",
746+
"schema": {
747+
"$comment": "RFC 8141 §2.3.2",
748+
"$id": "urn:example:weather?=op=map&lat=39.56&lon=-104.85&datetime=1969-07-21T02:56:15Z",
749+
"properties": {
750+
"foo": {"$ref": "#/$defs/bar"}
751+
},
752+
"$defs": {
753+
"bar": {"type": "string"}
754+
}
755+
},
756+
"tests": [
757+
{
758+
"description": "a string is valid",
759+
"data": {"foo": "bar"},
760+
"valid": true
761+
},
762+
{
763+
"description": "a non-string is invalid",
764+
"data": {"foo": 12},
765+
"valid": false
766+
}
767+
]
768+
},
769+
{
770+
"description": "URN base URI with f-component",
771+
"schema": {
772+
"$comment": "RFC 8141 §2.3.3, but we don't allow fragments",
773+
"$ref": "https://json-schema.org/draft/next/schema"
774+
},
775+
"tests": [
776+
{
777+
"description": "is invalid",
778+
"data": {"$id": "urn:example:foo-bar-baz-qux#somepart"},
779+
"valid": false
780+
}
781+
]
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+
]
645833
}
646834
]

tests/draft2019-09/ref.json

+188
Original file line numberDiff line numberDiff line change
@@ -642,5 +642,193 @@
642642
"valid": false
643643
}
644644
]
645+
},
646+
{
647+
"description": "simple URN base URI with $ref via the URN",
648+
"schema": {
649+
"$comment": "URIs do not have to have HTTP(s) schemes",
650+
"$id": "urn:uuid:deadbeef-1234-ffff-ffff-4321feebdaed",
651+
"minimum": 30,
652+
"properties": {
653+
"foo": {"$ref": "urn:uuid:deadbeef-1234-ffff-ffff-4321feebdaed"}
654+
}
655+
},
656+
"tests": [
657+
{
658+
"description": "valid under the URN IDed schema",
659+
"data": {"foo": 37},
660+
"valid": true
661+
},
662+
{
663+
"description": "invalid under the URN IDed schema",
664+
"data": {"foo": 12},
665+
"valid": false
666+
}
667+
]
668+
},
669+
{
670+
"description": "simple URN base URI with JSON pointer",
671+
"schema": {
672+
"$comment": "URIs do not have to have HTTP(s) schemes",
673+
"$id": "urn:uuid:deadbeef-1234-00ff-ff00-4321feebdaed",
674+
"properties": {
675+
"foo": {"$ref": "#/$defs/bar"}
676+
},
677+
"$defs": {
678+
"bar": {"type": "string"}
679+
}
680+
},
681+
"tests": [
682+
{
683+
"description": "a string is valid",
684+
"data": {"foo": "bar"},
685+
"valid": true
686+
},
687+
{
688+
"description": "a non-string is invalid",
689+
"data": {"foo": 12},
690+
"valid": false
691+
}
692+
]
693+
},
694+
{
695+
"description": "URN base URI with NSS",
696+
"schema": {
697+
"$comment": "RFC 8141 §2.2",
698+
"$id": "urn:example:1/406/47452/2",
699+
"properties": {
700+
"foo": {"$ref": "#/$defs/bar"}
701+
},
702+
"$defs": {
703+
"bar": {"type": "string"}
704+
}
705+
},
706+
"tests": [
707+
{
708+
"description": "a string is valid",
709+
"data": {"foo": "bar"},
710+
"valid": true
711+
},
712+
{
713+
"description": "a non-string is invalid",
714+
"data": {"foo": 12},
715+
"valid": false
716+
}
717+
]
718+
},
719+
{
720+
"description": "URN base URI with r-component",
721+
"schema": {
722+
"$comment": "RFC 8141 §2.3.1",
723+
"$id": "urn:example:foo-bar-baz-qux?+CCResolve:cc=uk",
724+
"properties": {
725+
"foo": {"$ref": "#/$defs/bar"}
726+
},
727+
"$defs": {
728+
"bar": {"type": "string"}
729+
}
730+
},
731+
"tests": [
732+
{
733+
"description": "a string is valid",
734+
"data": {"foo": "bar"},
735+
"valid": true
736+
},
737+
{
738+
"description": "a non-string is invalid",
739+
"data": {"foo": 12},
740+
"valid": false
741+
}
742+
]
743+
},
744+
{
745+
"description": "URN base URI with q-component",
746+
"schema": {
747+
"$comment": "RFC 8141 §2.3.2",
748+
"$id": "urn:example:weather?=op=map&lat=39.56&lon=-104.85&datetime=1969-07-21T02:56:15Z",
749+
"properties": {
750+
"foo": {"$ref": "#/$defs/bar"}
751+
},
752+
"$defs": {
753+
"bar": {"type": "string"}
754+
}
755+
},
756+
"tests": [
757+
{
758+
"description": "a string is valid",
759+
"data": {"foo": "bar"},
760+
"valid": true
761+
},
762+
{
763+
"description": "a non-string is invalid",
764+
"data": {"foo": 12},
765+
"valid": false
766+
}
767+
]
768+
},
769+
{
770+
"description": "URN base URI with f-component",
771+
"schema": {
772+
"$comment": "RFC 8141 §2.3.3, but we don't allow fragments",
773+
"$ref": "https://json-schema.org/draft/2019-09/schema"
774+
},
775+
"tests": [
776+
{
777+
"description": "is invalid",
778+
"data": {"$id": "urn:example:foo-bar-baz-qux#somepart"},
779+
"valid": false
780+
}
781+
]
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-ff00-00ff-4321feebdaed",
811+
"properties": {
812+
"foo": {"$ref": "urn:uuid:deadbeef-1234-ff00-00ff-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+
]
645833
}
646834
]

0 commit comments

Comments
 (0)