Skip to content

Commit

Permalink
array tests
Browse files Browse the repository at this point in the history
  • Loading branch information
RangelReale committed Jul 9, 2023
1 parent 8c750b3 commit ba3f9d3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion operation_header.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ func (d *DecodeOperationHeader) Decode(ctx DecodeContext, r *http.Request, field
return false, nil, nil
}

if field.Kind() == reflect.Slice || field.Kind() == reflect.Array {
// only check slices/arrays for primitive types, otherwise "type UUID [16]byte" would be checked as an array
isPrimitive := field.Type().PkgPath() == ""

if isPrimitive && (field.Kind() == reflect.Slice || field.Kind() == reflect.Array) {
return true, values, nil
}
return true, values[0], nil
Expand Down
5 changes: 4 additions & 1 deletion operation_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ func (d *DecodeOperationQuery) Decode(ctx DecodeContext, r *http.Request, field
return false, nil, nil
}

if field.Kind() == reflect.Slice {
// only check slices/arrays for primitive types, otherwise "type UUID [16]byte" would be checked as an array
isPrimitive := field.Type().PkgPath() == ""

if isPrimitive && (field.Kind() == reflect.Slice || field.Kind() == reflect.Array) {
explode, err := tag.Options.BoolValue("explode", false)
if err != nil {
return false, nil, err
Expand Down

0 comments on commit ba3f9d3

Please sign in to comment.