json-spec-elm-servant 0.4.1.2 → 0.4.2.0
raw patch · 3 files changed
+20/−3 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Data.JsonSpec.Elm.Servant: Ignore :: Param
+ Data.JsonSpec.Elm.Servant: instance forall k (a :: k). Data.JsonSpec.Elm.Servant.IsParam a
Files
- json-spec-elm-servant.cabal +1/−1
- src/Data/JsonSpec/Elm/Servant.hs +16/−1
- test/Api.hs +3/−1
json-spec-elm-servant.cabal view
@@ -1,6 +1,6 @@ cabal-version: 3.0 name: json-spec-elm-servant-version: 0.4.1.2+version: 0.4.2.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
src/Data/JsonSpec/Elm/Servant.hs view
@@ -25,7 +25,8 @@ The symbols in this section are mainly exposed in case you are using some extensions to the standard servant types and need to build some companion extensions to generate proper Elm types for them. For most- normal usage you will probably just use 'servantDefs'.+ normal usage you will probably just use 'generateElm' (or possibly+ 'servantDefs'). -} Elmable(..), IsParam(..),@@ -314,6 +315,16 @@ -} class IsParam a where param :: Definitions Param+{-|+ The default instance assumes that the API combinator does not contribute+ to the parameter list or the "name of the endpoint" in any way. This+ covers things like 'Summary' and 'Description', or potentially custom+ combinators created by the user. In the case of custom combinators,+ you may need to create an overlapping instance if you wish it to affect+ the elm function parameters or function name.+-}+instance {-# OVERLAPPABLE #-} IsParam a where+ param = pure Ignore instance (KnownSymbol name) => IsParam (Capture name tpy) where param = pure $ PathParam (Capture (sym @name)) instance (KnownSymbol name) => IsParam (Header' (Optional : mods) name a) where@@ -429,6 +440,7 @@ HeaderParam (OptionalHeader _) -> Just ("Basics.Maybe" `Type.App` "Basics.String") BodyEncoder typ _ -> Just typ+ Ignore -> Nothing ) params )@@ -535,6 +547,8 @@ (Bound.closed e) (PathParam (Static _) : more) e -> buildLambda more e+ (Ignore : more) e ->+ buildLambda more e (p : more) e -> buildLambda more@@ -549,6 +563,7 @@ { elmType :: Type Void , encoder :: Expression Void }+ | Ignore {-^ This is for things like `Summary` -} deriving stock (Eq)
test/Api.hs view
@@ -72,7 +72,8 @@ ( FromHttpApiData(parseHeader, parseQueryParam), GenericMode((:-)) , StdMethod(GET), (:>), Capture, DeleteNoContent, Get, Header, Header' , Headers, JSON, NamedRoutes, NoContent, Optional, Post, PostNoContent- , QueryParam', ReqBody, ReqBody', Required, Strict, ToHttpApiData, Verb+ , QueryParam', ReqBody, ReqBody', Required, Strict, Summary, ToHttpApiData+ , Verb ) import Web.Cookie (SetCookie) import qualified Data.JsonSpec as Spec@@ -100,6 +101,7 @@ data ProtectedApi mode = ProtectedApi { makeProposal :: mode :- "proposal"+ :> Summary "a summary" :> ReqBody' '[Required, Strict] '[JSON] NewProposalReq :> Post '[JSON] (KV ProposalId Proposal)