autodocodec-schema 0.1.0.0 → 0.1.0.1
raw patch · 3 files changed
+13/−6 lines, 3 files
Files
- CHANGELOG.md +6/−0
- autodocodec-schema.cabal +2/−2
- src/Autodocodec/Schema.hs +5/−4
CHANGELOG.md view
@@ -1,5 +1,11 @@ # Changelog +## [0.1.0.1] - 2022-04-26++### Added++* Compatibility with `aeson >= 2.0.0.0`+ ## [0.1.0.0] - 2021-12-21 ### Added
autodocodec-schema.cabal view
@@ -1,11 +1,11 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.34.5.+-- This file has been generated from package.yaml by hpack version 0.34.7. -- -- see: https://github.com/sol/hpack name: autodocodec-schema-version: 0.1.0.0+version: 0.1.0.1 synopsis: Autodocodec interpreters for JSON Schema homepage: https://github.com/NorfairKing/autodocodec#readme bug-reports: https://github.com/NorfairKing/autodocodec/issues
src/Autodocodec/Schema.hs view
@@ -10,6 +10,7 @@ module Autodocodec.Schema where import Autodocodec+import qualified Autodocodec.Aeson.Compat as Compat import Control.Monad.State import Data.Aeson (FromJSON (..), ToJSON (..)) import qualified Data.Aeson as JSON@@ -90,7 +91,7 @@ in ["type" JSON..= ("object" :: Text), "additionalProperties" JSON..= JSON.object itemSchemaVal] ObjectSchema os -> case toJSON os of- JSON.Object o -> HM.toList o+ JSON.Object o -> Compat.toList o _ -> [] -- Should not happen. AnyOfSchema jcs -> let svals :: [JSON.Value]@@ -147,7 +148,7 @@ case mOne of Just ones -> pure $ OneOfSchema ones Nothing -> do- let mConst = HM.lookup "const" o+ let mConst = Compat.lookupKey "const" o case mConst of Just constant -> pure $ ValueSchema constant Nothing -> do@@ -220,7 +221,7 @@ ObjectKeySchema k kr ks mDoc -> let (propVal, req) = keySchemaToPieces (k, kr, ks, mDoc) in -- TODO deal with the default value somehow.- concat [["properties" JSON..= JSON.object [k JSON..= propVal]], ["required" JSON..= [k] | req]]+ concat [["properties" JSON..= JSON.object [Compat.toKey k JSON..= propVal]], ["required" JSON..= [k] | req]] ObjectAnyOfSchema ne -> ["anyOf" JSON..= NE.map toJSON ne] ObjectOneOfSchema ne -> ["oneOf" JSON..= NE.map toJSON ne] ObjectAllOfSchema ne ->@@ -253,7 +254,7 @@ goObject :: JSON.Object -> ObjectSchema -> State (Map Text JSONSchema) Bool goObject obj = \case ObjectAnySchema -> pure True- ObjectKeySchema key kr ks _ -> case HM.lookup key obj of+ ObjectKeySchema key kr ks _ -> case Compat.lookupKey (Compat.toKey key) obj of Nothing -> case kr of Required -> pure False Optional _ -> pure True