Skip to content

Commit

Permalink
Merge pull request #163 from cwacek/feature/fix-156
Browse files Browse the repository at this point in the history
bugfix: Fix #156.
  • Loading branch information
cwacek authored Jun 6, 2019
2 parents 5d4f01b + b2d7b7d commit 8b7a5dc
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions python_jsonschema_objects/classbuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ def __new__(cls, **props):
cls, klass))
try:
obj = klass(**props)
obj.validate()
except validators.ValidationError as e:
validation_errors.append((klass, e))
else:
Expand Down
18 changes: 18 additions & 0 deletions test/test_regression_156.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import pytest # noqa
import python_jsonschema_objects as pjo


def test_regression_156(markdown_examples):
builder = pjo.ObjectBuilder(markdown_examples['MultipleObjects'], resolved=markdown_examples)
classes = builder.build_classes(named_only=True)

er = classes.ErrorResponse(message="Danger!", status=99)
vgr = classes.VersionGetResponse(local=False, version="1.2.3")

# round-trip serialize-deserialize into named classes
classes.ErrorResponse.from_json(er.serialize())
classes.VersionGetResponse.from_json(vgr.serialize())

# round-trip serialize-deserialize into class defined with `oneOf`
classes.Multipleobjects.from_json(er.serialize())
classes.Multipleobjects.from_json(vgr.serialize())

0 comments on commit 8b7a5dc

Please sign in to comment.