haskell-servant / haskell-servant/servant-swagger
Tagging endpoints on Sub APIs
- Dominant language
- Haskell
- Stars
- 123
- Forks
- 34
- PR merge metrics
- No merged PRs in 30d
Description
Running into some issues trying to tag endpoints when we have broken up the API so it doesn't live in one monolithic file/type.
For example, we have a top level:
```
type Routes =
ApiTerm :> VersionTerm :> (
AdminTerm :> AdminApi
:<|> ClientTerm :> ClientApi
)
```
with
```
type ClientApi =
AuthTerm :> AuthApi
:<|> UserTerm :> UserApi
```
and
```
type UserApi =
-- Users API
GetUserApi
:<|> CreateUserApi
```
and then
```
type GetUserApi =
Capture "id" UserId :>
Get '[JSON] UserReadable
```
What would be the proper way to tag the endpoint?
```appSwagger :: Swagger
appSwagger = toSwagger (Proxy::Proxy Routes)
& info.title .~ "App API"
& info.version .~ "1"
& info.description ?~ "This is the App API spec"
& applyTagsFor (subOperations (Proxy :: Proxy GetUserApi) (Proxy :: Proxy UserApi)) ["Client_User" & description ?~ "App Client API"]
```
Results in the tag getting created, but not associated with the endpoint. Attempting to specify Routes as the whole API results int he following type error:
```
src/App.hs:58:19: error:
• Could not deduce: Servant.Swagger.Internal.TypeLevel.API.IsIn
(Capture "id" Model.User.Types.UserId
:> Verb 'GET 200 '[JSON] Model.User.JSON.UserReadable)
(ApiTerm
:> (VersionTerm
:> ((AdminTerm :> Routes.Admin.AdminApi)
:<|> (ClientTerm :> ClientApi))))
arising from a use of ‘subOperations’
from the context: Applicative f
bound by a type expected by the context:
Applicative f => (Operation -> f Operation) -> Swagger -> f Swagger
at src/App.hs:58:5-136
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.