autodocodec-schema 0.1.0.1 → 0.1.0.2
raw patch · 4 files changed
+17/−4 lines, 4 filesdep ~autodocodecPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: autodocodec
API changes (from Hackage documentation)
Files
- CHANGELOG.md +6/−0
- LICENSE +1/−1
- autodocodec-schema.cabal +3/−3
- src/Autodocodec/Schema.hs +7/−0
CHANGELOG.md view
@@ -1,5 +1,11 @@ # Changelog +## [0.1.0.2] - 2022-07-21++### Added++* Support for the `discriminatedUnionCodec` for discriminated unions in `autodocodec-0.2.0.0`+ ## [0.1.0.1] - 2022-04-26 ### Added
LICENSE view
@@ -1,6 +1,6 @@ MIT License -Copyright (c) 2021 Tom Sydney Kerckhove+Copyright (c) 2021-2022 Tom Sydney Kerckhove Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal
autodocodec-schema.cabal view
@@ -5,13 +5,13 @@ -- see: https://github.com/sol/hpack name: autodocodec-schema-version: 0.1.0.1+version: 0.1.0.2 synopsis: Autodocodec interpreters for JSON Schema homepage: https://github.com/NorfairKing/autodocodec#readme bug-reports: https://github.com/NorfairKing/autodocodec/issues author: Tom Sydney Kerckhove maintainer: syd@cs-syd.eu-copyright: 2021 Tom Sydney Kerckhove+copyright: 2021-2022 Tom Sydney Kerckhove license: MIT license-file: LICENSE build-type: Simple@@ -32,7 +32,7 @@ src build-depends: aeson- , autodocodec >=0.0.1.0+ , autodocodec >=0.2.0.0 , base >=4.7 && <5 , containers , mtl
src/Autodocodec/Schema.hs view
@@ -384,6 +384,13 @@ pure $ case u of DisjointUnion -> ObjectOneOfSchema (goObjectOneOf (os1 :| [os2])) PossiblyJointUnion -> ObjectAnyOfSchema (goObjectAnyOf (os1 :| [os2]))+ DiscriminatedUnionCodec pn _ m -> do+ let mkSchema dName (_, oc) =+ goObject $ oc *> (requiredFieldWith' pn (literalTextCodec dName) .= const dName)+ ss <- HM.traverseWithKey mkSchema m+ pure $ case NE.nonEmpty $ toList ss of+ Nothing -> ObjectAnySchema+ Just ss' -> ObjectOneOfSchema $ goObjectOneOf ss' PureCodec _ -> pure ObjectAnySchema ApCodec oc1 oc2 -> do os1 <- goObject oc1