Skip to content

It's hard to use a parent schema's data to control a Nested OneOfSchema #214

@juledwar

Description

@juledwar

I have a schema that uses fields.Nested on a OneOfSchema type schema, where the type field data comes from the parent. I can work around the lack of built-in way to do that with some context, and override get_obj_type / get_data_type.

The new way of doing context in Marshmallow v4 has turned this into a much harder endeavour. I've had to override the load method in the parent schema so I can set a contextvar once per item in the incoming list of data which is now picked up by the nested schema's get_xxx methods.

I'm not really sure if there's any easier way to do it but leaving this Issue here in case someone has already thought about it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions