-
Notifications
You must be signed in to change notification settings - Fork 66
/
api.go
38 lines (34 loc) · 1019 Bytes
/
api.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package casesHelper
import (
"github.com/aaronchen2k/deeptest/internal/pkg/consts"
"github.com/getkin/kin-openapi/openapi3"
)
func GetApiPathItem(doc3 *openapi3.T) (pathItem *openapi3.PathItem, err error) {
for key, _ := range doc3.Paths {
pathItem = doc3.Paths[key] // get one
return
}
return
}
func GetApiOperation(method consts.HttpMethod, pathItem *openapi3.PathItem) (operation *openapi3.Operation, err error) {
if method == consts.GET {
operation = pathItem.Get
} else if method == consts.POST {
operation = pathItem.Post
} else if method == consts.PUT {
operation = pathItem.Put
} else if method == consts.DELETE {
operation = pathItem.Delete
} else if method == consts.PATCH {
operation = pathItem.Patch
} else if method == consts.HEAD {
operation = pathItem.Head
} else if method == consts.CONNECT {
operation = pathItem.Connect
} else if method == consts.OPTIONS {
operation = pathItem.Options
} else if method == consts.TRACE {
operation = pathItem.Trace
}
return
}