cwacek/python-jsonschema-objects

Array validation fails if array items are unspecified

Closed this issue · 1 comments

Consider this schema:

{
    "title": "foo",
    "type": "object",
    "properties": {
        "arr": {
            "type": "array"
        }
    }
}

When I try to instantiate the schema, I cannot use the property arr:

ob=pjs.ObjectBuilder(schema)
cl=ob.build_classes()
cl.Foo(arr=[1,2,3])

This raises an exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3/dist-packages/python_jsonschema_objects/classbuilder.py", line 197, in __init__
    setattr(self, prop, props[prop])
  File "/usr/lib/python3/dist-packages/python_jsonschema_objects/classbuilder.py", line 223, in __setattr__
    prop = getattr(self.__class__, self.__prop_names__[name])
AttributeError: type object 'foo' has no attribute 'arr'

The same happens when I instantiate Foo first and then try to assign arr. Interestingly, repr(cl.Foo()) shows the property: '<foo arr=None>'

stale commented

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.