packages feed

rest-gen 0.13.1.1 → 0.13.1.2

raw patch · 3 files changed

+18/−11 lines, 3 filesdep ~json-schemaPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: json-schema

API changes (from Hackage documentation)

Files

CHANGELOG.md view
@@ -1,5 +1,9 @@ # Changelog +#### 0.13.1.2++* Use `json-schema 0.5.*` and add `showExample` cases for `Map` and `Any`+ #### 0.13.1.1  * Allow `attoparsec 0.12.*`
rest-gen.cabal view
@@ -1,5 +1,5 @@ name:                rest-gen-version:             0.13.1.1+version:             0.13.1.2 description:         Documentation and client generation from rest definition. synopsis:            Documentation and client generation from rest definition. maintainer:          code@silk.co@@ -65,7 +65,7 @@     , hashable >= 1.1 && < 1.3     , hslogger >= 1.1 && < 1.3     , hxt >= 9.2 && < 9.4-    , json-schema == 0.4.*+    , json-schema == 0.5.*     , mtl >= 2.0 && < 2.3     , pretty >= 1.0 && < 1.2     , process >= 1.0 && < 1.3
src/Rest/Gen/Base/JSON.hs view
@@ -13,12 +13,15 @@ showExample :: Schema -> String showExample = render . pp_value . showExample'   where-    showExample' (Choice [])     = A.Null -- Cannot create zero value-    showExample' (Choice (x:_))  = showExample' x-    showExample' (Object fs)     = A.object $ map (\f -> pack (key f) .= showExample' (content f)) fs-    showExample' (Tuple vs)      = A.Array $ V.fromList $ map showExample' vs-    showExample' (Array l _ _ v) = A.Array $ V.fromList $ replicate (l `max` 1) (showExample' v)-    showExample' (Value _ _)     = A.String "value"-    showExample' Boolean         = A.Bool True-    showExample' (Number l _)    = A.Number (fromIntegral l)-    showExample' Null            = A.Null+    showExample' s = case s of+      Choice []     -> A.Null -- Cannot create zero value+      Choice (x:_)  -> showExample' x+      Object fs     -> A.object $ map (\f -> pack (key f) .= showExample' (content f)) fs+      Map v         -> A.object ["<key>" .= showExample' v]+      Tuple vs      -> A.Array $ V.fromList $ map showExample' vs+      Array l _ _ v -> A.Array $ V.fromList $ replicate (l `max` 1) (showExample' v)+      Value _ _     -> A.String "value"+      Boolean       -> A.Bool True+      Number l _    -> A.Number (fromIntegral l)+      Null          -> A.Null+      Any           -> A.String "<value>"