This repository was archived by the owner on Oct 19, 2022. It is now read-only.
Open
Conversation
…l be passed through marshmallow to apispec.
Owner
|
I'm uncomfortable changing a named parameter. I realize that most likely no one is using it as a named parameter but there's the case where an upgrade to a new version break them. Instead, could we pass the enum onto the kwargs storage? |
Author
|
Passing the enum directly wouldn't work AFAIK, as apispec is expecting a list instead. The other MR relating to this issue does attempt to do that, but there hasn't been any recent activity on that. |
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem: Marshmallow_enum.EnumField does not pass the enum as metadata to marshmallow. When used in conjunction with apispec (specifically, the apispec marshmallow extension), this results in EnumFields being converted to a property of just a string type with no additional metadata such as the permitted values of the enum.
Long-term fix: #25
Short term fix: Marshmallow and apispec both permit a workaround of manually specifying an enum value. In marshmallow any Field type can have an extra kwarg called
enumthat will be passed to apispec and correctly appended to the resulting docs. This cannot be done with EnumField because it's first positional argument is already calledenum. While the pros and cons of potential long-term fixes are debated, this would allow a user to manually specify a value to be passed asmetadata.enumto marshmallow and apispec.