Merge pull request #15 from zerobuzz/canonical-order
Render entpoints in canonical order.
This commit is contained in:
commit
72b2fac95d
2 changed files with 10 additions and 10 deletions
|
@ -31,7 +31,7 @@ library
|
||||||
, aeson
|
, aeson
|
||||||
, bytestring
|
, bytestring
|
||||||
, hashable
|
, hashable
|
||||||
, http-media
|
, http-media >= 0.6
|
||||||
, lens
|
, lens
|
||||||
, servant >= 0.2.1
|
, servant >= 0.2.1
|
||||||
, string-conversions
|
, string-conversions
|
||||||
|
|
|
@ -212,7 +212,7 @@ data Method = DocDELETE -- ^ the DELETE method
|
||||||
| DocGET -- ^ the GET method
|
| DocGET -- ^ the GET method
|
||||||
| DocPOST -- ^ the POST method
|
| DocPOST -- ^ the POST method
|
||||||
| DocPUT -- ^ the PUT method
|
| DocPUT -- ^ the PUT method
|
||||||
deriving (Eq, Generic)
|
deriving (Eq, Ord, Generic)
|
||||||
|
|
||||||
instance Show Method where
|
instance Show Method where
|
||||||
show DocGET = "GET"
|
show DocGET = "GET"
|
||||||
|
@ -239,7 +239,7 @@ instance Hashable Method
|
||||||
data Endpoint = Endpoint
|
data Endpoint = Endpoint
|
||||||
{ _path :: [String] -- type collected
|
{ _path :: [String] -- type collected
|
||||||
, _method :: Method -- type collected
|
, _method :: Method -- type collected
|
||||||
} deriving (Eq, Generic)
|
} deriving (Eq, Ord, Generic)
|
||||||
|
|
||||||
instance Show Endpoint where
|
instance Show Endpoint where
|
||||||
show (Endpoint p m) =
|
show (Endpoint p m) =
|
||||||
|
@ -291,7 +291,7 @@ emptyAPI = mempty
|
||||||
data DocCapture = DocCapture
|
data DocCapture = DocCapture
|
||||||
{ _capSymbol :: String -- type supplied
|
{ _capSymbol :: String -- type supplied
|
||||||
, _capDesc :: String -- user supplied
|
, _capDesc :: String -- user supplied
|
||||||
} deriving (Eq, Show)
|
} deriving (Eq, Ord, Show)
|
||||||
|
|
||||||
-- | A type to represent a /GET/ parameter from the Query String. Holds its name,
|
-- | A type to represent a /GET/ parameter from the Query String. Holds its name,
|
||||||
-- the possible values (leave empty if there isn't a finite number of them),
|
-- the possible values (leave empty if there isn't a finite number of them),
|
||||||
|
@ -303,7 +303,7 @@ data DocQueryParam = DocQueryParam
|
||||||
, _paramValues :: [String] -- user supplied
|
, _paramValues :: [String] -- user supplied
|
||||||
, _paramDesc :: String -- user supplied
|
, _paramDesc :: String -- user supplied
|
||||||
, _paramKind :: ParamKind
|
, _paramKind :: ParamKind
|
||||||
} deriving (Eq, Show)
|
} deriving (Eq, Ord, Show)
|
||||||
|
|
||||||
-- | An introductory paragraph for your documentation. You can pass these to
|
-- | An introductory paragraph for your documentation. You can pass these to
|
||||||
-- 'docsWithIntros'.
|
-- 'docsWithIntros'.
|
||||||
|
@ -322,7 +322,7 @@ instance Ord DocIntro where
|
||||||
data DocNote = DocNote
|
data DocNote = DocNote
|
||||||
{ _noteTitle :: String
|
{ _noteTitle :: String
|
||||||
, _noteBody :: [String]
|
, _noteBody :: [String]
|
||||||
} deriving (Eq, Show)
|
} deriving (Eq, Ord, Show)
|
||||||
|
|
||||||
-- | Type of extra information that a user may wish to "union" with their
|
-- | Type of extra information that a user may wish to "union" with their
|
||||||
-- documentation.
|
-- documentation.
|
||||||
|
@ -341,7 +341,7 @@ instance Monoid (ExtraInfo a) where
|
||||||
-- - List corresponds to @QueryParams@, i.e GET parameters with multiple values
|
-- - List corresponds to @QueryParams@, i.e GET parameters with multiple values
|
||||||
-- - Flag corresponds to @QueryFlag@, i.e a value-less GET parameter
|
-- - Flag corresponds to @QueryFlag@, i.e a value-less GET parameter
|
||||||
data ParamKind = Normal | List | Flag
|
data ParamKind = Normal | List | Flag
|
||||||
deriving (Eq, Show)
|
deriving (Eq, Ord, Show)
|
||||||
|
|
||||||
-- | A type to represent an HTTP response. Has an 'Int' status, a list of
|
-- | A type to represent an HTTP response. Has an 'Int' status, a list of
|
||||||
-- possible 'MediaType's, and a list of example 'ByteString' response bodies.
|
-- possible 'MediaType's, and a list of example 'ByteString' response bodies.
|
||||||
|
@ -362,7 +362,7 @@ data Response = Response
|
||||||
{ _respStatus :: Int
|
{ _respStatus :: Int
|
||||||
, _respTypes :: [M.MediaType]
|
, _respTypes :: [M.MediaType]
|
||||||
, _respBody :: [(Text, M.MediaType, ByteString)]
|
, _respBody :: [(Text, M.MediaType, ByteString)]
|
||||||
} deriving (Eq, Show)
|
} deriving (Eq, Ord, Show)
|
||||||
|
|
||||||
-- | Default response: status code 200, no response body.
|
-- | Default response: status code 200, no response body.
|
||||||
--
|
--
|
||||||
|
@ -394,7 +394,7 @@ data Action = Action
|
||||||
, _rqtypes :: [M.MediaType] -- type collected
|
, _rqtypes :: [M.MediaType] -- type collected
|
||||||
, _rqbody :: [(M.MediaType, ByteString)] -- user supplied
|
, _rqbody :: [(M.MediaType, ByteString)] -- user supplied
|
||||||
, _response :: Response -- user supplied
|
, _response :: Response -- user supplied
|
||||||
} deriving (Eq, Show)
|
} deriving (Eq, Ord, Show)
|
||||||
|
|
||||||
-- | Combine two Actions, we can't make a monoid as merging Response breaks the
|
-- | Combine two Actions, we can't make a monoid as merging Response breaks the
|
||||||
-- laws.
|
-- laws.
|
||||||
|
@ -611,7 +611,7 @@ class ToCapture c where
|
||||||
markdown :: API -> String
|
markdown :: API -> String
|
||||||
markdown api = unlines $
|
markdown api = unlines $
|
||||||
introsStr (api ^. apiIntros)
|
introsStr (api ^. apiIntros)
|
||||||
++ (concatMap (uncurry printEndpoint) . HM.toList $ api ^. apiEndpoints)
|
++ (concatMap (uncurry printEndpoint) . sort . HM.toList $ api ^. apiEndpoints)
|
||||||
|
|
||||||
where printEndpoint :: Endpoint -> Action -> [String]
|
where printEndpoint :: Endpoint -> Action -> [String]
|
||||||
printEndpoint endpoint action =
|
printEndpoint endpoint action =
|
||||||
|
|
Loading…
Reference in a new issue