packages feed

autodocodec-swagger2 0.0.1.0 → 0.0.1.1

raw patch · 4 files changed

+21/−4 lines, 4 filesdep +unordered-containersdep ~autodocodec

Dependencies added: unordered-containers

Dependency ranges changed: autodocodec

Files

CHANGELOG.md view
@@ -1,5 +1,11 @@ # Changelog +## [0.0.1.1] - 2022-07-21++### Added++* Support for the `discriminatedUnionCodec` for discriminated unions in `autodocodec-0.2.0.0`+ ## [0.0.1.0] - 2021-11-19  ### 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-swagger2.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-swagger2-version:        0.0.1.0+version:        0.0.1.1 synopsis:       Autodocodec interpreters for swagger2 homepage:       https://github.com/NorfairKing/autodocodec#readme bug-reports:    https://github.com/NorfairKing/autodocodec/issues@@ -34,10 +34,11 @@       src   build-depends:       aeson-    , autodocodec >=0.0.1.0+    , autodocodec >=0.2.0.0     , base >=4.7 && <5     , insert-ordered-containers     , scientific     , swagger2     , text+    , unordered-containers   default-language: Haskell2010
src/Autodocodec/Swagger/Schema.hs view
@@ -11,6 +11,8 @@  import Autodocodec import Control.Monad+import Data.Foldable (toList)+import qualified Data.HashMap.Strict as HashMap import qualified Data.HashMap.Strict.InsOrd as InsOrdHashMap import Data.List import Data.Proxy@@ -164,6 +166,14 @@         ss1 <- goObject oc1         ss2 <- goObject oc2         pure [combineSchemaOr u (combineObjectSchemas ss1) (combineObjectSchemas ss2)]+      DiscriminatedUnionCodec pn _ m -> do+        let mkSchema dName (_, oc) =+              fmap combineObjectSchemas $ goObject $ oc *> (requiredFieldWith' pn textCodec .= const dName)+        ss <- HashMap.traverseWithKey mkSchema m+        let combined = case toList ss of+              [] -> mempty+              (s : ss') -> foldr (combineSchemaOr DisjointUnion) s ss'+        pure [combined]       ApCodec oc1 oc2 -> do         ss1 <- goObject oc1         ss2 <- goObject oc2