Improving

This commit is contained in:
2021-11-28 19:08:32 -03:00
parent 984592b7fd
commit 3cc08c6bb9
6 changed files with 101 additions and 16 deletions
+5
View File
@@ -34,6 +34,9 @@ func addStruct(a *ast.GenDecl) {
llog("Adding type: %s => %#v", tp.Name, md)
for _, v := range a.Specs[0].(*ast.TypeSpec).Type.(*ast.StructType).Fields.List {
if len(v.Names) < 1 {
panic("Does not support Composition: " + tp.Name)
}
tp.Fields[v.Names[0].Name] = &APIField{}
tp.Fields[v.Names[0].Name].Tags = make(map[string]APIFieldTag)
@@ -203,6 +206,7 @@ func addFunction(a *ast.FuncDecl) error {
return nil
}
// load is responsible for loading the package for AST Parsing
func load(src string) error {
api.Types = (make(map[string]*APIType))
@@ -221,6 +225,7 @@ func load(src string) error {
return err
}
//iterate over packages
for _, v := range f {
llog("Loading Package: %s", v.Name)
+3 -2
View File
@@ -9,7 +9,7 @@ type API struct {
Imports map[string]string `yaml:"imports"`
UsedImportsTypes map[string]string `yaml:"used_imports_types"`
UsedImportsFunctions map[string]string `yaml:"used_imports_functions"`
SortedPaths []*APIPath `yaml:"sorted_paths"`
SortedPaths []*APIPath `yaml:"-"`
Paths map[string]*APIPath `yaml:"paths"`
}
@@ -65,8 +65,9 @@ type APIMethod struct {
Desc string `yaml:"desc"`
Verb string `yaml:"verb"`
Path string `yaml:"path"`
Perm string `yaml:perm`
Perm string `yaml:"perm"`
Raw bool `yaml:"raw"`
OpID string `yaml:"op_id"`
ReqType *APIParamType
ResType *APIParamType
}