File tree Expand file tree Collapse file tree 1 file changed +50
-0
lines changed Expand file tree Collapse file tree 1 file changed +50
-0
lines changed Original file line number Diff line number Diff line change @@ -730,3 +730,53 @@ paths:
730730	assert .True (t , valid )
731731	assert .Empty (t , errors )
732732}
733+ 
734+ // https://github.com/pb33f/libopenapi/issues/415 
735+ func  TestValidateSchema_v3_1_DependentSchemas_NotValid (t  * testing.T ) {
736+ 	spec  :=  `openapi: 3.1.0 
737+ paths: 
738+   /burgers/createBurger: 
739+     post: 
740+       requestBody: 
741+         content: 
742+           application/json: 
743+             schema: 
744+               type: object 
745+               properties: 
746+                 fishCake: 
747+                   type: object 
748+                   properties: 
749+                     bones: 
750+                       type: boolean 
751+                   dependentSchemas: 
752+                     fishCake: 
753+                       type: object 
754+                       properties: 
755+                         cream: 
756+                           type: number 
757+                           format: double 
758+                       required: 
759+                         - cream` 
760+ 
761+ 	doc , _  :=  libopenapi .NewDocument ([]byte (spec ))
762+ 
763+ 	m , _  :=  doc .BuildV3Model ()
764+ 
765+ 	exp  :=  `{ 
766+   "fishCake": { 
767+     "bones": true, 
768+   } 
769+   "cream": 2.5 
770+ }` 
771+ 
772+ 	sch  :=  m .Model .Paths .PathItems .GetOrZero ("/burgers/createBurger" ).Post .RequestBody .Content .GetOrZero ("application/json" ).Schema 
773+ 
774+ 	// create a schema validator 
775+ 	v  :=  NewSchemaValidator ()
776+ 
777+ 	// validate! 
778+ 	valid , errors  :=  v .ValidateSchemaString (sch .Schema (), exp )
779+ 
780+ 	assert .False (t , valid )
781+ 	assert .NotEmpty (t , errors )
782+ }
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments