warlock
warlock copied to clipboard
Default fields not declared on Object
Got KeyError referring to schema object with default value:
import warlock
schema = {
"title": "Message",
"type": "object",
"properties": {
"sender": {
"title": "Sender",
"type": "string"
},
"trace": {
"title": "Trace",
"default": [],
"type": "array",
"items": {
"type": "string"
}
}
},
"required": [
"sender"
],
'additionalProperties': True
}
Message = warlock.model_factory(schema)
m = Message(sender="who")
m.trace # got error
Experiencing this same issue myself, I can confirm by examining the test cases that there is no coverage for this behavior. I'm willing to put together a PR to handle this if one does not already exist on a fork somewhere.