File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -743,6 +743,44 @@ func TestSpecIndex_schemaComponentsHaveParentsAndPaths(t *testing.T) {
743743 }
744744}
745745
746+ func TestSpecIndex_foundObjectsWithProperties (t * testing.T ) {
747+ yml := `paths:
748+ /test:
749+ get:
750+ responses:
751+ '200':
752+ description: OK
753+ content:
754+ application/json:
755+ type: object
756+ properties:
757+ test:
758+ type: string
759+ components:
760+ schemas:
761+ test:
762+ type: object
763+ properties:
764+ test:
765+ type: string
766+ test2:
767+ type: [object, null]
768+ properties:
769+ test:
770+ type: string
771+ test3:
772+ type: object
773+ additionalProperties: true`
774+
775+ var rootNode yaml.Node
776+ yaml .Unmarshal ([]byte (yml ), & rootNode )
777+
778+ index := NewSpecIndex (& rootNode )
779+
780+ objects := index .GetAllObjectsWithProperties ()
781+ assert .Len (t , objects , 3 )
782+ }
783+
746784// Example of how to load in an OpenAPI Specification and index it.
747785func ExampleNewSpecIndex () {
748786 // define a rootNode to hold our raw spec AST.
You can’t perform that action at this time.
0 commit comments