File tree Expand file tree Collapse file tree 1 file changed +73
-0
lines changed Expand file tree Collapse file tree 1 file changed +73
-0
lines changed Original file line number Diff line number Diff line change @@ -2005,3 +2005,76 @@ test('object property reference with default value', (t) => {
2005
2005
2006
2006
t . equal ( output , '{"prop":"foo"}' )
2007
2007
} )
2008
+
2009
+ test ( 'should throw an Error if two non-identical schemas with same id are provided' , ( t ) => {
2010
+ t . plan ( 1 )
2011
+
2012
+ const schema = {
2013
+ $id : 'schema' ,
2014
+ type : 'object' ,
2015
+ allOf : [
2016
+ {
2017
+ $id : 'base' ,
2018
+ type : 'object' ,
2019
+ properties : {
2020
+ name : {
2021
+ type : 'string'
2022
+ }
2023
+ } ,
2024
+ required : [
2025
+ 'name'
2026
+ ]
2027
+ } ,
2028
+ {
2029
+ $id : 'inner_schema' ,
2030
+ type : 'object' ,
2031
+ properties : {
2032
+ union : {
2033
+ $id : '#id' ,
2034
+ anyOf : [
2035
+ {
2036
+
2037
+ $id : 'guid' ,
2038
+ type : 'string'
2039
+ } ,
2040
+ {
2041
+
2042
+ $id : 'email' ,
2043
+ type : 'string'
2044
+ }
2045
+ ]
2046
+ }
2047
+ } ,
2048
+ required : [
2049
+ 'union'
2050
+ ]
2051
+ } ,
2052
+ {
2053
+ $id : 'inner_schema' ,
2054
+ type : 'object' ,
2055
+ properties : {
2056
+ union : {
2057
+ $id : '#id' ,
2058
+ anyOf : [
2059
+ {
2060
+
2061
+ $id : 'guid' ,
2062
+ type : 'string'
2063
+ } ,
2064
+ {
2065
+
2066
+ $id : 'mail' ,
2067
+ type : 'string'
2068
+ }
2069
+ ]
2070
+ }
2071
+ } ,
2072
+ required : [
2073
+ 'union'
2074
+ ]
2075
+ }
2076
+ ]
2077
+ }
2078
+
2079
+ t . throws ( ( ) => build ( schema ) , new Error ( 'There is already another schema with id inner_schema' ) )
2080
+ } )
You can’t perform that action at this time.
0 commit comments