Skip to content

feat: add list_as_array flag to MarshmallowPlugin for array-root requestBody #982

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from

Conversation

nomi3
Copy link

@nomi3 nomi3 commented Jun 17, 2025

OpenAPI 3.x fully supports request bodies whose root schema is an array, but apispec + marshmallow currently cannot generate such schemas automatically. Projects must hand-write YAML/dict snippets for every endpoint that needs it.

This PR introduces an opt-in flag—list_as_array—to MarshmallowPlugin that lets the plugin emit type: array schemas automatically when:

  • a plain fields.List(...) is supplied as the schema, or
  • a Schema (class or instance) contains exactly one fields.List field with data_key=None.

The default behaviour remains unchanged (object-root), so the change is non-breaking.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant