git.iko.soy/typeable/servant
on master help sign in
test "merge documentation from duplicate routes"
commit0cfd9e6597a9a97e7e860a6a4468cda1da21eda7 authorSamuel Gélineau <gelisam@simspace.com> dateThu 7 Nov 2019, 19:31 (7 years ago) parentfdb1e03
1 file changed+15−4
servant-docs/test/Servant/DocsSpec.hs+15−4
servant-docs/test/Servant/DocsSpec.hs+15−4
@@ -52,8 +52,10 @@ spec :: Spec
5252spec = describe "Servant.Docs" $ do
5353
5454 describe "markdown" $ do
55− let md = markdown (docs (Proxy :: Proxy TestApi1))
56− tests md
55+ let md1 = markdown (docs (Proxy :: Proxy TestApi1))
56+ tests1 md1
57+ let md2 = markdown (docs (Proxy :: Proxy TestApi2))
58+ tests2 md2
5759
5860 describe "markdown with extra info" $ do
5961 let
@@ -65,7 +67,7 @@ spec = describe "Servant.Docs" $ do
6567 (Proxy :: Proxy (ReqBody '[JSON] String :> Post '[JSON] Datatype1))
6668 (defAction & notes <>~ [DocNote "Post data" ["Posts some Json data"]])
6769 md = markdown (docsWith defaultDocOptions [] extra (Proxy :: Proxy TestApi1))
68− tests md
70+ tests1 md
6971 it "contains the extra info provided" $ do
7072 md `shouldContain` "Get an Integer"
7173 md `shouldContain` "Post data"
@@ -93,7 +95,7 @@ spec = describe "Servant.Docs" $ do
9395
9496
9597 where
96− tests md = do
98+ tests1 md = do
9799 it "mentions supported content-types" $ do
98100 md `shouldContain` "application/json"
99101 md `shouldContain` "text/plain;charset=utf-8"
@@ -116,6 +118,11 @@ spec = describe "Servant.Docs" $ do
116118 it "does not generate any docs mentioning the 'empty-api' path" $
117119 md `shouldNotContain` "empty-api"
118120
121+ tests2 md = do
122+ it "mentions the content-types from both copies of the route" $ do
123+ md `shouldContain` "application/json"
124+ md `shouldContain` "text/plain;charset=utf-8"
125+
119126
120127-- * APIs
121128
@@ -142,6 +149,10 @@ type TestApi1 = Get '[JSON, PlainText] (Headers '[Header "Location" String] Int)
142149 :<|> Header "X-Test" Int :> Put '[JSON] Int
143150 :<|> "empty-api" :> EmptyAPI
144151
152+type TestApi2 = "duplicate-endpoint" :> Get '[JSON] Datatype1
153+ :<|> "duplicate-endpoint" :> Get '[PlainText] Int
154+
155+
145156data TT = TT1 | TT2 deriving (Show, Eq)
146157data UT = UT1 | UT2 deriving (Show, Eq)
147158