@@ -1,5 +1,6 @@
1{-# LANGUAGE TypeFamilies #-}
1{-# LANGUAGE TypeFamilies #-}
2{-# LANGUAGE DeriveGeneric #-}
2{-# LANGUAGE DeriveGeneric #-}
3+{-# LANGUAGE ScopedTypeVariables #-}
3{-# LANGUAGE TemplateHaskell #-}
4{-# LANGUAGE TemplateHaskell #-}
5-------------------------------------------------------------------------------
6-------------------------------------------------------------------------------
@@ -88,7 +89,10 @@ module Servant.Docs
88 HasDocs(..), docs, markdown, printMarkdown
89 HasDocs(..), docs, markdown, printMarkdown
90 , -- * Classes you need to implement for your types
91 , -- * Classes you need to implement for your types
91− ToSample(..), ToParam(..), ToCapture(..)
95+ , ToCapture(..)
93 , -- * ADTs to represent an 'API'
97 , -- * ADTs to represent an 'API'
94 Method(..)
98 Method(..)
@@ -320,10 +324,13 @@ class HasDocs layout where
321-- > where g = Greet "Hello, haskeller!"
325-- > where g = Greet "Hello, haskeller!"
322class ToJSON a => ToSample a where
326class ToJSON a => ToSample a where
323− toSample :: Proxy a -> Maybe ByteString
327+ toSample :: Maybe a
325instance ToSample () where
329instance ToSample () where
326− toSample Proxy = Just $ encode ()
330+ toSample = Just ()
332+sampleByteString :: forall a . ToSample a => Proxy a -> Maybe ByteString
333+sampleByteString Proxy = fmap encode (toSample :: Maybe a)
328-- | The class that helps us automatically get documentation
335-- | The class that helps us automatically get documentation
329-- for GET parameters.
336-- for GET parameters.