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

Use Pydantic for action argument validation & property models #15

Open
VigneshVSV opened this issue Jul 26, 2024 · 0 comments
Open

Use Pydantic for action argument validation & property models #15

VigneshVSV opened this issue Jul 26, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@VigneshVSV
Copy link
Owner

VigneshVSV commented Jul 26, 2024

Currently there are two ways to validate arguments given to actions

  • Using JSON schema validation (which is alright)
  • parameterized function, which is a little verbose.

Best is to use type annotations as much as possible. Its succint & mostly understandable.

There is an implementation in labthings-fastapi. Once the GPL related license details are sorted out, it can be carried over.

Its also better to describe actions using objects instead of a descriptor. One may have to create an Action class, which are instantiated for each action.

Regarding property models, many are comfortable using pydantic based models which will also offer a different type of flexibility compared to param. This should be supported. Code is already there in labthings-fastapi.

@VigneshVSV VigneshVSV added the enhancement New feature or request label Jul 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant