Skip to content

Fix ContainsOnly constraints on list item schemas - #1097

Open
Twiink wants to merge 1 commit into
marshmallow-code:devfrom
Twiink:fix/contains-only-item-schema
Open

Twiink wants to merge 1 commit into
marshmallow-code:devfrom
Twiink:fix/contains-only-item-schema

Conversation

@Twiink

@Twiink Twiink commented Nov 18, 2026

Copy link
Copy Markdown

For a Marshmallow list with validate.ContainsOnly(["blue", "green"]), apispec emits a top-level enum of strings on an array. A validator using that schema rejects every array, including [] and ["blue", "blue"], both of which Marshmallow accepts.

Apply the allowed choices to the item schema. If the inner field already has an enum, keep the intersection so the generated schema describes both validators. The regression exercises the field's real deserializer and its generated schema in OpenAPI 2 and 3.

The complete test suite passed locally (638 passed, 6 skipped).

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.

1 participant