You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm having some trouble with the following snippet under get: and parameters:
- name: group-id
in: query
description: Group IDs
schema:
type: array
items:
$ref: '#/components/schemas/GroupId'
minItems: 1
style: form
explode: false
The parameter is optional (no required: true). Yet when the parameter is omitted completely from the query parameter list in a HTTP Request then validation fails with the error 'Min items is 1'. Even though the parameter itself is optional.
Looking at the code, in ValidateParameter() in validate_request.go there is a test 'if value == nil' before checking parameter.Required. However if a query parameter such as above is missing completely then 'value' still gets decoded as the empty slice []interface{}, which is different to being nil in Go. So the 'test == nil' fails, the Required flag is not checked and it moves on to checking MinItems when it shouldn't in this case I don't believe, thus generating the validation error.
Is my interpretation correct here?
Many thanks
The text was updated successfully, but these errors were encountered:
Hi,
I'm having some trouble with the following snippet under get: and parameters:
The parameter is optional (no required: true). Yet when the parameter is omitted completely from the query parameter list in a HTTP Request then validation fails with the error 'Min items is 1'. Even though the parameter itself is optional.
Looking at the code, in ValidateParameter() in validate_request.go there is a test 'if value == nil' before checking parameter.Required. However if a query parameter such as above is missing completely then 'value' still gets decoded as the empty slice []interface{}, which is different to being nil in Go. So the 'test == nil' fails, the Required flag is not checked and it moves on to checking MinItems when it shouldn't in this case I don't believe, thus generating the validation error.
Is my interpretation correct here?
Many thanks
The text was updated successfully, but these errors were encountered: