Skip to content

Add models for farmOS record types #25

Description

@paul121

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.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions