Skip to content

Commit 8581c7f

Browse files
TristanSpeakEasydaveshanley
authored andcommitted
fix: add test
1 parent 36f5999 commit 8581c7f

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

index/spec_index_test.go

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff 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.
747785
func ExampleNewSpecIndex() {
748786
// define a rootNode to hold our raw spec AST.

0 commit comments

Comments
 (0)