optimize: fix experimental api (#3604)

This commit is contained in:
kesonan
2023-10-07 19:48:41 +08:00
committed by GitHub
parent 1ff541afe4
commit 02c95108b9
4 changed files with 49 additions and 15 deletions

View File

@@ -2,6 +2,7 @@ package parser
import (
"fmt"
"sort"
"strings"
"github.com/zeromicro/go-zero/tools/goctl/api/spec"
@@ -101,7 +102,25 @@ func (a *Analyzer) convert2Spec() error {
return err
}
return a.fillService()
if err := a.fillService(); err != nil {
return err
}
sort.SliceStable(a.spec.Types, func(i, j int) bool {
return a.spec.Types[i].Name() < a.spec.Types[j].Name()
})
groups := make([]spec.Group, 0, len(a.spec.Service.Groups))
for _, v := range a.spec.Service.Groups {
sort.SliceStable(v.Routes, func(i, j int) bool {
return v.Routes[i].Path < v.Routes[j].Path
})
groups = append(groups, v)
}
sort.SliceStable(groups, func(i, j int) bool {
return groups[i].Annotation.Properties["group"] < groups[j].Annotation.Properties["group"]
})
a.spec.Service.Groups = groups
return nil
}
func (a *Analyzer) convertAtDoc(atDoc ast.AtDocStmt) spec.AtDoc {