mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-09 20:47:44 +00:00
fix: add paths/parent nodes to schemas as well
This commit is contained in:
committed by
Dave Shanley
parent
53789cbc1b
commit
c75a1bfaf4
@@ -722,6 +722,27 @@ paths:
|
||||
}
|
||||
}
|
||||
|
||||
func TestSpecIndex_schemaComponentsHaveParentsAndPaths(t *testing.T) {
|
||||
yml := `components:
|
||||
schemas:
|
||||
Pet:
|
||||
type: object
|
||||
Dog:
|
||||
type: object`
|
||||
|
||||
var rootNode yaml.Node
|
||||
yaml.Unmarshal([]byte(yml), &rootNode)
|
||||
|
||||
index := NewSpecIndex(&rootNode)
|
||||
|
||||
schemas := index.GetAllSchemas()
|
||||
|
||||
for _, schema := range schemas {
|
||||
assert.NotNil(t, schema.ParentNode)
|
||||
assert.Equal(t, fmt.Sprintf("$.components.schemas.%s", schema.Name), schema.Path)
|
||||
}
|
||||
}
|
||||
|
||||
// Example of how to load in an OpenAPI Specification and index it.
|
||||
func ExampleNewSpecIndex() {
|
||||
// define a rootNode to hold our raw spec AST.
|
||||
|
||||
Reference in New Issue
Block a user