Skip to content

Commit 2c8450e

Browse files
committed
Support cookie auth
1 parent 8443ff7 commit 2c8450e

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
@@ -1464,7 +1464,31 @@ operationToAuthorizationInfo operation =
14641464
|> CliMonad.succeed
14651465

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

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

0 commit comments

Comments
 (0)