on master help sign in
Merge pull request #19 from haskell-servant/fixed-pr-16
e4b2e15Julian Arni
CHANGELOG.md+1
@@ -5,6 +5,7 @@
5* Render endpoints in a canonical order (https://github.com/haskell-servant/servant-docs/pull/15)
5* Render endpoints in a canonical order (https://github.com/haskell-servant/servant-docs/pull/15)
6* Remove ToJSON superclass from ToSample
6* Remove ToJSON superclass from ToSample
7* Split out Internal module
7* Split out Internal module
8+* `Canonicalize` API types before generating the docs for them
8
9
90.3
100.3
10---
11---
example/greet.hs+1−1
@@ -27,7 +27,7 @@ instance ToJSON Greet
27
27
28-- | We can also implement 'MimeRender' for additional formats like 'PlainText'.
28-- | We can also implement 'MimeRender' for additional formats like 'PlainText'.
29instance MimeRender PlainText Greet where
29instance MimeRender PlainText Greet where
30− toByteString Proxy (Greet s) = "\"" <> cs s <> "\""
30+ mimeRender Proxy (Greet s) = "\"" <> cs s <> "\""
31
31
32-- We add some useful annotations to our captures,
32-- We add some useful annotations to our captures,
33-- query parameters and request body to make the docs
33-- query parameters and request body to make the docs
src/Servant/Docs/Internal.hs+4−4
@@ -273,8 +273,8 @@ makeLenses ''Action
273
273
274-- | Generate the docs for a given API that implements 'HasDocs'. This is the
274-- | Generate the docs for a given API that implements 'HasDocs'. This is the
275-- default way to create documentation.
275-- default way to create documentation.
276−docs :: HasDocs layout => Proxy layout -> API
276+docs :: HasDocs (Canonicalize layout) => Proxy layout -> API
277−docs p = docsFor p (defEndpoint, defAction)
277+docs p = docsFor (canonicalize p) (defEndpoint, defAction)
278
278
279-- | Closed type family, check if endpoint is exactly within API.
279-- | Closed type family, check if endpoint is exactly within API.
280
280
@@ -318,7 +318,7 @@ extraInfo p action =
318-- 'extraInfo'.
318-- 'extraInfo'.
319--
319--
320-- If you only want to add an introduction, use 'docsWithIntros'.
320-- If you only want to add an introduction, use 'docsWithIntros'.
321−docsWith :: HasDocs layout
321+docsWith :: HasDocs (Canonicalize layout)
322 => [DocIntro]
322 => [DocIntro]
323 -> ExtraInfo layout
323 -> ExtraInfo layout
324 -> Proxy layout
324 -> Proxy layout
@@ -330,7 +330,7 @@ docsWith intros (ExtraInfo endpoints) p =
330
330
331-- | Generate the docs for a given API that implements 'HasDocs' with with any
331-- | Generate the docs for a given API that implements 'HasDocs' with with any
332-- number of introduction(s)
332-- number of introduction(s)
333−docsWithIntros :: HasDocs layout => [DocIntro] -> Proxy layout -> API
333+docsWithIntros :: HasDocs (Canonicalize layout) => [DocIntro] -> Proxy layout -> API
334docsWithIntros intros = docsWith intros mempty
334docsWithIntros intros = docsWith intros mempty
335
335
336-- | The class that abstracts away the impact of API combinators
336-- | The class that abstracts away the impact of API combinators
test/Servant/DocsSpec.hs+1−1
@@ -56,7 +56,7 @@ instance ToSample Int where
56 toSample = Just 17
56 toSample = Just 17
57
57
58instance MimeRender PlainText Int where
58instance MimeRender PlainText Int where
59− toByteString _ = cs . show
59+ mimeRender _ = cs . show
60
60
61
61
62type TestApi1 = Get '[JSON, PlainText] Int
62type TestApi1 = Get '[JSON, PlainText] Int