git.iko.soy/typeable/servant
on master help sign in
Make ComprehensiveAPI part of public API

We cannot simply tweak it, it will break tests of other packages. Including packages not in this repository.

commit7634e083526e61932416c6b1f8afb0454de1435b authorOleg Grenrus <oleg.grenrus@iki.fi> dateTue 6 Nov 2018, 13:32 (8 years ago) parent3f56b86
8 files changed+67−57
servant-client/test/Servant/ClientSpec.hs+1−1 servant-docs/test/Servant/DocsSpec.hs+1−1 servant-foreign/test/Servant/ForeignSpec.hs+1−1 servant-server/test/Servant/ServerSpec.hs+1−1 servant/servant.cabal+5−1 servant/src/Servant/API/Internal/Test/ComprehensiveAPI.hs+5−51 servant/src/Servant/Test/ComprehensiveAPI.hs+52 servant/test/Servant/LinksSpec.hs+1−1
servant-client/test/Servant/ClientSpec.hs+1−1
@@ -64,7 +64,7 @@ import Servant.API
6464 DeleteNoContent, EmptyAPI, FormUrlEncoded, Get, Header,
6565 Headers, JSON, NoContent (NoContent), Post, Put, QueryFlag,
6666 QueryParam, QueryParams, Raw, ReqBody, addHeader, getHeaders)
67−import Servant.API.Internal.Test.ComprehensiveAPI
67+import Servant.Test.ComprehensiveAPI
6868import Servant.Client
6969import qualified Servant.Client.Core.Internal.Auth as Auth
7070import qualified Servant.Client.Core.Internal.Request as Req
servant-docs/test/Servant/DocsSpec.hs+1−1
@@ -21,7 +21,7 @@ import GHC.Generics
2121import Test.Hspec
2222
2323import Servant.API
24−import Servant.API.Internal.Test.ComprehensiveAPI
24+import Servant.Test.ComprehensiveAPI
2525import Servant.Docs.Internal
2626
2727-- * comprehensive api
servant-foreign/test/Servant/ForeignSpec.hs+1−1
@@ -14,7 +14,7 @@ module Servant.ForeignSpec where
1414import Data.Monoid
1515 ((<>))
1616import Data.Proxy
17−import Servant.API.Internal.Test.ComprehensiveAPI
17+import Servant.Test.ComprehensiveAPI
1818import Servant.Foreign
1919import Servant.Types.SourceT
2020 (SourceT)
servant-server/test/Servant/ServerSpec.hs+1−1
@@ -51,7 +51,7 @@ import Servant.API
5151 PlainText, Post, Put, QueryFlag, QueryParam, QueryParams, Raw,
5252 RemoteHost, ReqBody, StdMethod (..), Stream,
5353 SourceIO, Verb, addHeader)
54−import Servant.API.Internal.Test.ComprehensiveAPI
54+import Servant.Test.ComprehensiveAPI
5555import Servant.Server
5656 (Context ((:.), EmptyContext), Handler, Server, Tagged (..),
5757 emptyServer, err401, err403, err404, serve, serveWithContext)
servant/servant.cabal+5−1
@@ -48,7 +48,6 @@ library
4848 Servant.API.Generic
4949 Servant.API.Header
5050 Servant.API.HttpVersion
51− Servant.API.Internal.Test.ComprehensiveAPI
5251 Servant.API.IsSecure
5352 Servant.API.Modifiers
5453 Servant.API.QueryParam
@@ -67,6 +66,10 @@ library
6766 exposed-modules:
6867 Servant.Types.SourceT
6968
69+ -- Test stuff
70+ exposed-modules:
71+ Servant.Test.ComprehensiveAPI
72+
7073 -- Safe links
7174 exposed-modules:
7275 Servant.Links
@@ -74,6 +77,7 @@ library
7477 -- Deprecated modules, to be removed in late 2019
7578 exposed-modules:
7679 Servant.Utils.Links
80+ Servant.API.Internal.Test.ComprehensiveAPI
7781
7882 -- Bundled with GHC: Lower bound to not force re-installs
7983 -- text and mtl are bundled starting with GHC-8.4
servant/src/Servant/API/Internal/Test/ComprehensiveAPI.hs+5−51
@@ -1,52 +1,6 @@
1−{-# LANGUAGE DataKinds #-}
2−{-# LANGUAGE TypeOperators #-}
1+module Servant.API.Internal.Test.ComprehensiveAPI
2+ {-# DEPRECATED "Use Servant.TestComprehensiveAPI" #-}
3+ ( module Servant.Test.ComprehensiveAPI )
4+ where
35
4−-- | This is a module containing an API with all `Servant.API` combinators. It
5−-- is used for testing only (in particular, checking that instances exist for
6−-- the core servant classes for each combinator), and should not be imported.
7−module Servant.API.Internal.Test.ComprehensiveAPI where
8−
9−import Data.Proxy
10− (Proxy (..))
11−import Servant.API
12−import Servant.Types.SourceT
13− (SourceT)
14−
15−type GET = Get '[JSON] NoContent
16−
17−type ComprehensiveAPI =
18− ComprehensiveAPIWithoutRaw :<|>
19− Raw
20−
21−comprehensiveAPI :: Proxy ComprehensiveAPI
22−comprehensiveAPI = Proxy
23−
24−type ComprehensiveAPIWithoutRaw =
25− GET :<|>
26− Get '[JSON] Int :<|>
27− Capture' '[Description "example description"] "foo" Int :> GET :<|>
28− Header "foo" Int :> GET :<|>
29− Header' '[Required, Lenient] "bar" Int :> GET :<|>
30− HttpVersion :> GET :<|>
31− IsSecure :> GET :<|>
32− QueryParam "foo" Int :> GET :<|>
33− QueryParam' '[Required, Lenient] "bar" Int :> GET :<|>
34− QueryParams "foo" Int :> GET :<|>
35− QueryFlag "foo" :> GET :<|>
36− RemoteHost :> GET :<|>
37− ReqBody '[JSON] Int :> GET :<|>
38− ReqBody' '[Lenient] '[JSON] Int :> GET :<|>
39− Get '[JSON] (Headers '[Header "foo" Int] NoContent) :<|>
40− "foo" :> GET :<|>
41− Vault :> GET :<|>
42− Verb 'POST 204 '[JSON] NoContent :<|>
43− Verb 'POST 204 '[JSON] Int :<|>
44− StreamBody NetstringFraming JSON (SourceT IO Int) :> Stream 'GET 200 NetstringFraming JSON (SourceT IO Int) :<|>
45− WithNamedContext "foo" '[] GET :<|>
46− CaptureAll "foo" Int :> GET :<|>
47− Summary "foo" :> GET :<|>
48− Description "foo" :> GET :<|>
49− EmptyAPI
50−
51−comprehensiveAPIWithoutRaw :: Proxy ComprehensiveAPIWithoutRaw
52−comprehensiveAPIWithoutRaw = Proxy
6+import Servant.Test.ComprehensiveAPI
servant/src/Servant/Test/ComprehensiveAPI.hsnew file+52
@@ -0,0 +1,52 @@
1+{-# LANGUAGE DataKinds #-}
2+{-# LANGUAGE TypeOperators #-}
3+
4+-- | This is a module containing an API with all `Servant.API` combinators. It
5+-- is used for testing only (in particular, checking that instances exist for
6+-- the core servant classes for each combinator).
7+module Servant.Test.ComprehensiveAPI where
8+
9+import Data.Proxy
10+ (Proxy (..))
11+import Servant.API
12+import Servant.Types.SourceT
13+ (SourceT)
14+
15+type GET = Get '[JSON] NoContent
16+
17+type ComprehensiveAPI =
18+ ComprehensiveAPIWithoutRaw :<|>
19+ Raw
20+
21+comprehensiveAPI :: Proxy ComprehensiveAPI
22+comprehensiveAPI = Proxy
23+
24+type ComprehensiveAPIWithoutRaw =
25+ GET :<|>
26+ Get '[JSON] Int :<|>
27+ Capture' '[Description "example description"] "foo" Int :> GET :<|>
28+ Header "foo" Int :> GET :<|>
29+ Header' '[Required, Lenient] "bar" Int :> GET :<|>
30+ HttpVersion :> GET :<|>
31+ IsSecure :> GET :<|>
32+ QueryParam "foo" Int :> GET :<|>
33+ QueryParam' '[Required, Lenient] "bar" Int :> GET :<|>
34+ QueryParams "foo" Int :> GET :<|>
35+ QueryFlag "foo" :> GET :<|>
36+ RemoteHost :> GET :<|>
37+ ReqBody '[JSON] Int :> GET :<|>
38+ ReqBody' '[Lenient] '[JSON] Int :> GET :<|>
39+ Get '[JSON] (Headers '[Header "foo" Int] NoContent) :<|>
40+ "foo" :> GET :<|>
41+ Vault :> GET :<|>
42+ Verb 'POST 204 '[JSON] NoContent :<|>
43+ Verb 'POST 204 '[JSON] Int :<|>
44+ StreamBody NetstringFraming JSON (SourceT IO Int) :> Stream 'GET 200 NetstringFraming JSON (SourceT IO Int) :<|>
45+ WithNamedContext "foo" '[] GET :<|>
46+ CaptureAll "foo" Int :> GET :<|>
47+ Summary "foo" :> GET :<|>
48+ Description "foo" :> GET :<|>
49+ EmptyAPI
50+
51+comprehensiveAPIWithoutRaw :: Proxy ComprehensiveAPIWithoutRaw
52+comprehensiveAPIWithoutRaw = Proxy
servant/test/Servant/LinksSpec.hs+1−1
@@ -13,7 +13,7 @@ import Test.Hspec
1313 (Expectation, Spec, describe, it, shouldBe)
1414
1515import Servant.API
16−import Servant.API.Internal.Test.ComprehensiveAPI
16+import Servant.Test.ComprehensiveAPI
1717 (comprehensiveAPIWithoutRaw)
1818import Servant.Links
1919