diff --git a/scripts/bump-versions.sh b/scripts/bump-versions.sh index f75a3d5e..e1e735f4 100755 --- a/scripts/bump-versions.sh +++ b/scripts/bump-versions.sh @@ -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 [-d|--dry-run]" @@ -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 diff --git a/scripts/lib/common.sh b/scripts/lib/common.sh index 19b85d5d..6b131455 100644 --- a/scripts/lib/common.sh +++ b/scripts/lib/common.sh @@ -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" @@ -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 diff --git a/servant-blaze/servant-blaze.cabal b/servant-blaze/servant-blaze.cabal index 92e8c24a..f5c4d761 100644 --- a/servant-blaze/servant-blaze.cabal +++ b/servant-blaze/servant-blaze.cabal @@ -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/ diff --git a/servant-client/servant-client.cabal b/servant-client/servant-client.cabal index 5245836b..faedd007 100644 --- a/servant-client/servant-client.cabal +++ b/servant-client/servant-client.cabal @@ -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 diff --git a/servant-docs/CHANGELOG.md b/servant-docs/CHANGELOG.md index 2d87a8bf..eb132226 100644 --- a/servant-docs/CHANGELOG.md +++ b/servant-docs/CHANGELOG.md @@ -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 diff --git a/servant-docs/servant-docs.cabal b/servant-docs/servant-docs.cabal index afa44525..0442697a 100644 --- a/servant-docs/servant-docs.cabal +++ b/servant-docs/servant-docs.cabal @@ -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. @@ -70,6 +70,7 @@ test-suite spec base , aeson , hspec + , lens , servant , servant-docs , string-conversions diff --git a/servant-docs/src/Servant/Docs/Internal.hs b/servant-docs/src/Servant/Docs/Internal.hs index c1e5b724..09bf8b40 100644 --- a/servant-docs/src/Servant/Docs/Internal.hs +++ b/servant-docs/src/Servant/Docs/Internal.hs @@ -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 diff --git a/servant-docs/test/Servant/DocsSpec.hs b/servant-docs/test/Servant/DocsSpec.hs index 8e6cb201..9da66448 100644 --- a/servant-docs/test/Servant/DocsSpec.hs +++ b/servant-docs/test/Servant/DocsSpec.hs @@ -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 @@ -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" @@ -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 diff --git a/servant-examples/CHANGELOG.md b/servant-examples/CHANGELOG.md new file mode 100644 index 00000000..1eaceb3d --- /dev/null +++ b/servant-examples/CHANGELOG.md @@ -0,0 +1,3 @@ +0.4.3 +----- +* Clarify some variable names in the examples + semantic html pedantry diff --git a/servant-examples/servant-examples.cabal b/servant-examples/servant-examples.cabal index 23956dd8..607cea13 100644 --- a/servant-examples/servant-examples.cabal +++ b/servant-examples/servant-examples.cabal @@ -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. diff --git a/servant-examples/tutorial/T4.hs b/servant-examples/tutorial/T4.hs index 595eabcb..94f8df73 100644 --- a/servant-examples/tutorial/T4.hs +++ b/servant-examples/tutorial/T4.hs @@ -25,11 +25,11 @@ 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 @@ -37,9 +37,9 @@ instance ToHtml Person where 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 diff --git a/servant-jquery/CHANGELOG.md b/servant-jquery/CHANGELOG.md index 09b241cc..efc1ea44 100644 --- a/servant-jquery/CHANGELOG.md +++ b/servant-jquery/CHANGELOG.md @@ -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 diff --git a/servant-jquery/servant-jquery.cabal b/servant-jquery/servant-jquery.cabal index 91dd6bb5..a20393b2 100644 --- a/servant-jquery/servant-jquery.cabal +++ b/servant-jquery/servant-jquery.cabal @@ -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. diff --git a/servant-jquery/src/Servant/JQuery.hs b/servant-jquery/src/Servant/JQuery.hs index 729a3fd9..974b3925 100644 --- a/servant-jquery/src/Servant/JQuery.hs +++ b/servant-jquery/src/Servant/JQuery.hs @@ -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 = "\"" ++ diff --git a/servant-lucid/servant-lucid.cabal b/servant-lucid/servant-lucid.cabal index 3cff3a4c..10aab86d 100644 --- a/servant-lucid/servant-lucid.cabal +++ b/servant-lucid/servant-lucid.cabal @@ -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/ diff --git a/servant-server/servant-server.cabal b/servant-server/servant-server.cabal index c519e8a0..ebd15883 100644 --- a/servant-server/servant-server.cabal +++ b/servant-server/servant-server.cabal @@ -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 diff --git a/servant/CHANGELOG.md b/servant/CHANGELOG.md index 21dd0278..5fc52ed1 100644 --- a/servant/CHANGELOG.md +++ b/servant/CHANGELOG.md @@ -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 diff --git a/servant/servant.cabal b/servant/servant.cabal index d644ac32..76463f1b 100644 --- a/servant/servant.cabal +++ b/servant/servant.cabal @@ -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 diff --git a/servant/src/Servant/Utils/Links.hs b/servant/src/Servant/Utils/Links.hs index a217e20d..7cb8df76 100644 --- a/servant/src/Servant/Utils/Links.hs +++ b/servant/src/Servant/Utils/Links.hs @@ -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