Skip to content

Commit 9b51ff1

Browse files
mike-zorndaveshanley
authored andcommitted
Add failing test for enum validation scenario
1 parent 40cae8c commit 9b51ff1

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

parameters/query_parameters_test.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -969,6 +969,37 @@ paths:
969969
"however the value 'haddock' is not a valid number", errors[1].Reason)
970970
}
971971

972+
func TestNewValidator_QueryParamValidEnumStringType(t *testing.T) {
973+
spec := `openapi: 3.1.0
974+
paths:
975+
/a/fishy/on/a/dishy:
976+
get:
977+
parameters:
978+
- name: fishy
979+
in: query
980+
required: true
981+
schema:
982+
type: array
983+
items:
984+
type: string
985+
enum: [cod, haddock]
986+
operationId: locateFishy
987+
`
988+
989+
doc, _ := libopenapi.NewDocument([]byte(spec))
990+
991+
m, _ := doc.BuildV3Model()
992+
993+
v := NewParameterValidator(&m.Model)
994+
995+
request, _ := http.NewRequest(http.MethodGet, "https://things.com/a/fishy/on/a/dishy?fishy=cod,haddock", nil)
996+
997+
valid, errors := v.ValidateQueryParams(request)
998+
assert.True(t, valid)
999+
1000+
assert.Len(t, errors, 0)
1001+
}
1002+
9721003
func TestNewValidator_QueryParamValidExplodedType(t *testing.T) {
9731004
spec := `openapi: 3.1.0
9741005
paths:

0 commit comments

Comments
 (0)