packages feed

servant-kotlin 0.1.0.3 → 0.1.1.0

raw patch · 4 files changed

+31/−17 lines, 4 filesdep ~lensdep ~servantPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: lens, servant

API changes (from Hackage documentation)

Files

servant-kotlin.cabal view
@@ -2,10 +2,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: f0ac27ee120fcace4bd3cf882a3683d2313aa7c98f6ae13a0ac54538c89c53a4+-- hash: 72d6da8fcfbeeb254805cbaf73c72da019a8ab6a31d9b651dd95eaadb6be1443  name:           servant-kotlin-version:        0.1.0.3+version:        0.1.1.0 synopsis:       Automatically derive Kotlin class to query servant webservices description:    See README at <https://github.com/matsubara0507/servant-kotlin#readme> category:       Web@@ -24,24 +24,26 @@ library   hs-source-dirs:       src-  ghc-options: -Wall -fno-warn-orphans+  ghc-options: -Wall   build-depends:       base >=4.7 && <5     , containers >=0.5.7 && <0.6.0     , directory >=1.3 && <1.4     , formatting >=6.2 && <6.4-    , lens >=4.15 && <4.16-    , servant >=0.9 && <0.13+    , lens >=4.15 && <4.17+    , servant >=0.9 && <0.14     , servant-foreign >=0.9 && <0.12     , text >=1.2 && <1.3     , time >=1.6 && <1.9     , wl-pprint-text >=1.1 && <1.2   exposed-modules:       Servant.Kotlin-      Servant.Kotlin.Type       Servant.Kotlin.Internal.File       Servant.Kotlin.Internal.Foreign       Servant.Kotlin.Internal.Generate+      Servant.Kotlin.Type+  other-modules:+      Paths_servant_kotlin   default-language: Haskell2010  test-suite spec@@ -59,8 +61,8 @@     , formatting >=6.2 && <6.4     , hspec >=2.4.1 && <2.5     , http-api-data >=0.3.7 && <0.3.8-    , lens >=4.15 && <4.16-    , servant >=0.9 && <0.13+    , lens >=4.15 && <4.17+    , servant >=0.9 && <0.14     , servant-foreign >=0.9 && <0.12     , text >=1.2 && <1.3     , time >=1.6 && <1.9@@ -87,8 +89,8 @@     , directory >=1.3 && <1.4     , formatting >=6.2 && <6.4     , http-api-data >=0.3.7 && <0.3.8-    , lens >=4.15 && <4.16-    , servant >=0.9 && <0.13+    , lens >=4.15 && <4.17+    , servant >=0.9 && <0.14     , servant-foreign >=0.9 && <0.12     , servant-kotlin     , shelly >=1.6.8 && <1.8
src/Servant/Kotlin/Internal/Generate.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP                   #-}
 {-# LANGUAGE FlexibleContexts      #-}
 {-# LANGUAGE MultiParamTypeClasses #-}
 {-# LANGUAGE OverloadedStrings     #-}
@@ -15,8 +16,6 @@     , UrlPrefix (..)
     ) where
 
-import           Prelude                         hiding ((<$>))
-
 import           Control.Lens                    (to, (^.))
 import           Data.List                       (nub)
 import           Data.Maybe                      (catMaybes, fromMaybe)
@@ -228,8 +227,15 @@     . to (stext . T.replace "-" "_" . F.unPathSegment)
 
 kotlinHeaderType :: F.HeaderArg KotlinClass -> Doc
+#if MIN_VERSION_servant_foreign(0,11,0)
 kotlinHeaderType header =
   header ^. F.headerArg . F.argType . to kotlinTypeRef
+#else
+kotlinHeaderType header =
+  header ^. F.headerArg . F.argType . to (kotlinTypeRef . wrapper)
+  where
+    wrapper = PrimitiveClass . KNullable
+#endif
 
 kotlinCaptureArg :: F.Segment KotlinClass -> Doc
 kotlinCaptureArg segment = "capture_" <>
@@ -244,12 +250,17 @@   arg ^. F.queryArgName . F.argName . to (stext . F.unPathSegment)
 
 kotlinQueryType :: F.QueryArg KotlinClass -> Doc
+#if MIN_VERSION_servant_foreign(0,11,0)
 kotlinQueryType arg =
+  arg ^. F.queryArgName . F.argType . to kotlinTypeRef
+#else
+kotlinQueryType arg =
   arg ^. F.queryArgName . F.argType . to (kotlinTypeRef . wrapper)
   where
     wrapper = case arg ^. F.queryArgType of
       F.Normal -> PrimitiveClass . KNullable
-      _        ->  id
+      _        -> id
+#endif
 
 kotlinBodyArg :: Doc
 kotlinBodyArg = "body"
test/Servant/Kotlin/Internal/GenerateSpec.hs view
@@ -7,6 +7,7 @@ module Servant.Kotlin.Internal.GenerateSpec
     ( main
     , spec
+    , Todo (..)
     ) where
 
 import           Data.Proxy                       (Proxy (Proxy))
@@ -15,8 +16,8 @@ import           GHC.Generics                     (Generic)
 import           Servant.Kotlin.Internal.Generate
 import           Servant.Kotlin.Type
-import           Test.Hspec                       (Spec, context, describe,
-                                                   hspec, it, shouldBe)
+import           Test.Hspec                       (Spec, describe, hspec, it,
+                                                   shouldBe)
 import           Test.TestAPI
 
 data Todo = Todo
@@ -131,7 +132,7 @@             , "}"
             ]
         , T.intercalate "\n"
-            [ "fun getWithaheader(header_myTextHeader: String, header_MyIntHeader: Int, handler: (Request, Response, Result<String, FuelError>) -> Unit) {"
+            [ "fun getWithaheader(header_myTextHeader: String?, header_MyIntHeader: Int?, handler: (Request, Response, Result<String, FuelError>) -> Unit) {"
             , "    Fuel.get(\"/\" + \"with-a-header\")"
             , "        .responseObject(handler)"
             , "}"
test/Test/TestAPI.hs view
@@ -15,7 +15,7 @@                                       QueryParams, ReqBody)
 import           Servant.Kotlin.Type (KotlinType)
 
-data Book = Book
+newtype Book = Book
     { title :: Text
     } deriving (Generic, KotlinType, Show, Eq)