chore: bump Go dependencies

This commit is contained in:
lzap 2025-08-03 15:24:15 +00:00 committed by Simon de Vlieger
parent b3d1e4cf13
commit e118df5dfd
1119 changed files with 126580 additions and 8706 deletions

View file

@ -83,12 +83,12 @@ func BindStyledParameterWithOptions(style string, paramName string, value string
// since prior to this refactoring, they always query unescaped.
value, err = url.QueryUnescape(value)
if err != nil {
return fmt.Errorf("error unescaping query parameter '%s': %v", paramName, err)
return fmt.Errorf("error unescaping query parameter '%s': %w", paramName, err)
}
case ParamLocationPath:
value, err = url.PathUnescape(value)
if err != nil {
return fmt.Errorf("error unescaping path parameter '%s': %v", paramName, err)
return fmt.Errorf("error unescaping path parameter '%s': %w", paramName, err)
}
default:
// Headers and cookies aren't escaped.
@ -97,7 +97,7 @@ func BindStyledParameterWithOptions(style string, paramName string, value string
// If the destination implements encoding.TextUnmarshaler we use it for binding
if tu, ok := dest.(encoding.TextUnmarshaler); ok {
if err := tu.UnmarshalText([]byte(value)); err != nil {
return fmt.Errorf("error unmarshaling '%s' text as %T: %s", value, dest, err)
return fmt.Errorf("error unmarshaling '%s' text as %T: %w", value, dest, err)
}
return nil
@ -124,7 +124,7 @@ func BindStyledParameterWithOptions(style string, paramName string, value string
// Chop up the parameter into parts based on its style
parts, err := splitStyledParameter(style, opts.Explode, false, paramName, value)
if err != nil {
return fmt.Errorf("error splitting input '%s' into parts: %s", value, err)
return fmt.Errorf("error splitting input '%s' into parts: %w", value, err)
}
return bindSplitPartsToDestinationArray(parts, dest)
@ -287,7 +287,7 @@ func bindSplitPartsToDestinationStruct(paramName string, parts []string, explode
jsonParam := "{" + strings.Join(fields, ",") + "}"
err := json.Unmarshal([]byte(jsonParam), dest)
if err != nil {
return fmt.Errorf("error binding parameter %s fields: %s", paramName, err)
return fmt.Errorf("error binding parameter %s fields: %w", paramName, err)
}
return nil
}
@ -318,7 +318,11 @@ func BindQueryParameter(style string, explode bool, required bool, paramName str
// inner code will bind the string's value to this interface.
var output interface{}
if required {
// required params are never pointers, but it may happen that optional param
// is not pointer as well if user decides to annotate it with
// x-go-type-skip-optional-pointer
var extraIndirect = !required && v.Kind() == reflect.Pointer
if !extraIndirect {
// If the parameter is required, then the generated code will pass us
// a pointer to it: &int, &object, and so forth. We can directly set
// them.
@ -414,9 +418,10 @@ func BindQueryParameter(style string, explode bool, required bool, paramName str
if err != nil {
return err
}
// If the parameter is required, and we've successfully unmarshaled
// it, this assigns the new object to the pointer pointer.
if !required {
// If the parameter is required (or relies on x-go-type-skip-optional-pointer),
// and we've successfully unmarshaled it, this assigns the new object to the
// pointer pointer.
if extraIndirect {
dv.Set(reflect.ValueOf(output))
}
return nil
@ -456,7 +461,7 @@ func BindQueryParameter(style string, explode bool, required bool, paramName str
if err != nil {
return err
}
if !required {
if extraIndirect {
dv.Set(reflect.ValueOf(output))
}
return nil

View file

@ -100,7 +100,7 @@ func BindStringToObject(src string, dst interface{}) error {
case reflect.Array:
if tu, ok := dst.(encoding.TextUnmarshaler); ok {
if err := tu.UnmarshalText([]byte(src)); err != nil {
return fmt.Errorf("error unmarshaling '%s' text as %T: %s", src, dst, err)
return fmt.Errorf("error unmarshaling '%s' text as %T: %w", src, dst, err)
}
return nil
@ -122,7 +122,7 @@ func BindStringToObject(src string, dst interface{}) error {
if err != nil {
parsedTime, err = time.Parse(types.DateFormat, src)
if err != nil {
return fmt.Errorf("error parsing '%s' as RFC3339 or 2006-01-02 time: %s", src, err)
return fmt.Errorf("error parsing '%s' as RFC3339 or 2006-01-02 time: %w", src, err)
}
}
// So, assigning this gets a little fun. We have a value to the
@ -145,7 +145,7 @@ func BindStringToObject(src string, dst interface{}) error {
}
parsedTime, err := time.Parse(types.DateFormat, src)
if err != nil {
return fmt.Errorf("error parsing '%s' as date: %s", src, err)
return fmt.Errorf("error parsing '%s' as date: %w", src, err)
}
parsedDate := types.Date{Time: parsedTime}

View file

@ -258,7 +258,7 @@ func assignPathValues(dst interface{}, pathValues fieldOrValue) error {
// TODO: why is this marked as an ineffassign?
tm, err = time.Parse(types.DateFormat, pathValues.value) //nolint:ineffassign,staticcheck
if err != nil {
return fmt.Errorf("error parsing '%s' as RFC3339 or 2006-01-02 time: %s", pathValues.value, err)
return fmt.Errorf("error parsing '%s' as RFC3339 or 2006-01-02 time: %w", pathValues.value, err)
}
return fmt.Errorf("invalid date format: %w", err)
}

View file

@ -26,8 +26,9 @@ import (
"strings"
"time"
"github.com/oapi-codegen/runtime/types"
"github.com/google/uuid"
"github.com/oapi-codegen/runtime/types"
)
// Parameter escaping works differently based on where a header is found
@ -79,7 +80,7 @@ func StyleParamWithLocation(style string, explode bool, paramName string, paramL
if !convertableToTime && !convertableToDate {
b, err := tu.MarshalText()
if err != nil {
return "", fmt.Errorf("error marshaling '%s' as text: %s", value, err)
return "", fmt.Errorf("error marshaling '%s' as text: %w", value, err)
}
return stylePrimitive(style, explode, paramName, paramLocation, string(b))
@ -165,7 +166,7 @@ func styleSlice(style string, explode bool, paramName string, paramLocation Para
part = escapeParameterString(part, paramLocation)
parts[i] = part
if err != nil {
return "", fmt.Errorf("error formatting '%s': %s", paramName, err)
return "", fmt.Errorf("error formatting '%s': %w", paramName, err)
}
}
return prefix + strings.Join(parts, separator), nil
@ -273,7 +274,7 @@ func styleStruct(style string, explode bool, paramName string, paramLocation Par
}
str, err := primitiveToString(f.Interface())
if err != nil {
return "", fmt.Errorf("error formatting '%s': %s", paramName, err)
return "", fmt.Errorf("error formatting '%s': %w", paramName, err)
}
fieldDict[fieldName] = str
}
@ -288,19 +289,15 @@ func styleMap(style string, explode bool, paramName string, paramLocation ParamL
}
return MarshalDeepObject(value, paramName)
}
dict, ok := value.(map[string]interface{})
if !ok {
return "", errors.New("map not of type map[string]interface{}")
}
v := reflect.ValueOf(value)
fieldDict := make(map[string]string)
for fieldName, value := range dict {
str, err := primitiveToString(value)
for _, fieldName := range v.MapKeys() {
str, err := primitiveToString(v.MapIndex(fieldName).Interface())
if err != nil {
return "", fmt.Errorf("error formatting '%s': %s", paramName, err)
return "", fmt.Errorf("error formatting '%s': %w", paramName, err)
}
fieldDict[fieldName] = str
fieldDict[fieldName.String()] = str
}
return processFieldDict(style, explode, paramName, paramLocation, fieldDict)
}