Skip to content
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: Enums #19

Open
stevebell117 opened this issue Feb 18, 2021 · 2 comments
Open

Feature Request: Enums #19

stevebell117 opened this issue Feb 18, 2021 · 2 comments

Comments

@stevebell117
Copy link

Hello,

I am using your library and I really like it! However, I have noticed if you have the following property:

"session": {
            "type": "string",
            "enum": [
            "NORMAL",
            "AM",
            "PM",
            "SEAMLESS"
            ]
        }

Then it doesn't generate something like:

class Session(Enum):
   Normal = "NORMAL"
   ...

Would this be possible to implement, as it's part of the JSON Schema format?

@saroad2
Copy link
Collaborator

saroad2 commented Feb 18, 2021

I think that this should be relatively easy to implement and it will add a very nice new feature to this library.

Thanks for the suggestion!

@SF-Zhou
Copy link
Member

SF-Zhou commented Feb 28, 2021

The enum in the JSON schema is not exactly the same as the enum in Python.
There are some issues need to be resolved, such as the variable name and enum type. The variable name may not be directly obtained from the enumerated value because of the existence of special characters. And using generated enum types will change the original strong value types like string, int and float.

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

No branches or pull requests

3 participants