rest-gen 0.19.0.1 → 0.19.0.2
raw patch · 5 files changed
+49/−49 lines, 5 filesdep +base-compatdep ~Cabaldep ~aesondep ~base
Dependencies added: base-compat
Dependency ranges changed: Cabal, aeson, base, process, rest-core
Files
- CHANGELOG.md +4/−0
- rest-gen.cabal +4/−3
- src/Rest/Gen/Base/ActionInfo.hs +37/−33
- src/Rest/Gen/Config.hs +3/−3
- src/Rest/Gen/Docs.hs +1/−10
CHANGELOG.md view
@@ -1,5 +1,9 @@ # Changelog +#### 0.19.0.2++* Upgrade to `rest-core 0.38` to add support for `RawJson(AndXml)(I/O)`.+ #### 0.19.0.1 * Allow `haskell-src-exts 1.17.*`.
rest-gen.cabal view
@@ -1,5 +1,5 @@ name: rest-gen-version: 0.19.0.1+version: 0.19.0.2 description: Documentation and client generation from rest definition. synopsis: Documentation and client generation from rest definition. maintainer: code@silk.co@@ -52,6 +52,7 @@ , Cabal >= 1.16 && < 1.23 , HStringTemplate >= 0.6 && < 0.9 , aeson >= 0.7 && < 0.11+ , base-compat >= 0.8 && < 0.10 , blaze-html >= 0.5 && < 0.9 , code-builder == 0.1.* , directory >= 1.1 && < 1.3@@ -63,7 +64,7 @@ , json-schema >= 0.6 && < 0.8 , pretty >= 1.0 && < 1.2 , process >= 1.0 && < 1.4- , rest-core >= 0.35 && < 0.38+ , rest-core >= 0.38 && < 0.39 , safe >= 0.2 && < 0.4 , semigroups >= 0.5 && < 0.19 , scientific >= 0.3.2 && < 0.4@@ -85,7 +86,7 @@ , HUnit >= 1.2 && < 1.4 , fclabels >= 1.0.4 && < 2.1 , haskell-src-exts >= 1.15.0 && < 1.18- , rest-core >= 0.35 && < 0.38+ , rest-core >= 0.38 && < 0.39 , rest-gen , test-framework == 0.8.* , test-framework-hunit == 0.3.*
src/Rest/Gen/Base/ActionInfo.hs view
@@ -1,9 +1,7 @@ {-# LANGUAGE- DataKinds- , GADTs- , KindSignatures+ GADTs , LambdaCase- , NoMonomorphismRestriction+ , NoImplicitPrelude , ScopedTypeVariables , TemplateHaskell #-}@@ -47,21 +45,19 @@ , singleActionInfo ) where -import Prelude hiding (id, (.))+import Prelude.Compat hiding (id, (.)) -import Control.Applicative import Control.Category import Control.Monad-import Data.Foldable (foldMap)+import Data.Foldable (find) import Data.Label.Derive-import Data.List+import Data.List (intercalate, intersect, nub, sortBy) import Data.List.NonEmpty (NonEmpty) import Data.Maybe import Data.Ord import Data.Proxy import Data.Typeable import Safe-import qualified Data.Foldable as F import qualified Data.JSON.Schema as J import qualified Data.Label.Total as L import qualified Data.List.NonEmpty as NList@@ -160,7 +156,7 @@ } chooseType :: NonEmpty DataDescription -> DataDescription-chooseType ls = fromMaybe (NList.head ls) $ F.find ((JSON ==) . L.get (dataType . desc)) ls+chooseType ls = fromMaybe (NList.head ls) $ find ((JSON ==) . L.get (dataType . desc)) ls data ResponseType = ResponseType { errorType :: Maybe DataDesc@@ -430,19 +426,23 @@ where handlerInput :: Proxy i -> Input i -> DataDescription handlerInput d c = case c of- ReadI -> L.set (haskellModules . desc) (modString d)- $ defaultDescription Other (describe d) (toHaskellType d)- StringI -> defaultDescription String "String" haskellStringType- XmlI -> L.set (haskellModules . desc) (modString d)- . L.set (dataSchema . meta) (pure . X.showSchema . X.getXmlSchema $ d)- . L.set (dataExample . meta) (pure . X.showExample . X.getXmlSchema $ d)- $ defaultDescription XML "XML" (toHaskellType d)- XmlTextI -> defaultDescription XML "XML" haskellStringType- RawXmlI -> defaultDescription XML "XML" haskellStringType- JsonI -> L.set (haskellModules . desc) (modString d)- . L.set (dataExample . meta) (J.showExamples . J.schema $ d)- $ defaultDescription JSON "JSON" (toHaskellType d)- FileI -> defaultDescription File "File" haskellByteStringType+ ReadI -> L.set (haskellModules . desc) (modString d)+ $ defaultDescription Other (describe d) (toHaskellType d)+ StringI -> defaultDescription String "String" haskellStringType+ XmlI -> L.set (haskellModules . desc) (modString d)+ . L.set (dataSchema . meta) (pure . X.showSchema . X.getXmlSchema $ d)+ . L.set (dataExample . meta) (pure . X.showExample . X.getXmlSchema $ d)+ $ defaultDescription XML "XML" (toHaskellType d)+ XmlTextI -> defaultDescription XML "XML" haskellStringType+ RawXmlI -> defaultDescription XML "XML" haskellStringType+ JsonI -> L.set (haskellModules . desc) (modString d)+ . L.set (dataExample . meta) (J.showExamples . J.schema $ d)+ $ defaultDescription JSON "JSON" (toHaskellType d)+ RawJsonI -> defaultDescription JSON "JSON" haskellStringType+ -- Picking JSON or XML is arbitrary here since both are possible+ -- so we stick with the convention of preferring JSON.+ RawJsonAndXmlI -> defaultDescription File "File" haskellByteStringType+ FileI -> defaultDescription File "File" haskellByteStringType -- | Extract output description from handlers handlerOutputs :: Handler m -> [DataDescription]@@ -450,16 +450,20 @@ where handlerOutput :: Proxy a -> Output a -> DataDescription handlerOutput d c = case c of- StringO -> defaultDescription String "String" haskellStringType- XmlO -> L.set (haskellModules . desc) (modString d)- . L.set (dataSchema . meta) (pure . X.showSchema . X.getXmlSchema $ d)- . L.set (dataExample . meta) (pure . X.showExample . X.getXmlSchema $ d)- $ defaultDescription XML "XML" (toHaskellType d)- RawXmlO -> defaultDescription XML "XML" haskellStringType- JsonO -> L.set (haskellModules . desc) (modString d)- . L.set (dataExample . meta) (J.showExamples . J.schema $ d)- $ defaultDescription JSON "JSON" (toHaskellType d)- FileO -> defaultDescription File "File" haskellByteStringType+ StringO -> defaultDescription String "String" haskellStringType+ XmlO -> L.set (haskellModules . desc) (modString d)+ . L.set (dataSchema . meta) (pure . X.showSchema . X.getXmlSchema $ d)+ . L.set (dataExample . meta) (pure . X.showExample . X.getXmlSchema $ d)+ $ defaultDescription XML "XML" (toHaskellType d)+ RawXmlO -> defaultDescription XML "XML" haskellStringType+ JsonO -> L.set (haskellModules . desc) (modString d)+ . L.set (dataExample . meta) (J.showExamples . J.schema $ d)+ $ defaultDescription JSON "JSON" (toHaskellType d)+ RawJsonO -> defaultDescription JSON "JSON" haskellStringType+ -- Picking JSON or XML is arbitrary here since both are possible+ -- so we stick with the convention of preferring JSON.+ RawJsonAndXmlO -> defaultDescription File "File" haskellStringType+ FileO -> defaultDescription File "File" haskellByteStringType -- | Extract input description from handlers handlerErrors :: Handler m -> [DataDescription]
src/Rest/Gen/Config.hs view
@@ -1,5 +1,6 @@ {-# LANGUAGE- TemplateHaskell+ NoImplicitPrelude+ , TemplateHaskell , TypeOperators #-} module Rest.Gen.Config@@ -19,9 +20,8 @@ , configFromArgs ) where -import Prelude hiding (id, (.))+import Prelude.Compat hiding (id, (.)) -import Control.Applicative import Control.Category import Data.Label import System.Console.GetOpt
src/Rest/Gen/Docs.hs view
@@ -1,13 +1,4 @@-{-# LANGUAGE- EmptyDataDecls- , GADTs- , MultiParamTypeClasses- , OverlappingInstances- , ScopedTypeVariables- , TemplateHaskell- , TupleSections- , TypeFamilies- #-}+{-# LANGUAGE TupleSections #-} module Rest.Gen.Docs ( DocsContext (..) , cdiv