You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been working on writing JSON schemas for Bodhi's messages the past few days. It's pretty rad, but I had the thought that it might be a nice convenience if fedora-messaging had the ability to generate these for me based on Python classes. I don't know exactly how I would recommend making it work, but I think it could be cool if we require Python 3 for this feature so we can use some cool Python 3 things to help out:
Type annotations! This way we can know the types of the items to fill in the schema in a "Pythonic" way.
We could use typing.NamedTuple - this is like a really fancy Enum that supports storing data with type annotations and behaviors.
Anyways, I'm quite fuzzy on the details, but I imagine some code that can introspect a class and spit out a JSON schema, and all fedora-messaging API users have to do is write nice Python classes and not worry about how JSON schema works.
Note: We would need some way to differentiate between required fields and non-required fields to fill out the required section on objects in the JSON schema. Perhaps just a _required = ['a', 'b', 'c'] on the class could do that for us?
The text was updated successfully, but these errors were encountered:
To solve the problem of Python 3 being used, it may be possible to have the requested feature live in its own module and have the Python 2 version avoid packaging it.
Or maybe I could do this in the https://python-jsonschema.readthedocs.io/en/latest/ project? Not sure if I would want to be able to mix with fedora-messaging features or not. I guess there are always mixin classes?
Greetings!
I've been working on writing JSON schemas for Bodhi's messages the past few days. It's pretty rad, but I had the thought that it might be a nice convenience if fedora-messaging had the ability to generate these for me based on Python classes. I don't know exactly how I would recommend making it work, but I think it could be cool if we require Python 3 for this feature so we can use some cool Python 3 things to help out:
typing.NamedTuple
- this is like a really fancy Enum that supports storing data with type annotations and behaviors.Anyways, I'm quite fuzzy on the details, but I imagine some code that can introspect a class and spit out a JSON schema, and all fedora-messaging API users have to do is write nice Python classes and not worry about how JSON schema works.
Note: We would need some way to differentiate between required fields and non-required fields to fill out the
required
section on objects in the JSON schema. Perhaps just a_required = ['a', 'b', 'c']
on the class could do that for us?The text was updated successfully, but these errors were encountered: