Skip to content

Commit f749ac0

Browse files
committed
Add test to ensure security: [] isn't decoded to Nothing
1 parent db427d7 commit f749ac0

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

tests/Test/OpenApi/Operation.elm

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ suite =
7171
decodedOperation
7272
|> Result.map (OpenApi.Operation.security >> Maybe.map List.length)
7373
|> Expect.equal (Ok (Just 1))
74+
, test "security = []" <|
75+
\() ->
76+
Json.Decode.decodeString OpenApi.Operation.decode securityIsEmptyArrayExample
77+
|> Result.map OpenApi.Operation.security
78+
|> Expect.equal (Ok (Just []))
7479
, describe "when 'security' is unspecified" <|
7580
[ test "it decodes to Nothing" <|
7681
\() ->
@@ -163,6 +168,21 @@ example =
163168
}"""
164169

165170

171+
securityIsEmptyArrayExample : String
172+
securityIsEmptyArrayExample =
173+
"""{
174+
"summary": "Updates a pet in the store with form data",
175+
"operationId": "updatePetWithForm",
176+
"security": [],
177+
"responses": {
178+
"200": {
179+
"description": "Pet updated.",
180+
"content": {}
181+
}
182+
}
183+
}"""
184+
185+
166186
securityUnspecifiedExample : String
167187
securityUnspecifiedExample =
168188
"""{

0 commit comments

Comments
 (0)