Open teto opened 2 years ago
Hi @teto,
Are you sure you are using Headers
correctly? It should be embedded in a Verb
, like this:
type Api = Get '[] (Headers '[Header "jinko-resource-type" String] NoContent)
openApi = toOpenApi (Proxy :: Proxy Api)
For me this example generates the following openapi:
{
"openapi": "3.0.0",
"info": {
"title": "",
"version":""
},
"paths": {
"/": {
"get": {
"responses": {
"200": {
"headers": {
"jinko-resource-type": {"schema": {"type": "string"}}
},
"description":""
}
}
}
}
},
"components": {}
}
@maksbotan I'm not the original poster, but I'm seeing this error for my auth endpoints:
type AuthAPI =
"register" :> ReqBody '[JSON] RegisterBody :> UVerb 'POST '[JSON] '[WithStatus 200 AuthResp, WithStatus 422 String]
:<|> "login"
:> ReqBody '[JSON] LoginBody
:> UVerb
'POST
'[JSON]
'[ WithStatus
200
( Headers
'[ Header "Set-Cookie" SetCookie,
Header "Set-Cookie" SetCookie
]
AuthResp
),
WithStatus 401 String
]
Seems like there may be a missing instance around the UVerb instances when using headers.
Can you show the precise error message generated with that code?
And why do you have "Set-Cookie"
twice in Headers
?
app/Main.hs:107:18: error:
• No instance for (ToSchema
(Headers
'[Header "Set-Cookie" SetCookie, Header "Set-Cookie" SetCookie]
AuthResp))
arising from a use of ‘toOpenApi’
• In the expression: toOpenApi authApi
In an equation for ‘authApiSwagger’:
authApiSwagger = toOpenApi authApi
|
107 | authApiSwagger = toOpenApi authApi
I assume it's because acceptLogin
sets two cookies? Not sure was mostly following this example:
https://github.com/haskell-servant/servant/tree/master/servant-auth
when compiling my program I get a no instance error for:
Here are the versions:
I've tried looking into the code but there seemed to be several abstractions and I gave up. Maybe with some guidance I could try again.