Skip to content

Commit 0cfd9e6

Browse files
author
Samuel Gélineau
committed
test "merge documentation from duplicate routes"
1 parent fdb1e03 commit 0cfd9e6

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

servant-docs/test/Servant/DocsSpec.hs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,10 @@ spec :: Spec
5252
spec = 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+
145156
data TT = TT1 | TT2 deriving (Show, Eq)
146157
data UT = UT1 | UT2 deriving (Show, Eq)
147158

0 commit comments

Comments
 (0)