Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions index/rolodex_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
package index

import (
"github.com/stretchr/testify/assert"
"gopkg.in/yaml.v3"
"io"
"io/fs"
"log/slog"
Expand All @@ -19,6 +17,9 @@ import (
"testing"
"testing/fstest"
"time"

"github.com/stretchr/testify/assert"
"gopkg.in/yaml.v3"
)

func TestRolodex_NewRolodex(t *testing.T) {
Expand Down Expand Up @@ -1540,15 +1541,16 @@ func TestRolodex_SimpleTest_OneDoc(t *testing.T) {

//assert.NotZero(t, rolo.GetIndexingDuration()) comes back as 0 on windows.
assert.NotNil(t, rolo.GetRootIndex())
assert.Len(t, rolo.GetIndexes(), 10)
assert.Len(t, rolo.GetAllReferences(), 8)
assert.Len(t, rolo.GetAllMappedReferences(), 8)
assert.Len(t, rolo.GetIndexes(), 11)
assert.Len(t, rolo.GetAllReferences(), 9)
assert.Len(t, rolo.GetAllMappedReferences(), 9)
assert.Len(t, rolo.GetRootIndex().GetAllPaths(), 3)

lineCount := rolo.GetFullLineCount()
assert.Equal(t, int64(167), lineCount, "total line count in the rolodex is wrong")
assert.Equal(t, int64(174), lineCount, "total line count in the rolodex is wrong")

assert.NoError(t, err)
assert.Len(t, rolo.indexes, 10)
assert.Len(t, rolo.indexes, 11)

// open components.yaml
f, rerr := rolo.Open("components.yaml")
Expand Down
2 changes: 2 additions & 0 deletions index/rolodex_test_data/doc1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ paths:
application/json:
schema:
$ref: 'components.yaml#/components/schemas/Ding'
/external_operation:
$ref: 'operations.yaml#/external_operation'
components:
schemas:
Thing:
Expand Down
5 changes: 5 additions & 0 deletions index/rolodex_test_data/operations.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
external_operation:
get:
responses:
200:
description: "OK"
8 changes: 8 additions & 0 deletions index/spec_index.go
Original file line number Diff line number Diff line change
Expand Up @@ -1002,6 +1002,14 @@ func (index *SpecIndex) GetOperationCount() int {
method = index.pathsNode.Content[x+1]
}

// is the path a ref?
if isRef, _, ref := utils.IsNodeRefValue(method); isRef {
pNode := seekRefEnd(index, ref)
if pNode != nil {
method = pNode.Node
}
}

// extract methods for later use.
for y, m := range method.Content {
if y%2 == 0 {
Expand Down