Skip to content

Commit

Permalink
fix: add test
Browse files Browse the repository at this point in the history
  • Loading branch information
TristanSpeakEasy authored and daveshanley committed Dec 20, 2022
1 parent 36f5999 commit 8581c7f
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions index/spec_index_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,44 @@ func TestSpecIndex_schemaComponentsHaveParentsAndPaths(t *testing.T) {
}
}

func TestSpecIndex_foundObjectsWithProperties(t *testing.T) {
yml := `paths:
/test:
get:
responses:
'200':
description: OK
content:
application/json:
type: object
properties:
test:
type: string
components:
schemas:
test:
type: object
properties:
test:
type: string
test2:
type: [object, null]
properties:
test:
type: string
test3:
type: object
additionalProperties: true`

var rootNode yaml.Node
yaml.Unmarshal([]byte(yml), &rootNode)

index := NewSpecIndex(&rootNode)

objects := index.GetAllObjectsWithProperties()
assert.Len(t, objects, 3)
}

// Example of how to load in an OpenAPI Specification and index it.
func ExampleNewSpecIndex() {
// define a rootNode to hold our raw spec AST.
Expand Down

0 comments on commit 8581c7f

Please sign in to comment.