-
-
Notifications
You must be signed in to change notification settings - Fork 419
Closed
Labels
Description
Since #937, it is now possible to write
type TestApi = "greet" :> Get '[JSON] Greet
:<|> "greet" :> Get '[PlainText] Greet
instead of
type TestApi = "greet" :> Get '[JSON, PlainText] Greet
However, servant-docs does not yet support the new format, it only lists the content-types specified in the first copy of the endpoint.
Here is a self-contained example:
{-# LANGUAGE DataKinds, DeriveGeneric, MultiParamTypeClasses, OverloadedStrings, TypeOperators #-}
import Data.Aeson
import Data.Proxy
import Data.String.Conversions
import Data.Text (Text)
import GHC.Generics
import Servant.API
import Servant.Docs
newtype Greet = Greet Text
deriving (Generic, Show)
instance FromJSON Greet
instance ToJSON Greet
instance MimeRender PlainText Greet where
mimeRender Proxy (Greet s) = cs s
instance ToSample Greet where
toSamples _ = singleSample $ Greet "hello"
type TestApi = "greet" :> Get '[JSON] Greet
:<|> "greet" :> Get '[PlainText] Greet
testApi :: Proxy TestApi
testApi = Proxy
main :: IO ()
main = putStrLn $ markdown $ docs testApi
The output is currently this:
# GET /greet
### Response:
- Status code 200
- Headers: []
- Supported content types are:
- `application/json;charset=utf-8`
- `application/json`
- Example (`application/json;charset=utf-8`, `application/json`):
```javascript
"hello"
```
But I expected this instead:
## GET /greet
### Response:
- Status code 200
- Headers: []
- Supported content types are:
- `application/json;charset=utf-8`
- `application/json`
- `text/plain;charset=utf-8`
- Example (`application/json;charset=utf-8`, `application/json`):
```javascript
"hello"
```
- Example (`text/plain;charset=utf-8`):
```
hello
```
rickowens