Skip to content

Commit 8c0c19f

Browse files
k1LoWdaveshanley
authored andcommitted
Added test for panic when path is missing
1 parent f866c7b commit 8c0c19f

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

paths/paths_test.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,3 +634,28 @@ paths:
634634
assert.Equal(t, "two", pathItem.Post.OperationId)
635635

636636
}
637+
638+
func TestNewValidator_FindPathMissingWithBaseURLInServer(t *testing.T) {
639+
640+
spec := `openapi: 3.1.0
641+
servers:
642+
- url: 'https://things.com/'
643+
paths:
644+
/dishy:
645+
get:
646+
operationId: one
647+
`
648+
649+
doc, err := libopenapi.NewDocument([]byte(spec))
650+
if err != nil {
651+
t.Fatal(err)
652+
}
653+
m, _ := doc.BuildV3Model()
654+
655+
request, _ := http.NewRequest(http.MethodGet, "https://things.com/not_here", nil)
656+
657+
_, errs, _ := FindPath(request, &m.Model)
658+
assert.Len(t, errs, 1)
659+
assert.Equal(t, "GET Path '/not_here' not found", errs[0].Message)
660+
661+
}

0 commit comments

Comments
 (0)