-
Notifications
You must be signed in to change notification settings - Fork 66
/
header.go
47 lines (40 loc) · 1.23 KB
/
header.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
39
40
41
42
43
44
45
46
47
package casesHelper
import (
"github.com/aaronchen2k/deeptest/internal/pkg/consts"
_stringUtils "github.com/aaronchen2k/deeptest/pkg/lib/string"
"github.com/getkin/kin-openapi/openapi3"
"github.com/kataras/iris/v12"
"path"
)
func LoadForHeaders(params openapi3.Parameters) (category *AlternativeCase) {
category = &AlternativeCase{
Title: Category["header"],
Path: AddFix(consts.ParamInHeader.String()),
Category: consts.AlternativeCaseCategory,
IsDir: true,
Key: _stringUtils.Uuid(),
Slots: iris.Map{"icon": "icon"},
}
for _, param := range params {
if param.Value.In != consts.ParamInHeader.String() {
continue
}
paramCase := &AlternativeCase{
Title: param.Value.Name,
Path: path.Join(category.Path, param.Value.Name),
Category: consts.AlternativeCaseParam,
IsDir: true,
Key: _stringUtils.Uuid(),
Slots: iris.Map{"icon": "icon"},
}
addParamRequiredCase(param.Value, paramCase)
addParamTypeCase(param.Value, paramCase)
addParamEnumCase(param.Value, paramCase)
addParamFormatCase(param.Value, paramCase)
addParamRuleCase(param.Value, paramCase)
if len(paramCase.Children) > 0 {
category.Children = append(category.Children, paramCase)
}
}
return
}