git.iko.soy/typeable/servant
on master help sign in
Merge pull request #146 from haskell-servant/pingu/0.4-bugfixes

Bugfix release

commita67cbbc2244341f02018cb16020878927f9def47 authorChristian Marie <christian@ponies.io> dateThu 9 Jul 2015, 11:52 (11 years ago) parent9f31996fb97bee
19 files changed+74−25
scripts/bump-versions.sh+7−3 scripts/lib/common.sh+2−1 servant-blaze/servant-blaze.cabal+1−1 servant-client/servant-client.cabal+1−1 servant-docs/CHANGELOG.md+4 servant-docs/servant-docs.cabal+2−1 servant-docs/src/Servant/Docs/Internal.hs+1−1 servant-docs/test/Servant/DocsSpec.hs+26−3 servant-examples/CHANGELOG.md+3 servant-examples/servant-examples.cabal+1−1 servant-examples/tutorial/T4.hs+7−7 servant-jquery/CHANGELOG.md+4 servant-jquery/servant-jquery.cabal+1−1 servant-jquery/src/Servant/JQuery.hs+3−2 servant-lucid/servant-lucid.cabal+1−1 servant-server/servant-server.cabal+1−1 servant/CHANGELOG.md+4 servant/servant.cabal+1−1 servant/src/Servant/Utils/Links.hs+4
scripts/bump-versions.sh+7−3
@@ -16,7 +16,8 @@
1616set -o nounset
1717set -o errexit
1818
19−. lib/common.sh
19+DIR=$( dirname $( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ))
20+. "${DIR}/scripts/lib/common.sh"
2021
2122usage () {
2223 echo " bump-versions.sh <POSITION> [-d|--dry-run]"
@@ -54,8 +55,11 @@ while [ "${1:-unset}" != "unset" ] ; do
5455done
5556
5657if $DRY_RUN ; then
57− bumper --dry-run -"$POSITION" $(join , "${SOURCES[@]}")
58+ echo "Would have bumped position ${POSITION} on these packages:"
59+ ( cd "$ROOT" && bumper --dry-run -"$POSITION" $(join , "${SOURCES[@]}") )
5860else
59− bumper -"$POSITION" $(join , "${SOURCES[@]}")
61+ ( cd "$ROOT" && bumper -"$POSITION" $(join , "${SOURCES[@]}") )
6062fi
6163
64+# Trailing newline, bumper does not ship with its own.
65+echo
scripts/lib/common.sh+2−1
@@ -11,6 +11,7 @@
1111
1212
1313DIR=$( dirname $( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ))
14+ROOT=$( dirname $DIR )
1415DRY_RUN=false
1516POSITION="none"
1617SOURCES_TXT="$( dirname $DIR)/sources.txt"
@@ -22,7 +23,7 @@ readarray -t SOURCES < "$SOURCES_TXT"
2223join () { local IFS="$1"; shift; echo "$*"; }
2324
2425versions_equal () {
25− local NUM=$(find . -name 'servant*.cabal' | xargs grep "^version:" | awk '{ print $2 }' | uniq -c | wc -l)
26+ local NUM=$(cd "$ROOT" && find . -name 'servant*.cabal' | xargs grep "^version:" | awk '{ print $2 }' | uniq -c | wc -l)
2627 if [ 1 -eq $NUM ] ; then
2728 return 0
2829 else
servant-blaze/servant-blaze.cabal+1−1
@@ -2,7 +2,7 @@
22-- documentation, see http://haskell.org/cabal/users-guide/
33
44name: servant-blaze
5−version: 0.4.2
5+version: 0.4.3
66synopsis: Blaze-html support for servant
77-- description:
88homepage: http://haskell-servant.github.io/
servant-client/servant-client.cabal+1−1
@@ -1,5 +1,5 @@
11name: servant-client
2−version: 0.4.2
2+version: 0.4.3
33synopsis: automatical derivation of querying functions for servant webservices
44description:
55 This library lets you derive automatically Haskell functions that
servant-docs/CHANGELOG.md+4
@@ -1,3 +1,7 @@
1+0.4.3
2+-----
3+* docsWith will no longer eat your documentation (https://github.com/haskell-servant/servant/pull/124)
4+
150.4
26---
37* `Delete` now is like `Get`, `Post`, `Put`, and `Patch` and returns a response body
servant-docs/servant-docs.cabal+2−1
@@ -1,5 +1,5 @@
11name: servant-docs
2−version: 0.4.2
2+version: 0.4.3
33synopsis: generate API docs for your servant webservice
44description:
55 Library for generating API docs from a servant API definition.
@@ -70,6 +70,7 @@ test-suite spec
7070 base
7171 , aeson
7272 , hspec
73+ , lens
7374 , servant
7475 , servant-docs
7576 , string-conversions
servant-docs/src/Servant/Docs/Internal.hs+1−1
@@ -338,7 +338,7 @@ extraInfo p action =
338338docsWith :: HasDocs layout => [DocIntro] -> ExtraInfo layout -> Proxy layout -> API
339339docsWith intros (ExtraInfo endpoints) p =
340340 docs p & apiIntros <>~ intros
341− & apiEndpoints %~ HM.unionWith combineAction endpoints
341+ & apiEndpoints %~ HM.unionWith (flip combineAction) endpoints
342342
343343
344344-- | Generate the docs for a given API that implements 'HasDocs' with with any
servant-docs/test/Servant/DocsSpec.hs+26−3
@@ -7,7 +7,9 @@
77{-# OPTIONS_GHC -fno-warn-orphans #-}
88module Servant.DocsSpec where
99
10+import Control.Lens
1011import Data.Aeson
12+import Data.Monoid
1113import Data.Proxy
1214import Data.String.Conversions (cs)
1315import GHC.Generics
@@ -21,7 +23,27 @@ spec = describe "Servant.Docs" $ do
2123
2224 describe "markdown" $ do
2325 let md = markdown (docs (Proxy :: Proxy TestApi1))
24−
26+ tests md
27+
28+ describe "markdown with extra info" $ do
29+ let
30+ extra = extraInfo
31+ (Proxy :: Proxy (Get '[JSON, PlainText] Int))
32+ (defAction & notes <>~ [DocNote "Get an Integer" ["get an integer in Json or plain text"]])
33+ <>
34+ extraInfo
35+ (Proxy :: Proxy (ReqBody '[JSON] String :> Post '[JSON] Datatype1))
36+ (defAction & notes <>~ [DocNote "Post data" ["Posts some Json data"]])
37+ md = markdown (docsWith [] extra (Proxy :: Proxy TestApi1))
38+ tests md
39+ it "contains the extra info provided" $ do
40+ md `shouldContain` "Get an Integer"
41+ md `shouldContain` "Post data"
42+ md `shouldContain` "get an integer in Json or plain text"
43+ md `shouldContain` "Posts some Json data"
44+
45+ where
46+ tests md = do
2547 it "mentions supported content-types" $ do
2648 md `shouldContain` "application/json"
2749 md `shouldContain` "text/plain;charset=utf-8"
@@ -34,10 +56,11 @@ spec = describe "Servant.Docs" $ do
3456 md `shouldContain` "POST"
3557 md `shouldContain` "GET"
3658
37− it "contains response samples" $ do
59+ it "contains response samples" $
3860 md `shouldContain` "{\"dt1field1\":\"field 1\",\"dt1field2\":13}"
39− it "contains request body samples" $ do
61+ it "contains request body samples" $
4062 md `shouldContain` "17"
63+
4164-- * APIs
4265
4366data Datatype1 = Datatype1 { dt1field1 :: String
servant-examples/CHANGELOG.mdnew file+3
@@ -0,0 +1,3 @@
1+0.4.3
2+-----
3+* Clarify some variable names in the examples + semantic html pedantry
servant-examples/servant-examples.cabal+1−1
@@ -1,5 +1,5 @@
11name: servant-examples
2−version: 0.4.2
2+version: 0.4.3
33synopsis: Example programs for servant
44description: Example programs for servant,
55 showcasing solutions to common needs.
servant-examples/tutorial/T4.hs+7−7
@@ -25,11 +25,11 @@ instance ToJSON Person
2525
2626-- HTML serialization of a single person
2727instance ToHtml Person where
28− toHtml p =
28+ toHtml person =
2929 tr_ $ do
30− td_ (toHtml $ firstName p)
31− td_ (toHtml $ lastName p)
32− td_ (toHtml . show $ age p)
30+ td_ (toHtml $ firstName person)
31+ td_ (toHtml $ lastName person)
32+ td_ (toHtml . show $ age person)
3333
3434 toHtmlRaw = toHtml
3535
@@ -37,9 +37,9 @@ instance ToHtml Person where
3737instance ToHtml [Person] where
3838 toHtml persons = table_ $ do
3939 tr_ $ do
40− td_ "first name"
41− td_ "last name"
42− td_ "age"
40+ th_ "first name"
41+ th_ "last name"
42+ th_ "age"
4343
4444 foldMap toHtml persons
4545
servant-jquery/CHANGELOG.md+4
@@ -1,3 +1,7 @@
1+0.4.3
2+-----
3+* Content type now set to JSON when a request body is sent (#122)
4+
150.4
26---
37* `Delete` now is like `Get`, `Post`, `Put`, and `Patch` and returns a response body
servant-jquery/servant-jquery.cabal+1−1
@@ -1,5 +1,5 @@
11name: servant-jquery
2−version: 0.4.2
2+version: 0.4.3
33synopsis: Automatically derive (jquery) javascript functions to query servant webservices
44description:
55 Automatically derive jquery-based javascript functions to query servant webservices.
servant-jquery/src/Servant/JQuery.hs+3−2
@@ -65,13 +65,14 @@ generateJS req = "\n" <>
6565
6666 dataBody =
6767 if req ^. reqBody
68− then "\n , data: JSON.stringify(body)\n"
68+ then " , data: JSON.stringify(body)\n" <>
69+ " , contentType: 'application/json'\n"
6970 else ""
7071
7172 reqheaders =
7273 if null hs
7374 then ""
74− else "\n , headers: { " ++ headersStr ++ " }\n"
75+ else " , headers: { " ++ headersStr ++ " }\n"
7576
7677 where headersStr = intercalate ", " $ map headerStr hs
7778 headerStr header = "\"" ++
servant-lucid/servant-lucid.cabal+1−1
@@ -2,7 +2,7 @@
22-- documentation, see http://haskell.org/cabal/users-guide/
33
44name: servant-lucid
5−version: 0.4.2
5+version: 0.4.3
66synopsis: Servant support for lucid
77-- description:
88homepage: http://haskell-servant.github.io/
servant-server/servant-server.cabal+1−1
@@ -1,5 +1,5 @@
11name: servant-server
2−version: 0.4.2
2+version: 0.4.3
33synopsis: A family of combinators for defining webservices APIs and serving them
44description:
55 A family of combinators for defining webservices APIs and serving them
servant/CHANGELOG.md+4
@@ -1,3 +1,7 @@
1+0.4.3
2+-----
3+* Add missing HasLink instance for Header (https://github.com/haskell-servant/servant/issues/128)
4+
150.4.1
26-----
37* Allow whitespace after parsing JSON
servant/servant.cabal+1−1
@@ -1,5 +1,5 @@
11name: servant
2−version: 0.4.2
2+version: 0.4.3
33synopsis: A family of combinators for defining webservices APIs
44description:
55 A family of combinators for defining webservices APIs and serving them
servant/src/Servant/Utils/Links.hs+4
@@ -339,6 +339,10 @@ instance (ToText v, HasLink sub)
339339 toLink (Proxy :: Proxy sub) $
340340 addSegment (escape . unpack $ toText v) l
341341
342+instance HasLink sub => HasLink (Header sym a :> sub) where
343+ type MkLink (Header sym a :> sub) = MkLink sub
344+ toLink _ = toLink (Proxy :: Proxy sub)
345+
342346-- Verb (terminal) instances
343347instance HasLink (Get y r) where
344348 type MkLink (Get y r) = URI