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
generated dataclasses not compatible with fastapi/pydantic dataclass bridge #486
Comments
Very fortuitous to see this bug already reported. I am encountering something similar for when I am trying to use the dataclasses from LinkML in FastAPI. |
@hsolbrig you were working on this code yesterday to add 3.10 support linkml/linkml-runtime#75 any chance you could take a look at this? in the interim @deepakunni3 you may be interested in pydanticgen see #172 (comment) |
Thanks @cmungall ! Will take a look at pydanticgen |
We have two PRs demoing the problem:
|
Hoping this will fix things: linkml/linkml-runtime#168 |
OK, I think the problem here is not with dataclass_extensions_376.py -- the above PR shifts the problem to
|
OK, the problem is that the generated code like:
tricks the pydantic dataclass wrapper, it doesn't recognize this as a default field this is true even if we replace for a more explicit Others seem to have the same issue: |
Is this still relevant? |
When using fastapi to serialize linkml objects we get an error
note: this even happens when we use the bridge layer between dataclasses and pydantic: https://fastapi.tiangolo.com/advanced/dataclasses/
here is the code that reproduces this (I will also make a PR)
main.py:
to test:
full stack trace:
this is the code here: https://github.com/linkml/linkml-runtime/blob/main/linkml_runtime/utils/dataclass_extensions_376.py
Related? linkml/linkml-runtime#73
The text was updated successfully, but these errors were encountered: