marshmallow-code / marshmallow-code/marshmallow

Object to pass to Nested as missing

Open
#1,042 13 comments 17 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
7.2k
Forks
738
Avg merge
1d 23h
Merged PRs (30d)
7

Description

In deserialization, It seems like the `missing` value is what is returned if there is no value as opposed to the value that gets passed to the nested Schema. Is there anyway to have "default" value for the nested schema?
e.g:
```python
class A(Schema):
a = fields.String()

class B(Schema):
b = fields.Nested(A, many=True, missing=[])

class C(Schema):
c = fields.Nested(B, missing={})

C().load({}) # returns {'c': {}}
```
I would like it to return `{'c': {'b': []}}`, i.e have it run the nested schema passing an empty object and then letting the nested schema apply its own missing logic.

Contributor guide

Open the contributing guide

Research direction

Start by tracing marshmallow's Nested deserialization and missing-value handling, using the C/B/A example as the reproduction. Determine how a missing nested value should trigger the inner schema's missing behavior, then add coverage showing C().load({}) produces the requested nested result.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.