-
Notifications
You must be signed in to change notification settings - Fork 88
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
Loading schema from file #177
Comments
Hi Boris! Thanks for checking out the library! I'm on vacation until the start of August so will be delayed at responding. One possibility is using kor with pydantic style schema rather than native kor schema and relying on the adapter to map from pydantic schema to kor schema (see validation section in docs). This gives control over serialization and also creates a validator at the same time. Would this work for your use case? |
Hi Eugene, thank you for the response while you are on vacation. I am not that familiar with python and pydantic, so maybe it might be possible to use it for out use case. Our use case is that the schema will be defined in a different application and can be changed by the user. My understanding with pydantic is, that I need to define the schema/model in code? Alternatively, with a little change to the {
"id": "person",
"description": "Information about a person",
"many": false,
"attributes": [
{
"$type": "Text",
"id": "name",
"description": "The name of the person",
"many": false,
"examples": []
},
{
"$type": "Text",
"id": "position",
"description": "The position of the person",
"many": false,
"examples": []
},
{
"$type": "Number",
"id": "age",
"description": "The age of the person",
"many": false,
"examples": []
}
],
"examples": []
} IMHO this is not the "prettiest" solution, but it works. And as I said, I don't know if our use case can be implemented with pydantic directly, but I will do some more research. |
That works! Will welcome a PR :). If possible could you add relevant unit tests to verify serialization works? |
Will check what I can do with my simple python skills and create a PR! Have a nice vacation! |
This PR makes the schema loadable from JSON via `Object.parse_raw`. PR includes feature, tests and documentation Link to Issue #177
Thank you merged |
released as version 0.11.0 |
Hey Eugene, I managed to make the schema serializable to JSON. Please check PR #184 if it fits for you! |
This PR makes the schema serializable to JSON via Object.json() PR includes feature, tests and documentation Link to Issue #177
Since this is all merged the issue can be closed. |
Hi,
is there any way to load a schema from a file? Tried serializing an existing schema to JSON, but loading (via Object.parse_raw) fails, because there is no type discriminator for the attributes.
Is there already another way to do that? If not, are you planning to implement this or would you accept a PR for this?
Thanks
Boris
The text was updated successfully, but these errors were encountered: