Skip to content

Commit 615a66e

Browse files
committed
feat: spectrum: add SpecMeta{}
1 parent 272bb7d commit 615a66e

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

spec_meta.go

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package spectrum
2+
3+
type SpecMeta struct {
4+
Counts SpecMetaCounts
5+
Names SpecMetaNames
6+
}
7+
8+
func NewSpecMeta() *SpecMeta {
9+
return &SpecMeta{
10+
Counts: SpecMetaCounts{},
11+
Names: SpecMetaNames{}}
12+
}
13+
14+
func (m *SpecMeta) Inflate() {
15+
m.Counts = m.Names.Counts()
16+
}
17+
18+
type SpecMetaCounts struct {
19+
Endpoints int
20+
Paths int
21+
Models int
22+
}
23+
24+
type SpecMetaNames struct {
25+
Endpoints []string
26+
Models []string
27+
Paths []string
28+
}
29+
30+
func (n SpecMetaNames) Counts() SpecMetaCounts {
31+
return SpecMetaCounts{
32+
Endpoints: len(n.Endpoints),
33+
Models: len(n.Models),
34+
Paths: len(n.Paths),
35+
}
36+
}
37+
38+
type SpecMetaSet struct {
39+
Data map[string]SpecMeta
40+
}
41+
42+
func NewSpecMetaSet() *SpecMetaSet {
43+
return &SpecMetaSet{Data: map[string]SpecMeta{}}
44+
}

0 commit comments

Comments
 (0)