autodocodec-openapi3 0.2.1.0 → 0.2.1.1
raw patch · 4 files changed
+27/−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-openapi3.cabal +3/−3
- src/Autodocodec/OpenAPI/Schema.hs +17/−0
CHANGELOG.md view
@@ -1,5 +1,11 @@ # Changelog +## [0.2.1.1] - 2022-07-21++### Added++* Support for the `discriminatedUnionCodec` for discriminated unions in `autodocodec-0.2.0.0`+ ## [0.2.1.0] - 2022-06-19 ### Changed
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-openapi3.cabal view
@@ -5,13 +5,13 @@ -- see: https://github.com/sol/hpack name: autodocodec-openapi3-version: 0.2.1.0+version: 0.2.1.1 synopsis: Autodocodec interpreters for openapi3 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@@ -34,7 +34,7 @@ src build-depends: aeson- , autodocodec+ , autodocodec >=0.2.0.0 , base >=4.7 && <5 , insert-ordered-containers , lens
src/Autodocodec/OpenAPI/Schema.hs view
@@ -17,6 +17,7 @@ import qualified Control.Monad.State.Lazy as State import Control.Monad.Trans (lift) import qualified Data.Aeson as Aeson+import qualified Data.Foldable as Foldable import Data.HashMap.Strict (HashMap) import qualified Data.HashMap.Strict as HashMap import qualified Data.HashMap.Strict.InsOrd as InsOrdHashMap@@ -182,6 +183,22 @@ u (NamedSchema Nothing (combineObjectSchemas s1s)) (NamedSchema Nothing (combineObjectSchemas s2s))+ DiscriminatedUnionCodec pn _ m -> do+ let d =+ Discriminator+ { _discriminatorPropertyName = pn,+ _discriminatorMapping = InsOrdHashMap.fromHashMap $ fmap fst m+ }+ mkSchema dName (refName, oc) = do+ s <- goObject $ oc *> (requiredFieldWith' pn (literalTextCodec dName) .= const dName)+ declareSpecificSchemaRef (Just refName) $ combineObjectSchemas s+ ss <- HashMap.traverseWithKey mkSchema m+ pure+ [ mempty+ { _schemaDiscriminator = Just d,+ _schemaOneOf = Just $ Foldable.toList ss+ }+ ] ApCodec oc1 oc2 -> do ss1 <- goObject oc1 ss2 <- goObject oc2