json-spec-elm-servant 0.5.1.0 → 0.6.0.0
raw patch · 4 files changed
+17/−23 lines, 4 filesdep ~json-specdep ~json-spec-elmPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: json-spec, json-spec-elm
API changes (from Hackage documentation)
Files
- changelog.md +6/−0
- json-spec-elm-servant.cabal +3/−3
- src/Data/JsonSpec/Elm/Servant.hs +5/−8
- test/Api.hs +3/−12
changelog.md view
@@ -1,5 +1,11 @@ # Changelog +## 0.6.0.0++- Require `json-spec` >= 1.4 and `json-spec-elm` >= 0.6, which provide+ `JsonDict` support (Elm `Dict String a`) via `json-spec-elm`.+- The test API now exercises `JsonDict` in `DashboardData`.+ ## 0.5.1.0 - Improved Elm generator output.
json-spec-elm-servant.cabal view
@@ -1,6 +1,6 @@ cabal-version: 3.0 name: json-spec-elm-servant-version: 0.5.1.0+version: 0.6.0.0 synopsis: Generated elm code for servant APIs. description: Generate Elm encoders, decoders, and API requests for an Servant API, where the shape of the data@@ -31,8 +31,8 @@ , elm-syntax >= 0.3.3.0 && < 0.4 , filepath >= 1.4.200.1 && < 1.6 , http-types >= 0.12.3 && < 0.13- , json-spec >= 1.3.0.0 && < 1.4- , json-spec-elm >= 0.5.0.1 && < 0.6+ , json-spec >= 1.4.0.0 && < 1.5+ , json-spec-elm >= 0.6.0.0 && < 0.7 , mtl >= 2.3.1 && < 2.4 , prettyprinter >= 1.7.1 && < 1.8 , process >= 1.6.18.0 && < 1.7
src/Data/JsonSpec/Elm/Servant.hs view
@@ -37,10 +37,9 @@ QP(..), ) where - import Bound (Var(B, F), Scope, abstract1, closed, toScope) import Control.Monad.Writer (MonadTrans(lift), MonadWriter(tell), execWriter)-import Data.Foldable (Foldable(fold), foldl', traverse_)+import Data.Foldable (Foldable(fold, foldl'), traverse_) import Data.HashMap.Strict (HashMap) import Data.JsonSpec ( HasJsonDecodingSpec(DecodingSpec), HasJsonEncodingSpec(EncodingSpec)@@ -60,11 +59,10 @@ import Language.Elm.Type (Type) import Network.HTTP.Types (Method) import Prelude- ( Applicative(pure), Bool(False, True), Eq((==))- , Foldable(foldr, length), Functor(fmap), Maybe(Just, Nothing)- , Monad((>>=)), Monoid(mconcat, mempty), Semigroup((<>))- , Traversable(sequence, traverse), ($), (.), (<$>), IO, Int, String, drop- , error, init, putStrLn, reverse, unlines+ ( Applicative(pure), Bool(False, True), Eq((==)), Foldable(foldr, length)+ , Functor(fmap), Maybe(Just, Nothing), Monad((>>=)), Monoid(mconcat, mempty)+ , Semigroup((<>)), Traversable(sequence, traverse), ($), (.), (<$>), IO, Int+ , String, drop, error, init, putStrLn, reverse, unlines ) import Prettyprinter (defaultLayoutOptions, layoutPretty) import Prettyprinter.Render.Text (renderStrict)@@ -89,7 +87,6 @@ import qualified Language.Elm.Pattern as Pat import qualified Language.Elm.Type as Type import qualified System.OsPath as OsPath- {-| This function will traverse the @api@ type, generating elm definitions for:
test/Api.hs view
@@ -46,7 +46,6 @@ FEConfig(..), ) where - import Data.Aeson (FromJSON, FromJSONKey, ToJSON, ToJSONKey) import Data.Binary (Binary) import Data.ByteString (ByteString)@@ -54,8 +53,8 @@ ( Field(Field), HasJsonDecodingSpec(DecodingSpec, fromJSONStructure) , HasJsonEncodingSpec(EncodingSpec, toJSONStructure), SpecJSON(SpecJSON) , Specification- ( JsonArray, JsonDateTime, JsonEither, JsonInt, JsonLet, JsonObject, JsonRef- , JsonString, JsonTag+ ( JsonArray, JsonDateTime, JsonDict, JsonEither, JsonInt, JsonLet+ , JsonObject, JsonRef, JsonString, JsonTag ) ) import Data.Map (Map)@@ -78,7 +77,6 @@ import Web.Cookie (SetCookie) import qualified Data.JsonSpec as Spec - data Api mode = Api { protectedApi :: mode :- "api"@@ -193,14 +191,7 @@ JsonLet '[ '("DashboardData" , JsonObject- '[ "proposals" :::- JsonArray- (- JsonObject- '[ "key" ::: EncodingSpec ProposalId- , "value" ::: EncodingSpec Proposal- ]- )+ '[ "proposals" ::: JsonDict (EncodingSpec Proposal) , "credits" ::: EncodingSpec AvailableCredits , "user" ::: EncodingSpec DiscordUser ]