@@ -1,5 +1,6 @@
11{-# LANGUAGE TypeFamilies #-}
22{-# LANGUAGE DeriveGeneric #-}
3+{-# LANGUAGE ScopedTypeVariables #-}
34{-# LANGUAGE TemplateHaskell #-}
45
56-------------------------------------------------------------------------------
@@ -88,7 +89,10 @@ module Servant.Docs
8889 HasDocs(..), docs, markdown, printMarkdown
8990
9091 , -- * Classes you need to implement for your types
91− ToSample(..), ToParam(..), ToCapture(..)
92+ ToSample(..)
93+ , sampleByteString
94+ , ToParam(..)
95+ , ToCapture(..)
9296
9397 , -- * ADTs to represent an 'API'
9498 Method(..)
@@ -320,10 +324,13 @@ class HasDocs layout where
320324-- >
321325-- > where g = Greet "Hello, haskeller!"
322326class ToJSON a => ToSample a where
323− toSample :: Proxy a -> Maybe ByteString
327+ toSample :: Maybe a
324328
325329instance ToSample () where
326− toSample Proxy = Just $ encode ()
330+ toSample = Just ()
331+
332+sampleByteString :: forall a . ToSample a => Proxy a -> Maybe ByteString
333+sampleByteString Proxy = fmap encode (toSample :: Maybe a)
327334
328335-- | The class that helps us automatically get documentation
329336-- for GET parameters.