Exemple #1
0
// Imports returns array of modules that need to be imported by server's main file
func (s *Server) Imports() []string {
	imports := map[string]struct{}{}

	for _, r := range s.Resources {
		imports[r.apiName()] = struct{}{}
	}
	return commons.MapToSortedStrings(imports)
}
Exemple #2
0
// get array of all imported modules
func (r *resource) Imports() []string {
	ip := map[string]struct{}{}

	for _, mi := range r.Methods {
		m := mi.(method)
		if m.ReqBody != "" && objectRegistered(m.ReqBody) {
			ip[m.ReqBody] = struct{}{}
		}
		if m.RespBody != "" && objectRegistered(m.RespBody) {
			ip[m.RespBody] = struct{}{}
		}
	}
	return commons.MapToSortedStrings(ip)
}
Exemple #3
0
func (s *Struct) goAnnotations() []string {
	pkg := []string{fmt.Sprintf(`$Go.package("%v")`, s.pkg)}
	annosMap := map[string]struct{}{}
	// import enums
	for _, f := range s.Fields {
		if f.Enum != nil {
			annosMap[fmt.Sprintf(`$Go.import("%v")`, f.Enum.pkg)] = struct{}{}
		}
	}
	// import our own package
	annosMap[fmt.Sprintf(`$Go.import("%v")`, s.pkg)] = struct{}{}
	annos := commons.MapToSortedStrings(annosMap)
	return append(pkg, annos...)
}
Exemple #4
0
// get array of all imported modules
func (o object) Imports() []string {
	ip := map[string]struct{}{}

	for _, f := range o.Fields {
		if objectRegistered(f.Type) {
			ip[f.Type] = struct{}{}
		}
		if f.Type == "Time" {
			ip["times"] = struct{}{}
		}
	}

	for _, p := range o.Parents {
		if objectRegistered(p) {
			ip[p] = struct{}{}
		}
	}
	return commons.MapToSortedStrings(ip)
}