diff --git a/servant-docs/src/Servant/Docs/Internal.hs b/servant-docs/src/Servant/Docs/Internal.hs index 9991aec5..9ff742d0 100644 --- a/servant-docs/src/Servant/Docs/Internal.hs +++ b/servant-docs/src/Servant/Docs/Internal.hs @@ -1074,13 +1074,14 @@ instance (ToForm a, ToSample a, HasDocs api) instance (ToFragment (Fragment a), HasDocs api) => HasDocs (Fragment a :> api) where + docsFor Proxy (endpoint, action) = docsFor subApiP (endpoint, action') + where subApiP = Proxy :: Proxy api fragmentP = Proxy :: Proxy (Fragment a) action' = set fragment (Just (toFragment fragmentP)) action - instance HasDocs Raw where docsFor _proxy (endpoint, action) _ = single endpoint action diff --git a/servant-docs/test/Servant/DocsSpec.hs b/servant-docs/test/Servant/DocsSpec.hs index f8a35ebb..9b87c1ac 100644 --- a/servant-docs/test/Servant/DocsSpec.hs +++ b/servant-docs/test/Servant/DocsSpec.hs @@ -82,7 +82,7 @@ spec = describe "Servant.Docs" $ do (defAction & notes <>~ [DocNote "Get an Integer" ["get an integer in Json or plain text"]]) <> extraInfo - (Proxy :: Proxy ("postJson" :> ReqBody '[JSON] String :> Post '[JSON] Datatype1)) + (Proxy :: Proxy (ReqBody '[JSON] String :> Post '[JSON] Datatype1)) (defAction & notes <>~ [DocNote "Post data" ["Posts some Json data"]]) md = markdown (docsWith defaultDocOptions [] extra (Proxy :: Proxy TestApi1)) tests1 md @@ -126,10 +126,10 @@ spec = describe "Servant.Docs" $ do md `shouldContain` "## GET" it "should mention the endpoints" $ do - md `shouldContain` "## POST /postJson" + md `shouldContain` "## POST /" md `shouldContain` "## GET /qparam" md `shouldContain` "## GET /qparamform" - md `shouldContain` "## PUT /header" + md `shouldContain` "## PUT /" it "mentions headers" $ do md `shouldContain` "- This endpoint is sensitive to the value of the **X-Test** HTTP header." @@ -145,7 +145,7 @@ spec = describe "Servant.Docs" $ do md `shouldContain` "### GET Parameters:" md `shouldContain` "- query" it "mentions optional query-param-form params from QueryParamForm" $ - md `shouldContain` "- **Values**: *dt1field1=field%201&dt1field2=13*" + md `shouldContain` "**Values**: *dt1field2=13&dt1field1=field%201*" it "does not generate any docs mentioning the 'empty-api' path" $ md `shouldNotContain` "empty-api" @@ -178,11 +178,12 @@ instance MimeRender PlainText Int where mimeRender _ = cs . show type TestApi1 = Get '[JSON, PlainText] (Headers '[Header "Location" String] Int) - :<|> "postJson" :> ReqBody '[JSON] String :> Post '[JSON] Datatype1 + :<|> ReqBody '[JSON] String :> Post '[JSON] Datatype1 + :<|> Header "X-Test" Int :> Put '[JSON] Int + :<|> "empty-api" :> EmptyAPI :<|> "qparam" :> QueryParam "query" String :> Get '[JSON] Datatype1 :<|> "qparamform" :> QueryParamForm Datatype1 :> Get '[JSON] Datatype1 - :<|> "header" :> Header "X-Test" Int :> Put '[JSON] Int - :<|> "empty-api" :> EmptyAPI + type TestApi2 = "duplicate-endpoint" :> Get '[JSON] Datatype1 :<|> "duplicate-endpoint" :> Get '[PlainText] Int diff --git a/servant-foreign/test/Servant/ForeignSpec.hs b/servant-foreign/test/Servant/ForeignSpec.hs index 3632c071..fe65493a 100644 --- a/servant-foreign/test/Servant/ForeignSpec.hs +++ b/servant-foreign/test/Servant/ForeignSpec.hs @@ -127,8 +127,10 @@ listFromAPISpec = describe "listFromAPI" $ do { _reqUrl = Url [ Segment $ Static "test" ] [ QueryArg (Arg "" "maybe contactFormX") Form ] + Nothing , _reqMethod = "POST" , _reqHeaders = [] + , _reqBody = Nothing , _reqReturnType = Just "voidX" , _reqFuncName = FunctionName ["post", "test"] }