Skip to content

Commit

Permalink
Merge pull request #146 from haskell-servant/pingu/0.4-bugfixes
Browse files Browse the repository at this point in the history
Bugfix release
  • Loading branch information
christian-marie committed Jul 9, 2015
2 parents 9f31996 + fb97bee commit a67cbbc
Show file tree
Hide file tree
Showing 19 changed files with 74 additions and 25 deletions.
10 changes: 7 additions & 3 deletions scripts/bump-versions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
set -o nounset
set -o errexit

. lib/common.sh
DIR=$( dirname $( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ))
. "${DIR}/scripts/lib/common.sh"

usage () {
echo " bump-versions.sh <POSITION> [-d|--dry-run]"
Expand Down Expand Up @@ -54,8 +55,11 @@ while [ "${1:-unset}" != "unset" ] ; do
done

if $DRY_RUN ; then
bumper --dry-run -"$POSITION" $(join , "${SOURCES[@]}")
echo "Would have bumped position ${POSITION} on these packages:"
( cd "$ROOT" && bumper --dry-run -"$POSITION" $(join , "${SOURCES[@]}") )
else
bumper -"$POSITION" $(join , "${SOURCES[@]}")
( cd "$ROOT" && bumper -"$POSITION" $(join , "${SOURCES[@]}") )
fi

# Trailing newline, bumper does not ship with its own.
echo
3 changes: 2 additions & 1 deletion scripts/lib/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@


DIR=$( dirname $( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ))
ROOT=$( dirname $DIR )
DRY_RUN=false
POSITION="none"
SOURCES_TXT="$( dirname $DIR)/sources.txt"
Expand All @@ -22,7 +23,7 @@ readarray -t SOURCES < "$SOURCES_TXT"
join () { local IFS="$1"; shift; echo "$*"; }

versions_equal () {
local NUM=$(find . -name 'servant*.cabal' | xargs grep "^version:" | awk '{ print $2 }' | uniq -c | wc -l)
local NUM=$(cd "$ROOT" && find . -name 'servant*.cabal' | xargs grep "^version:" | awk '{ print $2 }' | uniq -c | wc -l)
if [ 1 -eq $NUM ] ; then
return 0
else
Expand Down
2 changes: 1 addition & 1 deletion servant-blaze/servant-blaze.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
-- documentation, see http://haskell.org/cabal/users-guide/

name: servant-blaze
version: 0.4.2
version: 0.4.3
synopsis: Blaze-html support for servant
-- description:
homepage: http://haskell-servant.github.io/
Expand Down
2 changes: 1 addition & 1 deletion servant-client/servant-client.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: servant-client
version: 0.4.2
version: 0.4.3
synopsis: automatical derivation of querying functions for servant webservices
description:
This library lets you derive automatically Haskell functions that
Expand Down
4 changes: 4 additions & 0 deletions servant-docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
0.4.3
-----
* docsWith will no longer eat your documentation (https://github.com/haskell-servant/servant/pull/124)

0.4
---
* `Delete` now is like `Get`, `Post`, `Put`, and `Patch` and returns a response body
Expand Down
3 changes: 2 additions & 1 deletion servant-docs/servant-docs.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: servant-docs
version: 0.4.2
version: 0.4.3
synopsis: generate API docs for your servant webservice
description:
Library for generating API docs from a servant API definition.
Expand Down Expand Up @@ -70,6 +70,7 @@ test-suite spec
base
, aeson
, hspec
, lens
, servant
, servant-docs
, string-conversions
Expand Down
2 changes: 1 addition & 1 deletion servant-docs/src/Servant/Docs/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ extraInfo p action =
docsWith :: HasDocs layout => [DocIntro] -> ExtraInfo layout -> Proxy layout -> API
docsWith intros (ExtraInfo endpoints) p =
docs p & apiIntros <>~ intros
& apiEndpoints %~ HM.unionWith combineAction endpoints
& apiEndpoints %~ HM.unionWith (flip combineAction) endpoints


-- | Generate the docs for a given API that implements 'HasDocs' with with any
Expand Down
29 changes: 26 additions & 3 deletions servant-docs/test/Servant/DocsSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
{-# OPTIONS_GHC -fno-warn-orphans #-}
module Servant.DocsSpec where

import Control.Lens
import Data.Aeson
import Data.Monoid
import Data.Proxy
import Data.String.Conversions (cs)
import GHC.Generics
Expand All @@ -21,7 +23,27 @@ spec = describe "Servant.Docs" $ do

describe "markdown" $ do
let md = markdown (docs (Proxy :: Proxy TestApi1))

tests md

describe "markdown with extra info" $ do
let
extra = extraInfo
(Proxy :: Proxy (Get '[JSON, PlainText] Int))
(defAction & notes <>~ [DocNote "Get an Integer" ["get an integer in Json or plain text"]])
<>
extraInfo
(Proxy :: Proxy (ReqBody '[JSON] String :> Post '[JSON] Datatype1))
(defAction & notes <>~ [DocNote "Post data" ["Posts some Json data"]])
md = markdown (docsWith [] extra (Proxy :: Proxy TestApi1))
tests md
it "contains the extra info provided" $ do
md `shouldContain` "Get an Integer"
md `shouldContain` "Post data"
md `shouldContain` "get an integer in Json or plain text"
md `shouldContain` "Posts some Json data"

where
tests md = do
it "mentions supported content-types" $ do
md `shouldContain` "application/json"
md `shouldContain` "text/plain;charset=utf-8"
Expand All @@ -34,10 +56,11 @@ spec = describe "Servant.Docs" $ do
md `shouldContain` "POST"
md `shouldContain` "GET"

it "contains response samples" $ do
it "contains response samples" $
md `shouldContain` "{\"dt1field1\":\"field 1\",\"dt1field2\":13}"
it "contains request body samples" $ do
it "contains request body samples" $
md `shouldContain` "17"

-- * APIs

data Datatype1 = Datatype1 { dt1field1 :: String
Expand Down
3 changes: 3 additions & 0 deletions servant-examples/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
0.4.3
-----
* Clarify some variable names in the examples + semantic html pedantry
2 changes: 1 addition & 1 deletion servant-examples/servant-examples.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: servant-examples
version: 0.4.2
version: 0.4.3
synopsis: Example programs for servant
description: Example programs for servant,
showcasing solutions to common needs.
Expand Down
14 changes: 7 additions & 7 deletions servant-examples/tutorial/T4.hs
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,21 @@ instance ToJSON Person

-- HTML serialization of a single person
instance ToHtml Person where
toHtml p =
toHtml person =
tr_ $ do
td_ (toHtml $ firstName p)
td_ (toHtml $ lastName p)
td_ (toHtml . show $ age p)
td_ (toHtml $ firstName person)
td_ (toHtml $ lastName person)
td_ (toHtml . show $ age person)

toHtmlRaw = toHtml

-- HTML serialization of a list of persons
instance ToHtml [Person] where
toHtml persons = table_ $ do
tr_ $ do
td_ "first name"
td_ "last name"
td_ "age"
th_ "first name"
th_ "last name"
th_ "age"

foldMap toHtml persons

Expand Down
4 changes: 4 additions & 0 deletions servant-jquery/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
0.4.3
-----
* Content type now set to JSON when a request body is sent (#122)

0.4
---
* `Delete` now is like `Get`, `Post`, `Put`, and `Patch` and returns a response body
Expand Down
2 changes: 1 addition & 1 deletion servant-jquery/servant-jquery.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: servant-jquery
version: 0.4.2
version: 0.4.3
synopsis: Automatically derive (jquery) javascript functions to query servant webservices
description:
Automatically derive jquery-based javascript functions to query servant webservices.
Expand Down
5 changes: 3 additions & 2 deletions servant-jquery/src/Servant/JQuery.hs
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,14 @@ generateJS req = "\n" <>

dataBody =
if req ^. reqBody
then "\n , data: JSON.stringify(body)\n"
then " , data: JSON.stringify(body)\n" <>
" , contentType: 'application/json'\n"
else ""

reqheaders =
if null hs
then ""
else "\n , headers: { " ++ headersStr ++ " }\n"
else " , headers: { " ++ headersStr ++ " }\n"

where headersStr = intercalate ", " $ map headerStr hs
headerStr header = "\"" ++
Expand Down
2 changes: 1 addition & 1 deletion servant-lucid/servant-lucid.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
-- documentation, see http://haskell.org/cabal/users-guide/

name: servant-lucid
version: 0.4.2
version: 0.4.3
synopsis: Servant support for lucid
-- description:
homepage: http://haskell-servant.github.io/
Expand Down
2 changes: 1 addition & 1 deletion servant-server/servant-server.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: servant-server
version: 0.4.2
version: 0.4.3
synopsis: A family of combinators for defining webservices APIs and serving them
description:
A family of combinators for defining webservices APIs and serving them
Expand Down
4 changes: 4 additions & 0 deletions servant/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
0.4.3
-----
* Add missing HasLink instance for Header (https://github.com/haskell-servant/servant/issues/128)

0.4.1
-----
* Allow whitespace after parsing JSON
Expand Down
2 changes: 1 addition & 1 deletion servant/servant.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: servant
version: 0.4.2
version: 0.4.3
synopsis: A family of combinators for defining webservices APIs
description:
A family of combinators for defining webservices APIs and serving them
Expand Down
4 changes: 4 additions & 0 deletions servant/src/Servant/Utils/Links.hs
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,10 @@ instance (ToText v, HasLink sub)
toLink (Proxy :: Proxy sub) $
addSegment (escape . unpack $ toText v) l

instance HasLink sub => HasLink (Header sym a :> sub) where
type MkLink (Header sym a :> sub) = MkLink sub
toLink _ = toLink (Proxy :: Proxy sub)

-- Verb (terminal) instances
instance HasLink (Get y r) where
type MkLink (Get y r) = URI
Expand Down

0 comments on commit a67cbbc

Please sign in to comment.