@@ -155,6 +155,59 @@ describe(JsonSchema.name, () => {
155155 expect ( ( ) => schemaWithVendorExtensions . validateObject ( { name : 'hello' } , '' ) ) . toThrow ( ) ;
156156 } ) ;
157157
158+ test ( 'rejects vendor extension keywords that are not at the schema root level' , ( ) => {
159+ const schemaWithNestedVendorExtension : JsonSchema = JsonSchema . fromLoadedObject (
160+ {
161+ title : 'Test nested vendor extension' ,
162+ type : 'object' ,
163+ properties : {
164+ name : {
165+ type : 'string' ,
166+ 'x-myvendor-display-name' : 'Name field'
167+ }
168+ } ,
169+ additionalProperties : false ,
170+ required : [ 'name' ]
171+ } ,
172+ { schemaVersion : 'draft-07' }
173+ ) ;
174+ expect ( ( ) => schemaWithNestedVendorExtension . validateObject ( { name : 'hello' } , '' ) ) . toThrow ( ) ;
175+ } ) ;
176+
177+ test ( 'rejects malformed vendor extension keywords that do not match x-<vendor>-<keyword>' , ( ) => {
178+ // Missing vendor segment: "x-tag" has no second hyphen-separated part
179+ const schemaWithMalformedTag : JsonSchema = JsonSchema . fromLoadedObject (
180+ {
181+ title : 'Test malformed vendor extension' ,
182+ 'x-tag' : '@beta' ,
183+ type : 'object' ,
184+ properties : {
185+ name : { type : 'string' }
186+ } ,
187+ additionalProperties : false ,
188+ required : [ 'name' ]
189+ } ,
190+ { schemaVersion : 'draft-07' }
191+ ) ;
192+ expect ( ( ) => schemaWithMalformedTag . validateObject ( { name : 'hello' } , '' ) ) . toThrow ( ) ;
193+
194+ // Uppercase characters in vendor segment
195+ const schemaWithUppercaseTag : JsonSchema = JsonSchema . fromLoadedObject (
196+ {
197+ title : 'Test uppercase vendor extension' ,
198+ 'x-MyVendor-tag' : 'value' ,
199+ type : 'object' ,
200+ properties : {
201+ name : { type : 'string' }
202+ } ,
203+ additionalProperties : false ,
204+ required : [ 'name' ]
205+ } ,
206+ { schemaVersion : 'draft-07' }
207+ ) ;
208+ expect ( ( ) => schemaWithUppercaseTag . validateObject ( { name : 'hello' } , '' ) ) . toThrow ( ) ;
209+ } ) ;
210+
158211 test ( 'successfully applies custom formats' , ( ) => {
159212 const schemaWithCustomFormat = JsonSchema . fromLoadedObject (
160213 {
0 commit comments