diff --git a/servant-docs/src/Servant/Docs.hs b/servant-docs/src/Servant/Docs.hs index 09399c02..5a244cc1 100644 --- a/servant-docs/src/Servant/Docs.hs +++ b/servant-docs/src/Servant/Docs.hs @@ -151,6 +151,7 @@ module Servant.Docs , toSample , noSamples , singleSample + , samples , sampleByteString , sampleByteStrings , ToParam(..) diff --git a/servant-docs/src/Servant/Docs/Internal.hs b/servant-docs/src/Servant/Docs/Internal.hs index 5ea68d8e..5d9d8418 100644 --- a/servant-docs/src/Servant/Docs/Internal.hs +++ b/servant-docs/src/Servant/Docs/Internal.hs @@ -399,6 +399,10 @@ noSamples = empty singleSample :: a -> [(Text, a)] singleSample x = [("", x)] +-- | Samples without documentation. +samples :: [a] -> [(Text, a)] +samples = map ("",) + -- | Default sample Generic-based inputs/outputs. defaultSamples :: forall a b. (Generic a, Generic b, GToSample (Rep a) (Rep b)) => Proxy a -> [(Text, b)] defaultSamples _ = Omega.runOmega $ second to <$> gtoSamples (Proxy :: Proxy (Rep a)) diff --git a/servant-docs/test/Servant/DocsSpec.hs b/servant-docs/test/Servant/DocsSpec.hs index 9063f9a5..8a7fa301 100644 --- a/servant-docs/test/Servant/DocsSpec.hs +++ b/servant-docs/test/Servant/DocsSpec.hs @@ -4,7 +4,6 @@ {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE OverloadedStrings #-} -{-# LANGUAGE TupleSections #-} {-# LANGUAGE TypeOperators #-} {-# LANGUAGE TypeSynonymInstances #-} {-# OPTIONS_GHC -fno-warn-orphans #-} @@ -95,7 +94,7 @@ instance ToSample Datatype1 Datatype1 where toSamples _ = singleSample $ Datatype1 "field 1" 13 instance ToSample Char Char where - toSamples _ = map ("",) ['a'..'z'] + toSamples _ = samples ['a'..'z'] instance ToSample Int Int where toSamples _ = singleSample 17