Skip to content

fix(convert): do not mark dump_only fields as required - #747

Open
voidstackloop wants to merge 2 commits into
marshmallow-code:devfrom
voidstackloop:fix/dump-only-not-required
Open

voidstackloop wants to merge 2 commits into
marshmallow-code:devfrom
voidstackloop:fix/dump-only-not-required

Conversation

@voidstackloop

Copy link
Copy Markdown

Description

Fixes #672.

When a field is configured as dump_only=True (either through auto_field(dump_only=True), field_for(dump_only=True), or Meta.dump_only), required was previously set to True if the underlying column was non-nullable without a default. Because dump-only fields are only used for serialization and are never expected on input, marking them as required causes OpenAPI generators and schemas to flag them as required request fields.

This change ensures that when dump_only=True is active, required defaults to False unless explicitly overridden.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Don't set a field as required if it's read-only

1 participant