on master help sign in
Merge pull request #15 from zerobuzz/canonical-order

Render entpoints in canonical order.

commit72b2fac95d67925cef39c91d60507bf3c7697a72 authorAlp Mestanogullari <alpmestan@gmail.com> dateTue 24 Feb 2015, 11:15 (12 years ago) parent795a77068fee74
2 files changed+10−10
servant-docs.cabal+1−1 src/Servant/Docs.hs+9−9
servant-docs.cabal+1−1
@@ -31,7 +31,7 @@ library
3131 , aeson
3232 , bytestring
3333 , hashable
34− , http-media
34+ , http-media >= 0.6
3535 , lens
3636 , servant >= 0.2.1
3737 , string-conversions
src/Servant/Docs.hs+9−9
@@ -212,7 +212,7 @@ data Method = DocDELETE -- ^ the DELETE method
212212 | DocGET -- ^ the GET method
213213 | DocPOST -- ^ the POST method
214214 | DocPUT -- ^ the PUT method
215− deriving (Eq, Generic)
215+ deriving (Eq, Ord, Generic)
216216
217217instance Show Method where
218218 show DocGET = "GET"
@@ -239,7 +239,7 @@ instance Hashable Method
239239data Endpoint = Endpoint
240240 { _path :: [String] -- type collected
241241 , _method :: Method -- type collected
242− } deriving (Eq, Generic)
242+ } deriving (Eq, Ord, Generic)
243243
244244instance Show Endpoint where
245245 show (Endpoint p m) =
@@ -291,7 +291,7 @@ emptyAPI = mempty
291291data DocCapture = DocCapture
292292 { _capSymbol :: String -- type supplied
293293 , _capDesc :: String -- user supplied
294− } deriving (Eq, Show)
294+ } deriving (Eq, Ord, Show)
295295
296296-- | A type to represent a /GET/ parameter from the Query String. Holds its name,
297297-- the possible values (leave empty if there isn't a finite number of them),
@@ -303,7 +303,7 @@ data DocQueryParam = DocQueryParam
303303 , _paramValues :: [String] -- user supplied
304304 , _paramDesc :: String -- user supplied
305305 , _paramKind :: ParamKind
306− } deriving (Eq, Show)
306+ } deriving (Eq, Ord, Show)
307307
308308-- | An introductory paragraph for your documentation. You can pass these to
309309-- 'docsWithIntros'.
@@ -322,7 +322,7 @@ instance Ord DocIntro where
322322data DocNote = DocNote
323323 { _noteTitle :: String
324324 , _noteBody :: [String]
325− } deriving (Eq, Show)
325+ } deriving (Eq, Ord, Show)
326326
327327-- | Type of extra information that a user may wish to "union" with their
328328-- documentation.
@@ -341,7 +341,7 @@ instance Monoid (ExtraInfo a) where
341341-- - List corresponds to @QueryParams@, i.e GET parameters with multiple values
342342-- - Flag corresponds to @QueryFlag@, i.e a value-less GET parameter
343343data ParamKind = Normal | List | Flag
344− deriving (Eq, Show)
344+ deriving (Eq, Ord, Show)
345345
346346-- | A type to represent an HTTP response. Has an 'Int' status, a list of
347347-- possible 'MediaType's, and a list of example 'ByteString' response bodies.
@@ -362,7 +362,7 @@ data Response = Response
362362 { _respStatus :: Int
363363 , _respTypes :: [M.MediaType]
364364 , _respBody :: [(Text, M.MediaType, ByteString)]
365− } deriving (Eq, Show)
365+ } deriving (Eq, Ord, Show)
366366
367367-- | Default response: status code 200, no response body.
368368--
@@ -394,7 +394,7 @@ data Action = Action
394394 , _rqtypes :: [M.MediaType] -- type collected
395395 , _rqbody :: [(M.MediaType, ByteString)] -- user supplied
396396 , _response :: Response -- user supplied
397− } deriving (Eq, Show)
397+ } deriving (Eq, Ord, Show)
398398
399399-- | Combine two Actions, we can't make a monoid as merging Response breaks the
400400-- laws.
@@ -611,7 +611,7 @@ class ToCapture c where
611611markdown :: API -> String
612612markdown api = unlines $
613613 introsStr (api ^. apiIntros)
614− ++ (concatMap (uncurry printEndpoint) . HM.toList $ api ^. apiEndpoints)
614+ ++ (concatMap (uncurry printEndpoint) . sort . HM.toList $ api ^. apiEndpoints)
615615
616616 where printEndpoint :: Endpoint -> Action -> [String]
617617 printEndpoint endpoint action =