Skip to content

Commit

Permalink
Add enum test case for query params
Browse files Browse the repository at this point in the history
  • Loading branch information
rekfuki committed Aug 22, 2019
1 parent cd14906 commit 5af509b
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions swag-validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ func TestQuery(t *testing.T) {
expectedStatus: 200,
expectedResponse: nil,
},
{
description: "Not allowed enum value in enum query param",
query: "enum_param=baz",
expectedStatus: 400,
expectedResponse: map[string]interface{}{
"enum_param": "Must be one of the following: \"foo\", \"bar\"",
},
},
}

api := swag.New(swag.Endpoints(endpoint.New("GET", "/validate-test", "Test query params",
Expand All @@ -67,6 +75,10 @@ func TestQuery(t *testing.T) {
Type: "string",
Format: "uuid",
},
"enum_param": {
Type: "string",
Enum: []string{"foo", "bar"},
},
}),
)))

Expand Down

0 comments on commit 5af509b

Please sign in to comment.