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

Allow marshmallow_enum to be used for OpenAPI schema definitions #38

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

h
Copy link

@h h commented Apr 18, 2020

Passing the enum through to the super-class allows it to be used for APISpec/OpenAPI schema definitions, an important use-case for marshmallow. Given that it's the first parameter of the function, the risk that the parameter was referenced by name in a client library is fairly small. Searching through public repositories in GitHub doesn't reveal any clients where this would be problematic.

OpenAPI does not permit the values to differ between loading/dumping. The load_by and dump_by parameters are still accepted for backward compatibility, but they have been deprecated in favor of the by_value parameter.

Birne94 and others added 6 commits August 15, 2018 17:31
Passing the enum through the custructor allows it to be used for OpenAPI
schema definitions, an important use-case for marshmallow. Given it's
the first parameter of the function, the risk of it being referenced by
a client library by name is fairly small, and searching through public
repositories in GitHub doesn't reveal any clients where this would be
problematic.
The unused import was causing pytest to fail
@h
Copy link
Author

h commented Apr 18, 2020

See #24 and #25

@h h marked this pull request as draft April 22, 2020 21:26
@h h marked this pull request as ready for review April 22, 2020 21:26
@h
Copy link
Author

h commented Apr 22, 2020

@justanr Could you review the PR and let me know if this looks alright to you? We'd like to start using it to include enum fields in our autogenerated OpenAPI specs. Thanks!

@kaos
Copy link

kaos commented Jan 8, 2021

Time to make a move on this?
If @justanr have moved on to other projects, perhaps we can adopt this under another namespace/project?

)

self.load_by = load_by
self.dump_by = dump_by
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a backwards breaking change to not set these attributes. Better would be to set them based on the self.by_value attr for backwards compatibility.

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.

3 participants