autodocodec-swagger2 0.0.1.3 → 0.0.1.4
raw patch · 4 files changed
+29/−6 lines, 4 filesPVP: minor bump suggested
API additions: PVP suggests at least a minor version bump
API changes (from Hackage documentation)
+ Autodocodec.Swagger.DerivingVia.NonOrphan: AutodocodecSwagger :: a -> AutodocodecSwagger a
+ Autodocodec.Swagger.DerivingVia.NonOrphan: [unAutodocodecSwagger] :: AutodocodecSwagger a -> a
+ Autodocodec.Swagger.DerivingVia.NonOrphan: instance Autodocodec.Class.HasCodec a => Data.Swagger.Internal.Schema.ToSchema (Autodocodec.Swagger.DerivingVia.NonOrphan.AutodocodecSwagger a)
+ Autodocodec.Swagger.DerivingVia.NonOrphan: newtype AutodocodecSwagger a
Files
- CHANGELOG.md +4/−0
- autodocodec-swagger2.cabal +2/−1
- src/Autodocodec/Swagger/DerivingVia.hs +6/−5
- src/Autodocodec/Swagger/DerivingVia/NonOrphan.hs +17/−0
CHANGELOG.md view
@@ -1,5 +1,9 @@ # Changelog +## [0.0.1.4] - 2024-07-29++* Non-orphan version of the `ToSchema` deriving.+ ## [0.0.1.3] - 2024-07-26 * Support for `autodocodec >=0.4`.
autodocodec-swagger2.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack name: autodocodec-swagger2-version: 0.0.1.3+version: 0.0.1.4 synopsis: Autodocodec interpreters for swagger2 homepage: https://github.com/NorfairKing/autodocodec#readme bug-reports: https://github.com/NorfairKing/autodocodec/issues@@ -27,6 +27,7 @@ exposed-modules: Autodocodec.Swagger Autodocodec.Swagger.DerivingVia+ Autodocodec.Swagger.DerivingVia.NonOrphan Autodocodec.Swagger.Schema other-modules: Paths_autodocodec_swagger2
src/Autodocodec/Swagger/DerivingVia.hs view
@@ -3,13 +3,14 @@ module Autodocodec.Swagger.DerivingVia where -import Autodocodec-import Autodocodec.Swagger.Schema-import Data.Proxy-import Data.Swagger as Swagger+import Autodocodec (Autodocodec, HasCodec)+import Autodocodec.Swagger.Schema (declareNamedSchemaViaCodec)+import Data.Proxy (Proxy (..))+import qualified Data.Swagger as Swagger -- | An instance for 'Autodocodec' that lets you use 'DerivingVia' to derive 'Swagger.ToSchema' if your type has a 'HasCodec' instance. -- -- > deriving (Swagger.ToSchema) via (Autodocodec FooBar) instance (HasCodec a) => Swagger.ToSchema (Autodocodec a) where- declareNamedSchema (Proxy :: Proxy (Autodocodec a)) = declareNamedSchemaViaCodec (Proxy :: Proxy a)+ -- See comments in 'Autodocodec.OpenAPI.DerivingVia' for the reason why this is defined like this.+ declareNamedSchema = let schema = declareNamedSchemaViaCodec (Proxy :: Proxy a) in const schema
+ src/Autodocodec/Swagger/DerivingVia/NonOrphan.hs view
@@ -0,0 +1,17 @@+{-# LANGUAGE ScopedTypeVariables #-}++module Autodocodec.Swagger.DerivingVia.NonOrphan (AutodocodecSwagger (..)) where++import Autodocodec (HasCodec)+import Autodocodec.Swagger.Schema (declareNamedSchemaViaCodec)+import Data.Proxy (Proxy (..))+import qualified Data.Swagger as Swagger++newtype AutodocodecSwagger a = AutodocodecSwagger {unAutodocodecSwagger :: a}++-- | An non-orphan instance for 'AutodocodecSwagger' that lets you use 'DerivingVia' to derive 'Swagger.ToSchema' if your type has a 'HasCodec' instance.+--+-- > deriving (Swagger.ToSchema) via (AutodocodecSwagger FooBar)+instance (HasCodec a) => Swagger.ToSchema (AutodocodecSwagger a) where+ -- See comments in 'Autodocodec.OpenAPI.DerivingVia' for the reason why this is defined like this.+ declareNamedSchema = let schema = declareNamedSchemaViaCodec (Proxy :: Proxy a) in const schema