fix lying swagger spec response type
This commit is contained in:
		@@ -30,33 +30,49 @@ var ParseFunctionsMap = map[string]interface{}{
 | 
			
		||||
 | 
			
		||||
type FunctionParamInfo struct {
 | 
			
		||||
	FunctionName string
 | 
			
		||||
	Params       []string
 | 
			
		||||
	Params       []FunctionParam
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type FunctionParam struct {
 | 
			
		||||
	Name string
 | 
			
		||||
	Type string
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const tmplFuncParams = `
 | 
			
		||||
// List of functions in eiaapi package
 | 
			
		||||
// with slice of arg types as strings
 | 
			
		||||
var FunctionParams = map[string][]string{
 | 
			
		||||
 | 
			
		||||
type FunctionParam struct {
 | 
			
		||||
	Name string
 | 
			
		||||
	Type string
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
var FunctionParams = map[string][]FunctionParam{
 | 
			
		||||
{{- range .}}
 | 
			
		||||
	"{{ .FunctionName }}": {
 | 
			
		||||
	  {{- range .Params }}
 | 
			
		||||
	  {{ . | printf "\"%s\"" }},
 | 
			
		||||
	  {
 | 
			
		||||
			Name: {{ .Name | printf "\"%s\"" }},
 | 
			
		||||
			Type: {{ .Type | printf "\"%s\"" }},
 | 
			
		||||
		},
 | 
			
		||||
	  {{- end }}
 | 
			
		||||
	},
 | 
			
		||||
{{- end}}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func GetFuncParamType(funcName string, idx int) string {
 | 
			
		||||
func GetFuncParamType(funcName string, idx int) *FunctionParam {
 | 
			
		||||
	var param FunctionParam
 | 
			
		||||
 | 
			
		||||
	funcParams, exists := FunctionParams[funcName]
 | 
			
		||||
	if !exists {
 | 
			
		||||
		return ""
 | 
			
		||||
		return nil
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if idx < len(funcParams) {
 | 
			
		||||
	  return funcParams[idx]
 | 
			
		||||
	  param = funcParams[idx]
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return ""
 | 
			
		||||
	return ¶m
 | 
			
		||||
}
 | 
			
		||||
`
 | 
			
		||||
 | 
			
		||||
@@ -88,7 +104,7 @@ func main() {
 | 
			
		||||
 | 
			
		||||
					// Load up params for all functions
 | 
			
		||||
					if funcDecl.Name.IsExported() {
 | 
			
		||||
						paramTypes := make([]string, 0)
 | 
			
		||||
						paramTypes := make([]FunctionParam, 0)
 | 
			
		||||
						if funcDecl.Type.Params != nil {
 | 
			
		||||
							for _, param := range funcDecl.Type.Params.List {
 | 
			
		||||
								// Convert the type expression to a string representation
 | 
			
		||||
@@ -98,8 +114,11 @@ func main() {
 | 
			
		||||
									continue
 | 
			
		||||
								}
 | 
			
		||||
								// Append the type once for each name in the parameter
 | 
			
		||||
								for range param.Names {
 | 
			
		||||
									paramTypes = append(paramTypes, typeStr)
 | 
			
		||||
								for _, name := range param.Names {
 | 
			
		||||
									paramTypes = append(paramTypes, FunctionParam{
 | 
			
		||||
										Name: name.Name,
 | 
			
		||||
										Type: typeStr,
 | 
			
		||||
									})
 | 
			
		||||
								}
 | 
			
		||||
							}
 | 
			
		||||
						}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user