Skip to content

Commit

Permalink
Merge pull request haskell-servant#4 from NoRedInk/puffins/upgrade-0.19
Browse files Browse the repository at this point in the history
Upgrade to 0.19
  • Loading branch information
stoeffel committed Nov 29, 2018
2 parents f69984f + 6fca070 commit 575fb04
Show file tree
Hide file tree
Showing 28 changed files with 269 additions and 199 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ before_install:
- export PATH=$HOME/.local/bin:$PATH
- travis_retry curl -L https://www.stackage.org/stack/linux-x86_64 | tar xz --wildcards --strip-components=1 -C ~/.local/bin '*/stack'
# install elm
- npm install -g elm@0.18.0
- npm install -g elm@0.19.0

# This line does all of the work: installs GHC if necessary, build the library,
# executables, and test suites, and runs the test suites. --no-terminal works
Expand All @@ -32,3 +32,4 @@ script: stack $ARGS --no-terminal --install-ghc test --haddock --flag servant-el
cache:
directories:
- $HOME/.stack
- $HOME/.elm
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ import Json.Decode exposing (..)
import Json.Decode.Pipeline exposing (..)
import Json.Encode
import Http
import String
import String.Conversions as String
import Url


type alias Book =
Expand All @@ -95,7 +95,7 @@ getBooksByBookId capture_bookId =
String.join "/"
[ ""
, "books"
, capture_bookId |> toString |> Http.encodeUri
, capture_bookId |> String.fromInt |> Url.percentEncode
]
, body =
Http.emptyBody
Expand Down
18 changes: 0 additions & 18 deletions examples/books/elm-package.json

This file was deleted.

27 changes: 27 additions & 0 deletions examples/books/elm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"type": "application",
"source-directories": [
"elm"
],
"elm-version": "0.19.0",
"dependencies": {
"direct": {
"NoRedInk/elm-json-decode-pipeline": "1.0.0",
"NoRedInk/elm-string-conversions": "1.0.0",
"elm/browser": "1.0.0",
"elm/core": "1.0.0",
"elm/html": "1.0.0",
"elm/http": "1.0.0",
"elm/json": "1.0.0",
"elm/url": "1.0.0"
},
"indirect": {
"elm/time": "1.0.0",
"elm/virtual-dom": "1.0.0"
}
},
"test-dependencies": {
"direct": {},
"indirect": {}
}
}
33 changes: 18 additions & 15 deletions examples/books/elm/Generated/BooksApi.elm
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import Json.Decode exposing (..)
import Json.Decode.Pipeline exposing (..)
import Json.Encode
import Http
import String
import String.Conversions as String
import Url


type alias Book =
Expand All @@ -14,7 +14,7 @@ type alias Book =

decodeBook : Decoder Book
decodeBook =
decode Book
succeed Book
|> required "name" string

encodeBook : Book -> Json.Encode.Value
Expand All @@ -39,10 +39,11 @@ postBooks body =
Http.jsonBody (encodeBook body)
, expect =
Http.expectStringResponse
(\response ->
Result.map
(\body -> { response | body = body })
(decodeString decodeBook response.body))
(\res ->
Result.mapError Json.Decode.errorToString
(Result.map
(\body_ -> { url = res.url, status = res.status, headers = res.headers, body = body_ })
(decodeString decodeBook res.body)))
, timeout =
Nothing
, withCredentials =
Expand All @@ -65,10 +66,11 @@ getBooks =
Http.emptyBody
, expect =
Http.expectStringResponse
(\response ->
Result.map
(\body -> { response | body = body })
(decodeString (list decodeBook) response.body))
(\res ->
Result.mapError Json.Decode.errorToString
(Result.map
(\body_ -> { url = res.url, status = res.status, headers = res.headers, body = body_ })
(decodeString (list decodeBook) res.body)))
, timeout =
Nothing
, withCredentials =
Expand All @@ -86,16 +88,17 @@ getBooksByBookId capture_bookId =
String.join "/"
[ "http://localhost:8000"
, "books"
, capture_bookId |> toString |> Http.encodeUri
, capture_bookId |> String.fromInt |> Url.percentEncode
]
, body =
Http.emptyBody
, expect =
Http.expectStringResponse
(\response ->
Result.map
(\body -> { response | body = body })
(decodeString decodeBook response.body))
(\res ->
Result.mapError Json.Decode.errorToString
(Result.map
(\body_ -> { url = res.url, status = res.status, headers = res.headers, body = body_ })
(decodeString decodeBook res.body)))
, timeout =
Nothing
, withCredentials =
Expand Down
18 changes: 0 additions & 18 deletions examples/e2e-tests/elm-package.json

This file was deleted.

