@@ -50,9 +50,10 @@ impl BuildSerializer for FunctionAfterSerializerBuilder {
50
50
definitions : & mut DefinitionsBuilder < CombinedSerializer > ,
51
51
) -> PyResult < CombinedSerializer > {
52
52
let py = schema. py ( ) ;
53
- // while `before` schemas have an obvious type, for
54
- // `after` schemas it's less, clear but the default will be the same type, and the user/lib can always
55
- // override the serializer
53
+ // While `before` function schemas do not modify the output type (and therefore affect the
54
+ // serialization), for `after` schemas, there's no way to directly infer what schema should
55
+ // be used for serialization. For convenience, the default is to assume the wrapped schema
56
+ // should be used; the user/lib can override the serializer if necessary.
56
57
let schema = schema. get_as_req ( intern ! ( py, "schema" ) ) ?;
57
58
CombinedSerializer :: build ( schema, config, definitions)
58
59
}
@@ -279,7 +280,13 @@ impl BuildSerializer for FunctionWrapSerializerBuilder {
279
280
config : Option < & PyDict > ,
280
281
definitions : & mut DefinitionsBuilder < CombinedSerializer > ,
281
282
) -> PyResult < CombinedSerializer > {
282
- super :: any:: AnySerializer :: build ( schema, config, definitions)
283
+ let py = schema. py ( ) ;
284
+ // While `before` function schemas do not modify the output type (and therefore affect the
285
+ // serialization), for `wrap` schemas (like `after`), there's no way to directly infer what
286
+ // schema should be used for serialization. For convenience, the default is to assume the
287
+ // wrapped schema should be used; the user/lib can override the serializer if necessary.
288
+ let schema = schema. get_as_req ( intern ! ( py, "schema" ) ) ?;
289
+ CombinedSerializer :: build ( schema, config, definitions)
283
290
}
284
291
}
285
292
0 commit comments