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 @@ -680,3 +680,53 @@ paths:
680
680
// assert.Len(t, errors, 0)
681
681
//
682
682
//}
683
+
684
+ // https://github.com/pb33f/libopenapi/issues/415
685
+ func TestValidateSchema_v3_1_DependentSchemas (t * testing.T ) {
686
+ spec := `openapi: 3.1.0
687
+ paths:
688
+ /burgers/createBurger:
689
+ post:
690
+ requestBody:
691
+ content:
692
+ application/json:
693
+ schema:
694
+ type: object
695
+ properties:
696
+ fishCake:
697
+ type: object
698
+ properties:
699
+ bones:
700
+ type: boolean
701
+ dependentSchemas:
702
+ fishCake:
703
+ type: object
704
+ properties:
705
+ cream:
706
+ type: number
707
+ format: double
708
+ required:
709
+ - cream`
710
+
711
+ doc , _ := libopenapi .NewDocument ([]byte (spec ))
712
+
713
+ m , _ := doc .BuildV3Model ()
714
+
715
+ exp := `{
716
+ "fishCake": {
717
+ "bones": true,
718
+ "cream": 2.5
719
+ }
720
+ }`
721
+
722
+ sch := m .Model .Paths .PathItems .GetOrZero ("/burgers/createBurger" ).Post .RequestBody .Content .GetOrZero ("application/json" ).Schema
723
+
724
+ // create a schema validator
725
+ v := NewSchemaValidator ()
726
+
727
+ // validate!
728
+ valid , errors := v .ValidateSchemaString (sch .Schema (), exp )
729
+
730
+ assert .True (t , valid )
731
+ assert .Empty (t , errors )
732
+ }
You can’t perform that action at this time.
0 commit comments