Skip to content

Commit ef7b7cc

Browse files
committed
Assume wrap validators produce the same serialization schema
1 parent 119b265 commit ef7b7cc

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/serializers/type_serializers/function.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,10 @@ impl BuildSerializer for FunctionAfterSerializerBuilder {
5050
definitions: &mut DefinitionsBuilder<CombinedSerializer>,
5151
) -> PyResult<CombinedSerializer> {
5252
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.
5657
let schema = schema.get_as_req(intern!(py, "schema"))?;
5758
CombinedSerializer::build(schema, config, definitions)
5859
}
@@ -279,7 +280,13 @@ impl BuildSerializer for FunctionWrapSerializerBuilder {
279280
config: Option<&PyDict>,
280281
definitions: &mut DefinitionsBuilder<CombinedSerializer>,
281282
) -> 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)
283290
}
284291
}
285292

0 commit comments

Comments
 (0)