gen/writers/helpers.go
func paramsInitializer(action *gen.Action, location int, varName string) string {
	var fields []string
	var optionals []*gen.ActionParam
	varName = fixReserved(varName)
	for _, param := range action.Params {
		if param.Location != location {
			continue
		}
		if param.Mandatory {
			name := param.Name
			if location == 1 { // QueryParam
				name = param.QueryName
			}
			fields = append(fields, fmt.Sprintf("\"%s\": %s,", name, fixReserved(param.VarName)))
		} else {
			optionals = append(optionals, param)
		}
	}
	if len(fields) == 0 && len(optionals) == 0 {
		return ""
	}
	var paramsDecl = fmt.Sprintf("rsapi.APIParams{\n%s\n}", strings.Join(fields, "\n\t"))
	if len(optionals) == 0 {
		return fmt.Sprintf("\n%s = %s", varName, paramsDecl)
	}
	var inits = make([]string, len(optionals))
	for i, opt := range optionals {
		name := opt.Name
		if location == 1 { // QueryParam
			name = opt.QueryName
		}
		inits[i] = fmt.Sprintf("\tvar %sOpt = options[\"%s\"]\n\tif %sOpt != nil {\n\t\t%s[\"%s\"] = %sOpt\n\t}",
			opt.VarName, opt.Name, opt.VarName, varName, name, opt.VarName)
	}
	var paramsInits = strings.Join(inits, "\n\t")
	return fmt.Sprintf("\n%s = %s\n%s", varName, paramsDecl, paramsInits)
}
func paramsInitializer(action *gen.Action, location int, varName string) string {
	var fields []string
	var optionals []*gen.ActionParam
	varName = fixReserved(varName)
	for _, param := range action.Params {
		if param.Location != location {
			continue
		}
		if param.Mandatory {
			name := param.Name
			if location == 1 { // QueryParam
				name = param.QueryName
			}
			fields = append(fields, fmt.Sprintf("\"%s\": %s,", name, fixReserved(param.VarName)))
		} else {
			optionals = append(optionals, param)
		}
	}
	if len(fields) == 0 && len(optionals) == 0 {
		return ""
	}
	var paramsDecl = fmt.Sprintf("rsapi.APIParams{\n%s\n}", strings.Join(fields, "\n\t"))
	if len(optionals) == 0 {
		return fmt.Sprintf("\n%s = %s", varName, paramsDecl)
	}
	var inits = make([]string, len(optionals))
	for i, opt := range optionals {
		name := opt.Name
		if location == 1 { // QueryParam
			name = opt.QueryName
		}
		inits[i] = fmt.Sprintf("\tvar %sOpt = options[\"%s\"]\n\tif %sOpt != nil {\n\t\t%s[\"%s\"] = %sOpt\n\t}",
			opt.VarName, opt.Name, opt.VarName, varName, name, opt.VarName)
	}
	var paramsInits = strings.Join(inits, "\n\t")
	return fmt.Sprintf("\n%s = %s\n%s", varName, paramsDecl, paramsInits)
}
// Produces code that initializes a APIParams struct with the values of parameters for the given
// action and location.