Browse Source

Fix to make it work with the current unerleased servant 0.5 version

master
parent
commit
982cab1bf6
  1. 3
      example/File.hs
  2. 11
      example/Server.hs
  3. 5
      example/example.cabal
  4. 2
      servant-swagger.cabal
  5. 13
      stack.yaml

3
example/File.hs

@ -13,6 +13,7 @@ import Data.Swagger
import GHC.Generics
import Servant
import Servant.Swagger
import Web.HttpApiData
-- Types
data Todo = Todo
@ -22,7 +23,7 @@ data Todo = Todo
instance ToJSON Todo
newtype TodoId = TodoId String deriving (FromText, Generic)
newtype TodoId = TodoId String deriving (Generic,FromHttpApiData)
-- API
type API = "todo" :> Capture "id" TodoId :> Get '[JSON] Todo

11
example/Server.hs

@ -6,7 +6,7 @@
module Main where
import Control.Lens
import Control.Monad.Trans.Either
import Control.Monad.Trans.Except
import Data.Aeson
import qualified Data.ByteString.Lazy.Char8 as BL8
import Data.Proxy
@ -15,6 +15,7 @@ import GHC.Generics
import Network.Wai.Handler.Warp
import Servant
import Servant.Swagger
import Web.HttpApiData
-- Test API
type TodoAPI
@ -43,9 +44,9 @@ data Todo = Todo { created :: Int, description :: String }
instance ToJSON Todo
instance FromJSON Todo
newtype TodoId = TodoId String deriving (FromText, Generic)
newtype TodoCount = TodoCount Int deriving (FromText, Generic)
newtype Completed = Completed Bool deriving (FromText, Generic)
newtype TodoId = TodoId String deriving (Generic,FromHttpApiData)
newtype TodoCount = TodoCount Int deriving (Generic,FromHttpApiData)
newtype Completed = Completed Bool deriving (Generic,FromHttpApiData)
api :: Proxy TodoAPI
api = Proxy
@ -60,7 +61,7 @@ main = do
undefined :<|> undefined :<|> undefined
undefined :<|> undefined
swagHandler :: EitherT ServantErr IO Swagger
swagHandler :: ExceptT ServantErr IO Swagger
swagHandler = pure $ toSwagger api
& info.infoTitle .~ "Todo API"
& info.infoVersion .~ "1.0"

5
example/example.cabal

@ -17,7 +17,7 @@ executable swagger-server
base
, aeson
, bytestring == 0.10.*
, servant
, servant >= 0.5
, either
, servant-server
, servant-swagger
@ -25,6 +25,8 @@ executable swagger-server
, lens
, wai
, warp
, transformers
, http-api-data
default-language: Haskell2010
executable swagger-file
@ -39,4 +41,5 @@ executable swagger-file
, servant-server
, servant-swagger
, lens
, http-api-data
default-language: Haskell2010

2
servant-swagger.cabal

@ -32,7 +32,7 @@ library
, bytestring
, http-media
, lens
, servant
, servant >= 0.5
, swagger2
, text
, unordered-containers

13
stack.yaml

@ -7,10 +7,23 @@ resolver: lts-3.11
packages:
- '.'
- example/
- '../servant/servant/'
- '../servant/servant-blaze/'
- '../servant/servant-cassava/'
- '../servant/servant-client/'
- '../servant/servant-docs/'
- '../servant/servant-examples/'
- '../servant/servant-foreign/'
- '../servant/servant-js/'
- '../servant/servant-lucid/'
- '../servant/servant-mock/'
- '../servant/servant-server/'
# Packages to be pulled from upstream that are not in the resolver (e.g., acme-missiles-0.3)
extra-deps:
- swagger2-1.1.1
- control-monad-omega-0.3.1
- engine-io-wai-1.0.5
# Override default flag values for local packages and extra-deps
flags: {}

Loading…
Cancel
Save