Pass Python type information through the Thing Description
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 35/100
- Issue type
- Feature
- Clarity
- Needs clarification
- Activity status
- Quiet
- Domain
- api, backend-api-design
Research direction
Start by locating thing_description._model.DataSchema and the schema-generation entry point that populates it. Define the minimal optional Python-type metadata described in the issue, preserve JSONSchema as the primary description, and verify that schema generation still works when the metadata is absent.
Written by the indexing model from the issue text.
Description
I believe both JSONSchema and Thing Description permit additional fields. This means we could add, for example a labthings_python_type field, which provides optional information about the Python type that generated the schema. This might include:
- module and qualified name, allowing the exact type to be imported. This would work really nicely for
pydantic-compatible types. - a type hint as a string (if it uses builtins) - parsing that safely is likely to be quite hard!
- hints as to whether to reconstruct an
objecttype as something with attributes (dataclassorpydantic.BaseModel) or something with items (dictorTypedDict). - special cases like
np.arraywhich aren'tpydanticcompatible but should have a LabThings wrapper/annotation to make them work.
We'd need to add a field for this in the thing_description._model.DataSchema and populate it when generating the schema.
Just to be clear, I am very keen that this does not replace describing the types properly in JSONSchema. That is, and should remain, the primary way of describing types, as it's cross-language and cross-platform. I am proposing adding some minimal extra information, so that the Python types can match the server more closely. We should continue to test that everything works without this feature, if we choose to implement it.
- Dominant language
- Python
- Stars
- 9
- Forks
- 4
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from labthings/labthings-fastapi
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
labthings/labthings-fastapi#405 ·
-
drop-python-version
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
labthings/labthings-fastapi#354 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
labthings/labthings-fastapi#312 · 1 comment ·
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
labthings/labthings-fastapi#404 · 2 comments ·
-
Difficulty 3/5 1-2 days Newbie friendliness 63/100
labthings/labthings-fastapi#403 · 1 comment ·
All issues in labthings/labthings-fastapi
Similar issues
-
bug confirmed issue
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
open-webui/open-webui#30750 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
OpenwaterHealth/openmotion-bloodflow-app#604 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
good first issue
Difficulty 1/5 Under an hour Newbie friendliness 90/100