@@ -61,8 +61,8 @@ instance ToCapture (Capture "y" Int) where
6161 DocCapture "y" -- name
6262 "(integer) position on the y axis" -- description
6363
64−instance ToSample Position Position where
65− toSample _ = Just (Position 3 14) -- example of output
64+instance ToSample Position where
65+ toSamples _ = singleSample (Position 3 14) -- example of output
6666
6767instance ToParam (QueryParam "name" String) where
6868 toParam _ =
@@ -71,7 +71,7 @@ instance ToParam (QueryParam "name" String) where
7171 "Name of the person to say hello to." -- description
7272 Normal -- Normal, List or Flag
7373
74−instance ToSample HelloMessage HelloMessage where
74+instance ToSample HelloMessage where
7575 toSamples _ =
7676 [ ("When a value is provided for 'name'", HelloMessage "Hello, Alp")
7777 , ("When 'name' is not specified", HelloMessage "Hello, anonymous coward")
@@ -81,11 +81,11 @@ instance ToSample HelloMessage HelloMessage where
8181ci :: ClientInfo
8282ci = ClientInfo "Alp" "alp@foo.com" 26 ["haskell", "mathematics"]
8383
84−instance ToSample ClientInfo ClientInfo where
85− toSample _ = Just ci
84+instance ToSample ClientInfo where
85+ toSamples _ = singleSample ci
8686
87−instance ToSample Email Email where
88− toSample _ = Just (emailForClient ci)
87+instance ToSample Email where
88+ toSamples _ = singleSample (emailForClient ci)
8989```
9090
9191Types that are used as request or response bodies have to instantiate the `ToSample` typeclass which lets you specify one or more examples of values. `Capture`s and `QueryParam`s have to instantiate their respective `ToCapture` and `ToParam` classes and provide a name and some information about the concrete meaning of that argument, as illustrated in the code above.
@@ -228,7 +228,7 @@ server = Server.server3 :<|> serveDocs
228228 plain = ("Content-Type", "text/plain")
229229
230230app :: Application
231−app = serve api server
231+app = serve api EmptyConfig server
232232```
233233
234234And if you spin up this server with `dist/build/tutorial/tutorial 10` and go to anywhere else than `/position`, `/hello` and `/marketing`, you will see the API docs in markdown. This is because `serveDocs` is attempted if the 3 other endpoints don't match and systematically succeeds since its definition is to just return some fixed bytestring with the `text/plain` content type.