cwacek / python-jsonschema-objects

Automatic Python binding generation from JSON Schemas
MIT License
364 stars 96 forks source link

Nested Pattern Properties in definition not handled properly #220

Closed bdanofsky closed 8 months ago

bdanofsky commented 3 years ago

Describe the bug Having a Pattern property in a definition referenced as part of the overall schema always fails with ValidationError

Example Schema and code { "title": "mypattern", "definitions":{ "baz":{ "type": "object", "patternProperties": { "^[a-zA-Z0-9_]$": { "type": "string" } } } }, "type": "object", "properties":{ "abc": {"$ref": "#/definitions/baz"} }, "default": { "abc":{}} }

usage might be as follows:

builder = pjs.ObjectBuilder('pattern4.json') ns = builder.build_classes(standard_names=False) pattern = ns.mypattern() pattern.abc = {} pattern.abc.foo = "something wicked this way comes" or setattr(pattern.abc, 'foo', "more wicked stuff") or pattern.abc['foo'] = "less wicked but more complex"

I get the error TypeProxy object .... was neither a literal nor a schema wrapper

Expected behavior Ideally one should be able to use pattern properties as any level of the schema