Skip to content

Commit 13fbb55

Browse files
committed
Support cookie auth
1 parent 012f3ec commit 13fbb55

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

src/OpenApi/Generate.elm

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1463,7 +1463,31 @@ operationToAuthorizationInfo operation =
14631463
|> CliMonad.succeed
14641464

14651465
OpenApi.SecurityScheme.Cookie ->
1466-
CliMonad.todoWithDefault acc "Unsupported security schema: ApiKey in Cookie"
1466+
if Dict.member "Cookie" acc.headers then
1467+
CliMonad.todoWithDefault acc "Cookie header already set"
1468+
1469+
else
1470+
CliMonad.succeed
1471+
{ acc
1472+
| headers =
1473+
Dict.insert "Cookie"
1474+
(\config ->
1475+
Elm.Op.append
1476+
(Elm.string (apiKey.name ++ "="))
1477+
(config
1478+
|> Elm.get "authorization"
1479+
|> Elm.get cleanName
1480+
)
1481+
)
1482+
acc.headers
1483+
, params =
1484+
Dict.insert "authorization"
1485+
(Dict.insert cleanName Elm.Annotation.string <|
1486+
Maybe.withDefault Dict.empty <|
1487+
Dict.get "authorization" acc.params
1488+
)
1489+
acc.params
1490+
}
14671491

14681492
OpenApi.SecurityScheme.Http details ->
14691493
case details.scheme of

0 commit comments

Comments
 (0)