diff --git a/CHANGELOG.md b/CHANGELOG.md
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,11 @@
 # Changelog
 
+## [0.4.0.2] - 2025-06-20
+
+### Changed
+
+* Support for `autodocodec >=0.5`
+
 ## [0.4.0.1] - 2025-02-13
 
 ### Added
diff --git a/autodocodec-yaml.cabal b/autodocodec-yaml.cabal
--- a/autodocodec-yaml.cabal
+++ b/autodocodec-yaml.cabal
@@ -1,11 +1,11 @@
 cabal-version: 1.12
 
--- This file has been generated from package.yaml by hpack version 0.36.0.
+-- This file has been generated from package.yaml by hpack version 0.36.1.
 --
 -- see: https://github.com/sol/hpack
 
 name:           autodocodec-yaml
-version:        0.4.0.1
+version:        0.4.0.2
 synopsis:       Autodocodec interpreters for yaml
 homepage:       https://github.com/NorfairKing/autodocodec#readme
 bug-reports:    https://github.com/NorfairKing/autodocodec/issues
@@ -34,7 +34,7 @@
   hs-source-dirs:
       src
   build-depends:
-      autodocodec >=0.4.0.0
+      autodocodec >=0.5.0.0
     , autodocodec-schema >=0.2.0.1
     , base >=4.7 && <5
     , bytestring
diff --git a/src/Autodocodec/Yaml/Encode.hs b/src/Autodocodec/Yaml/Encode.hs
--- a/src/Autodocodec/Yaml/Encode.hs
+++ b/src/Autodocodec/Yaml/Encode.hs
@@ -52,7 +52,7 @@
 
     goObject :: a -> ObjectCodec a void -> [(Text, YamlBuilder)]
     goObject a = \case
-      RequiredKeyCodec k c _ -> [(k, go a c)]
+      RequiredKeyCodec k c _ -> [(k, go (coerce a) c)]
       OptionalKeyCodec k c _ -> case (coerce a :: Maybe _) of
         Nothing -> []
         Just b -> [k Yaml..= go b c]
