@@ -95,7 +95,7 @@ module Servant.Docs
95 , Endpoint, path, method, defEndpoint
95 , Endpoint, path, method, defEndpoint
96 , API, emptyAPI
96 , API, emptyAPI
97 , DocCapture(..), capSymbol, capDesc
97 , DocCapture(..), capSymbol, capDesc
98− , DocQueryParam(..), paramName, paramValues, paramDesc
98+ , DocQueryParam(..), ParamKind(..), paramName, paramValues, paramDesc, paramKind
99 , Response, respStatus, respBody, defResponse
99 , Response, respStatus, respBody, defResponse
100 , Action, captures, params, rqbody, response, defAction
100 , Action, captures, params, rqbody, response, defAction
@@ -199,8 +199,17 @@ data DocQueryParam = DocQueryParam
199 { _paramName :: String -- type supplied
199 { _paramName :: String -- type supplied
200 , _paramValues :: [String] -- user supplied
200 , _paramValues :: [String] -- user supplied
201 , _paramDesc :: String -- user supplied
201 , _paramDesc :: String -- user supplied
202+ , _paramKind :: ParamKind
202 } deriving (Eq, Show)
203 } deriving (Eq, Show)
205+-- | Type of GET parameter:
207+-- - Normal corresponds to @QueryParam@, i.e your usual GET parameter
208+-- - List corresponds to @QueryParams@, i.e GET parameters with multiple values
209+-- - Flag corresponds to @QueryFlag@, i.e a value-less GET parameter
210+data ParamKind = Normal | List | Flag
204-- | A type to represent an HTTP response. Has an 'Int' status and
213-- | A type to represent an HTTP response. Has an 'Int' status and
205-- a 'Maybe ByteString' response body. Tweak 'defResponse' using
214-- a 'Maybe ByteString' response body. Tweak 'defResponse' using
206-- the 'respStatus' and 'respBody' lenses if you want.
215-- the 'respStatus' and 'respBody' lenses if you want.
@@ -373,9 +382,14 @@ printMarkdown = imapM_ printEndpoint
373 putStrLn ""
382 putStrLn ""
374 paramStr param = do
383 paramStr param = do
375 putStrLn $ " - " ++ param ^. paramName
384 putStrLn $ " - " ++ param ^. paramName
376− when (not $ null values) $
385+ when (not (null values) || param ^. paramKind /= Flag) $
377 putStrLn $ " - **Values**: *" ++ intercalate ", " values ++ "*"
386 putStrLn $ " - **Values**: *" ++ intercalate ", " values ++ "*"
378 putStrLn $ " - **Description**: " ++ param ^. paramDesc
387 putStrLn $ " - **Description**: " ++ param ^. paramDesc
388+ when (param ^. paramKind == List) $
389+ putStrLn $ " - This parameter is a **list**. All GET parameters with the name "
390+ ++ param ^. paramName ++ "[] will forward their values in a list to the handler."
391+ when (param ^. paramKind == Flag) $
392+ putStrLn $ " - This parameter is a **flag**. This means no value is expected to be associated to this parameter."
380 where values = param ^. paramValues
394 where values = param ^. paramValues