Skip to content
This repository was archived by the owner on Oct 19, 2022. It is now read-only.

APISpec quickfix#27

Open
quaterneon wants to merge 1 commit intojustanr:masterfrom
quaterneon:master
Open

APISpec quickfix#27
quaterneon wants to merge 1 commit intojustanr:masterfrom
quaterneon:master

Conversation

@quaterneon
Copy link

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 enum that 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 called enum. 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 as metadata.enum to marshmallow and apispec.

@justanr
Copy link
Owner

justanr commented Feb 1, 2019

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?

@quaterneon
Copy link
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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants