test "merge documentation from duplicate routes"
This commit is contained in:
parent
fdb1e030e6
commit
0cfd9e6597
1 changed files with 15 additions and 4 deletions
|
@ -52,8 +52,10 @@ spec :: Spec
|
||||||
spec = describe "Servant.Docs" $ do
|
spec = describe "Servant.Docs" $ do
|
||||||
|
|
||||||
describe "markdown" $ do
|
describe "markdown" $ do
|
||||||
let md = markdown (docs (Proxy :: Proxy TestApi1))
|
let md1 = markdown (docs (Proxy :: Proxy TestApi1))
|
||||||
tests md
|
tests1 md1
|
||||||
|
let md2 = markdown (docs (Proxy :: Proxy TestApi2))
|
||||||
|
tests2 md2
|
||||||
|
|
||||||
describe "markdown with extra info" $ do
|
describe "markdown with extra info" $ do
|
||||||
let
|
let
|
||||||
|
@ -65,7 +67,7 @@ spec = describe "Servant.Docs" $ do
|
||||||
(Proxy :: Proxy (ReqBody '[JSON] String :> Post '[JSON] Datatype1))
|
(Proxy :: Proxy (ReqBody '[JSON] String :> Post '[JSON] Datatype1))
|
||||||
(defAction & notes <>~ [DocNote "Post data" ["Posts some Json data"]])
|
(defAction & notes <>~ [DocNote "Post data" ["Posts some Json data"]])
|
||||||
md = markdown (docsWith defaultDocOptions [] extra (Proxy :: Proxy TestApi1))
|
md = markdown (docsWith defaultDocOptions [] extra (Proxy :: Proxy TestApi1))
|
||||||
tests md
|
tests1 md
|
||||||
it "contains the extra info provided" $ do
|
it "contains the extra info provided" $ do
|
||||||
md `shouldContain` "Get an Integer"
|
md `shouldContain` "Get an Integer"
|
||||||
md `shouldContain` "Post data"
|
md `shouldContain` "Post data"
|
||||||
|
@ -93,7 +95,7 @@ spec = describe "Servant.Docs" $ do
|
||||||
|
|
||||||
|
|
||||||
where
|
where
|
||||||
tests md = do
|
tests1 md = do
|
||||||
it "mentions supported content-types" $ do
|
it "mentions supported content-types" $ do
|
||||||
md `shouldContain` "application/json"
|
md `shouldContain` "application/json"
|
||||||
md `shouldContain` "text/plain;charset=utf-8"
|
md `shouldContain` "text/plain;charset=utf-8"
|
||||||
|
@ -116,6 +118,11 @@ spec = describe "Servant.Docs" $ do
|
||||||
it "does not generate any docs mentioning the 'empty-api' path" $
|
it "does not generate any docs mentioning the 'empty-api' path" $
|
||||||
md `shouldNotContain` "empty-api"
|
md `shouldNotContain` "empty-api"
|
||||||
|
|
||||||
|
tests2 md = do
|
||||||
|
it "mentions the content-types from both copies of the route" $ do
|
||||||
|
md `shouldContain` "application/json"
|
||||||
|
md `shouldContain` "text/plain;charset=utf-8"
|
||||||
|
|
||||||
|
|
||||||
-- * APIs
|
-- * APIs
|
||||||
|
|
||||||
|
@ -142,6 +149,10 @@ type TestApi1 = Get '[JSON, PlainText] (Headers '[Header "Location" String] Int)
|
||||||
:<|> Header "X-Test" Int :> Put '[JSON] Int
|
:<|> Header "X-Test" Int :> Put '[JSON] Int
|
||||||
:<|> "empty-api" :> EmptyAPI
|
:<|> "empty-api" :> EmptyAPI
|
||||||
|
|
||||||
|
type TestApi2 = "duplicate-endpoint" :> Get '[JSON] Datatype1
|
||||||
|
:<|> "duplicate-endpoint" :> Get '[PlainText] Int
|
||||||
|
|
||||||
|
|
||||||
data TT = TT1 | TT2 deriving (Show, Eq)
|
data TT = TT1 | TT2 deriving (Show, Eq)
|
||||||
data UT = UT1 | UT2 deriving (Show, Eq)
|
data UT = UT1 | UT2 deriving (Show, Eq)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue