warlock icon indicating copy to clipboard operation
warlock copied to clipboard

Default fields not declared on Object

Open dmvieira opened this issue 6 years ago • 1 comments

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

dmvieira avatar Mar 02 '20 18:03 dmvieira

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.

minelminel avatar Aug 31 '21 17:08 minelminel