27 changes: 27 additions & 0 deletions examples/e2e-tests/elm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"type": "application",
"source-directories": [
"elm"
],
"elm-version": "0.19.0",
"dependencies": {
"direct": {
"NoRedInk/elm-json-decode-pipeline": "1.0.0",
"NoRedInk/elm-string-conversions": "1.0.0",
"elm/browser": "1.0.0",
"elm/core": "1.0.0",
"elm/html": "1.0.0",
"elm/http": "1.0.0",
"elm/json": "1.0.0",
"elm/url": "1.0.0"
},
"indirect": {
"elm/time": "1.0.0",
"elm/virtual-dom": "1.0.0"
}
},
"test-dependencies": {
"direct": {},
"indirect": {}
}
}
61 changes: 32 additions & 29 deletions examples/e2e-tests/elm/Generated/Api.elm
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,16 @@ import Json.Decode exposing (..)
import Json.Decode.Pipeline exposing (..)
import Json.Encode
import Http
import String
import String.Conversions as String

import Url

type alias Response =
{ origin : String
}

decodeResponse : Decoder Response
decodeResponse =
decode Response
succeed Response
|> required "origin" string

type NoContent
Expand All @@ -32,7 +31,7 @@ encodeMessageBody x =

decodeMessageBody : Decoder MessageBody
decodeMessageBody =
decode MessageBody
succeed MessageBody
|> required "message" string

type alias ResponseWithJson =
Expand All @@ -41,7 +40,7 @@ type alias ResponseWithJson =

decodeResponseWithJson : Decoder ResponseWithJson
decodeResponseWithJson =
decode ResponseWithJson
succeed ResponseWithJson
|> required "json" decodeMessageBody

type alias QueryArgs =
Expand All @@ -50,7 +49,7 @@ type alias QueryArgs =

decodeQueryArgs : Decoder QueryArgs
decodeQueryArgs =
decode QueryArgs
succeed QueryArgs
|> required "q" string

type alias ResponseWithArgs =
Expand All @@ -59,7 +58,7 @@ type alias ResponseWithArgs =

decodeResponseWithArgs : Decoder ResponseWithArgs
decodeResponseWithArgs =
decode ResponseWithArgs
succeed ResponseWithArgs
|> required "args" decodeQueryArgs

getIp : Http.Request (Http.Response (Response))
Expand All @@ -78,10 +77,11 @@ getIp =
Http.emptyBody
, expect =
Http.expectStringResponse
(\response ->
Result.map
(\body -> { response | body = body })
(decodeString decodeResponse response.body))
(\res ->
Result.mapError Json.Decode.errorToString
(Result.map
(\body_ -> { url = res.url, status = res.status, headers = res.headers, body = body_ })
(decodeString decodeResponse res.body)))
, timeout =
Nothing
, withCredentials =
Expand All @@ -105,9 +105,9 @@ getStatus204 =
Http.emptyBody
, expect =
Http.expectStringResponse
(\response ->
if String.isEmpty response.body then
Ok { response | body = NoContent }
(\res ->
if String.isEmpty res.body then
Ok { url = res.url, status = res.status, headers = res.headers, body = NoContent }
else
Err "Expected the response body to be empty"
)
Expand All @@ -133,10 +133,11 @@ postPost body =
Http.jsonBody (encodeMessageBody body)
, expect =
Http.expectStringResponse
(\response ->
Result.map
(\body -> { response | body = body })
(decodeString decodeResponseWithJson response.body))
(\res ->
Result.mapError Json.Decode.errorToString
(Result.map
(\body_ -> { url = res.url, status = res.status, headers = res.headers, body = body_ })
(decodeString decodeResponseWithJson res.body)))
, timeout =
Nothing
, withCredentials =
Expand All @@ -149,7 +150,7 @@ getGet query_q =
params =
List.filter (not << String.isEmpty)
[ query_q
|> Maybe.map (Http.encodeUri >> (++) "q=")
|> Maybe.map (Url.percentEncode >> (++) "q=")
|> Maybe.withDefault ""
]
in
Expand All @@ -171,10 +172,11 @@ getGet query_q =
Http.emptyBody
, expect =
Http.expectStringResponse
(\response ->
Result.map
(\body -> { response | body = body })
(decodeString decodeResponseWithArgs response.body))
(\res ->
Result.mapError Json.Decode.errorToString
(Result.map
(\body_ -> { url = res.url, status = res.status, headers = res.headers, body = body_ })
(decodeString decodeResponseWithArgs res.body)))
, timeout =
Nothing
, withCredentials =
Expand All @@ -191,18 +193,19 @@ getByPath capture_path =
, url =
String.join "/"
[ "https://httpbin.org"
, capture_path |> Http.encodeUri
, capture_path |> Url.percentEncode
]
, body =
Http.emptyBody
, expect =
Http.expectStringResponse
(\response ->
Result.map
(\body -> { response | body = body })
(decodeString decodeResponse response.body))
(\res ->
Result.mapError Json.Decode.errorToString
(Result.map
(\body_ -> { url = res.url, status = res.status, headers = res.headers, body = body_ })
(decodeString decodeResponse res.body)))
, timeout =
Nothing
, withCredentials =
False
}
}
18 changes: 0 additions & 18 deletions examples/giphy/elm-package.json

This file was deleted.

Loading

0 comments on commit 575fb04

Please sign in to comment.