File tree 2 files changed +23
-0
lines changed
aws_lambda_powertools/event_handler/openapi
tests/functional/event_handler/_pydantic 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -95,6 +95,7 @@ def jsonable_encoder( # noqa: PLR0911
95
95
exclude_unset = exclude_unset ,
96
96
exclude_defaults = exclude_defaults ,
97
97
exclude_none = exclude_none ,
98
+ custom_serializer = custom_serializer ,
98
99
)
99
100
100
101
# Enums
Original file line number Diff line number Diff line change @@ -253,3 +253,25 @@ def serializer(value):
253
253
254
254
# THEN we should get the custom serializer output
255
255
assert result == {"kind" : "serialized" }
256
+
257
+
258
+ def test_openapi_encode_custom_serializer_dataclasses ():
259
+ # GIVEN a sequence with a custom class
260
+ class CustomClass :
261
+ __slots__ = []
262
+
263
+ @dataclass
264
+ class Order :
265
+ kind : CustomClass
266
+
267
+ order = Order (kind = CustomClass ())
268
+
269
+ # AND a custom serializer
270
+ def serializer (value ):
271
+ return "serialized"
272
+
273
+ # WHEN we call jsonable_encoder with the nested dictionary and unserializable value
274
+ result = jsonable_encoder (order , custom_serializer = serializer )
275
+
276
+ # THEN we should get the custom serializer output
277
+ assert result == {"kind" : "serialized" }
You can’t perform that action at this time.
0 commit comments