-
Notifications
You must be signed in to change notification settings - Fork 74
Cookie support in servant-auth-swagger #70
Comments
From current Auth combinator, you can't really document much about Cookies in swagger2. #42 has set authentication to be a noop - because swagger2.0 doesn't support Cookie authentication (on the other hand, openapi 3 does). About documenting parameters, shortcut I use for now is a noop: instance ToParamSchema SetCookie where
toParamSchema _ = mempty -- TODO: document name of the cookie Combining #116 and #58 we could come up with API combinators like |
I don't have required context. What kind of There is If there's some other thing where |
I can reproduce with #!/usr/bin/env stack
{- stack script --nix --resolver lts-12.16
--package http-api-data
--package servant-auth
--package servant-auth-swagger
--package cookie
-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE OverloadedStrings #-}
module ApiType where
import Servant
import Servant.Auth
import Servant.Auth.Swagger ()
import Servant.Swagger
import Web.Cookie
type API = Header "X-Foo" SetCookie :> Get '[JSON] Int
api :: Proxy API
api = Proxy
main :: IO ()
main = print (toSwagger api) Although this doesn't pin http-api-data-0.3.10, but I've tried in my project with the correct version and it's missing the same instance. |
Ok. so you use Then the instance for instance ToParamSchema SetCookie where
toParamSchema _ = mempty
& type_ .~ SwaggerString
.... |
There's no Cookie support in Swagger2, best effort is: parameters:
- name: Cookie
in: header
type: string
required: true So given SetCookie instance, we can only set that it's a string. I suppose |
I'm not so interested "what's inside the cookie", the |
@phadej agreed :) I've updated the PR, it's an improvement over the current missing instance. |
I'd like to use cookie based auth with
toSwagger
but I get this errorWhat is necessary for cookie auth support? If it's not too complicated I'd be glad to take care of it.
The text was updated successfully, but these errors were encountered: