Skip to content

Commit ba01d08

Browse files
committed
fixed linting issues
1 parent b9e741d commit ba01d08

File tree

4 files changed

+8
-13
lines changed

4 files changed

+8
-13
lines changed

errors/parameter_errors.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,7 @@ func IncorrectQueryParamArrayBoolean(
150150
}
151151
}
152152

153-
func IncorrectParamArrayMaxNumItems(
154-
param *v3.Parameter, sch *base.Schema, expected, actual int64) *ValidationError {
153+
func IncorrectParamArrayMaxNumItems(param *v3.Parameter, sch *base.Schema, expected, actual int64) *ValidationError {
155154
return &ValidationError{
156155
ValidationType: helpers.ParameterValidation,
157156
ValidationSubType: helpers.ParameterValidationQuery,
@@ -165,8 +164,7 @@ func IncorrectParamArrayMaxNumItems(
165164
}
166165
}
167166

168-
func IncorrectParamArrayMinNumItems(
169-
param *v3.Parameter, sch *base.Schema, expected, actual int64) *ValidationError {
167+
func IncorrectParamArrayMinNumItems(param *v3.Parameter, sch *base.Schema, expected, actual int64) *ValidationError {
170168
return &ValidationError{
171169
ValidationType: helpers.ParameterValidation,
172170
ValidationSubType: helpers.ParameterValidationQuery,
@@ -180,8 +178,7 @@ func IncorrectParamArrayMinNumItems(
180178
}
181179
}
182180

183-
func IncorrectParamArrayUniqueItems(
184-
param *v3.Parameter, sch *base.Schema, duplicates string) *ValidationError {
181+
func IncorrectParamArrayUniqueItems(param *v3.Parameter, sch *base.Schema, duplicates string) *ValidationError {
185182
return &ValidationError{
186183
ValidationType: helpers.ParameterValidation,
187184
ValidationSubType: helpers.ParameterValidationQuery,

parameters/query_parameters.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ import (
2121
"github.com/pb33f/libopenapi-validator/paths"
2222
)
2323

24+
const rx = `[:\/\?#\[\]\@!\$&'\(\)\*\+,;=]`
25+
26+
var rxRxp = regexp.MustCompile(rx)
27+
2428
func (v *paramValidator) ValidateQueryParams(request *http.Request) (bool, []*errors.ValidationError) {
2529
pathItem, errs, foundPath := paths.FindPath(request, v.document)
2630
if len(errs) > 0 {
@@ -29,9 +33,6 @@ func (v *paramValidator) ValidateQueryParams(request *http.Request) (bool, []*er
2933
return v.ValidateQueryParamsWithPathItem(request, pathItem, foundPath)
3034
}
3135

32-
var rx = `[:\/\?#\[\]\@!\$&'\(\)\*\+,;=]`
33-
var rxRxp = regexp.MustCompile(rx)
34-
3536
func (v *paramValidator) ValidateQueryParamsWithPathItem(request *http.Request, pathItem *v3.PathItem, pathValue string) (bool, []*errors.ValidationError) {
3637
if pathItem == nil {
3738
return false, []*errors.ValidationError{{

parameters/query_parameters_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3172,9 +3172,7 @@ paths:
31723172
// Helper to build a request
31733173
makeRequest := func(ids []string) *http.Request {
31743174
values := make([]string, len(ids))
3175-
for i, id := range ids {
3176-
values[i] = fmt.Sprintf("%s", id)
3177-
}
3175+
copy(values, ids)
31783176
req, _ := http.NewRequest(http.MethodGet, "/items?id="+strings.Join(values, ","), nil)
31793177
return req
31803178
}

parameters/validation_functions.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@ func ValidateQueryArray(
161161

162162
// for each type defined in the item's schema, check the item
163163
for _, itemType := range itemsSchema.Type {
164-
165164
switch itemType {
166165
case helpers.Integer, helpers.Number:
167166
if _, err := strconv.ParseFloat(item, 64); err != nil {

0 commit comments

Comments
 (0)