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

Add models for farmOS record types #25

Open
paul121 opened this issue Nov 18, 2019 · 0 comments
Open

Add models for farmOS record types #25

paul121 opened this issue Nov 18, 2019 · 0 comments

Comments

@paul121
Copy link
Member

paul121 commented Nov 18, 2019

There's been some discussion about how it would be useful to have models for creating and validating farmOS records. I think this library would be a great place to provide such models for Python, and would allow us to do it in a very "pythonic" way.

Models could be stored under a farmOS.models module and be imported like from farmOS.models import log, area, asset

I'd like to propose we use pydantic for this - https://pydantic-docs.helpmanual.io/. Basically, this library allows you to define models which are classes that inherit from the pydantic BaseModel class which already has a bunch of properties and features built in. You can easily create objects from the models you define, and pass them around as if they were types in a strictly typed language.

Another benefit is that the farmOS-aggregator could use these models to further document it's auto-generated OpenAPI schema. Other tools such as SQLAlchemy have support for pydantic models as well. I'm sure there are lots of other benefits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant