From 5af509b8e73546fa2a80c5ddc6e165650b18b84d Mon Sep 17 00:00:00 2001 From: Andrius Navasaitis Date: Thu, 22 Aug 2019 10:52:29 +0100 Subject: [PATCH] Add enum test case for query params --- swag-validator_test.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/swag-validator_test.go b/swag-validator_test.go index 380b825..a737514 100644 --- a/swag-validator_test.go +++ b/swag-validator_test.go @@ -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", @@ -67,6 +75,10 @@ func TestQuery(t *testing.T) { Type: "string", Format: "uuid", }, + "enum_param": { + Type: "string", + Enum: []string{"foo", "bar"}, + }, }), )))