-
-
Notifications
You must be signed in to change notification settings - Fork 111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature Request][OpenApi3] Add support for enums #231
Comments
@BilliAlpha Thanks. Would you be interested in taking a crack at a PR? |
Sorry for the delay in responding, but i'll take a look at it and try something. |
@BilliAlpha I havent tried using the new parameter structures yet, was planning on looking at it later today, but I find that adding the line
No idea if that solves your problem or not, feel free to try it out ... |
@artcg That would probably be a barebones usage. But, it probably should be: enum: Union[List[str], Enum] In which case we would need some logic on serialization to extract key/values from an enum. from enum import Enum
class Color(Enum):
RED = "red"
GREEN = "green"
BLUE = "blue"
print([item.value for item in Color.__members__.values()])
# ['red', 'green', 'blue'] |
@ahopkins I just saw your comment, I'll adapt the PR to support python Enums too. |
* Add enum field on Schema And add some tests to check results in spec output * test CI fix ? Co-authored-by: Arthur Goldberg <arthur.c.goldberg@gmail.com>
The PR #235 was merged |
I am migrating my project from openapi2 and I found out that the
choices
parameters has disappeared in favor ofenum
. However it seems that this parameter is not supported in sanic-openapi.I suppose the implementation wouldn't be more complex than adding an
enum
field on theSchema
object.The enum field should be supported as specified in the specifications:
The JSON Schema definition of the
enum
field is:https://datatracker.ietf.org/doc/html/draft-wright-json-schema-validation-00#section-5.20
The text was updated successfully, but these errors were encountered: