Skip to content

Commit 55a85e1

Browse files
committed
Making the diff smaller and fix the tests.
1 parent c64bbb9 commit 55a85e1

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

servant-docs/src/Servant/Docs/Internal.hs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1074,13 +1074,14 @@ instance (ToForm a, ToSample a, HasDocs api)
10741074

10751075
instance (ToFragment (Fragment a), HasDocs api)
10761076
=> HasDocs (Fragment a :> api) where
1077+
10771078
docsFor Proxy (endpoint, action) =
10781079
docsFor subApiP (endpoint, action')
1080+
10791081
where subApiP = Proxy :: Proxy api
10801082
fragmentP = Proxy :: Proxy (Fragment a)
10811083
action' = set fragment (Just (toFragment fragmentP)) action
10821084

1083-
10841085
instance HasDocs Raw where
10851086
docsFor _proxy (endpoint, action) _ =
10861087
single endpoint action

servant-docs/test/Servant/DocsSpec.hs

+8-7
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ spec = describe "Servant.Docs" $ do
8282
(defAction & notes <>~ [DocNote "Get an Integer" ["get an integer in Json or plain text"]])
8383
<>
8484
extraInfo
85-
(Proxy :: Proxy ("postJson" :> ReqBody '[JSON] String :> Post '[JSON] Datatype1))
85+
(Proxy :: Proxy (ReqBody '[JSON] String :> Post '[JSON] Datatype1))
8686
(defAction & notes <>~ [DocNote "Post data" ["Posts some Json data"]])
8787
md = markdown (docsWith defaultDocOptions [] extra (Proxy :: Proxy TestApi1))
8888
tests1 md
@@ -126,10 +126,10 @@ spec = describe "Servant.Docs" $ do
126126
md `shouldContain` "## GET"
127127

128128
it "should mention the endpoints" $ do
129-
md `shouldContain` "## POST /postJson"
129+
md `shouldContain` "## POST /"
130130
md `shouldContain` "## GET /qparam"
131131
md `shouldContain` "## GET /qparamform"
132-
md `shouldContain` "## PUT /header"
132+
md `shouldContain` "## PUT /"
133133

134134
it "mentions headers" $ do
135135
md `shouldContain` "- This endpoint is sensitive to the value of the **X-Test** HTTP header."
@@ -145,7 +145,7 @@ spec = describe "Servant.Docs" $ do
145145
md `shouldContain` "### GET Parameters:"
146146
md `shouldContain` "- query"
147147
it "mentions optional query-param-form params from QueryParamForm" $
148-
md `shouldContain` "- **Values**: *dt1field1=field%201&dt1field2=13*"
148+
md `shouldContain` "**Values**: *dt1field2=13&dt1field1=field%201*"
149149

150150
it "does not generate any docs mentioning the 'empty-api' path" $
151151
md `shouldNotContain` "empty-api"
@@ -178,11 +178,12 @@ instance MimeRender PlainText Int where
178178
mimeRender _ = cs . show
179179

180180
type TestApi1 = Get '[JSON, PlainText] (Headers '[Header "Location" String] Int)
181-
:<|> "postJson" :> ReqBody '[JSON] String :> Post '[JSON] Datatype1
181+
:<|> ReqBody '[JSON] String :> Post '[JSON] Datatype1
182+
:<|> Header "X-Test" Int :> Put '[JSON] Int
183+
:<|> "empty-api" :> EmptyAPI
182184
:<|> "qparam" :> QueryParam "query" String :> Get '[JSON] Datatype1
183185
:<|> "qparamform" :> QueryParamForm Datatype1 :> Get '[JSON] Datatype1
184-
:<|> "header" :> Header "X-Test" Int :> Put '[JSON] Int
185-
:<|> "empty-api" :> EmptyAPI
186+
186187

187188
type TestApi2 = "duplicate-endpoint" :> Get '[JSON] Datatype1
188189
:<|> "duplicate-endpoint" :> Get '[PlainText] Int

servant-foreign/test/Servant/ForeignSpec.hs

+2
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,10 @@ listFromAPISpec = describe "listFromAPI" $ do
127127
{ _reqUrl = Url
128128
[ Segment $ Static "test" ]
129129
[ QueryArg (Arg "" "maybe contactFormX") Form ]
130+
Nothing
130131
, _reqMethod = "POST"
131132
, _reqHeaders = []
133+
, _reqBody = Nothing
132134
, _reqReturnType = Just "voidX"
133135
, _reqFuncName = FunctionName ["post", "test"]
134136
}

0 commit comments

Comments
 (0)