fuhrysteve / marshmallow-jsonschema

JSON Schema Draft v7 (http://json-schema.org/) formatting with marshmallow
MIT License
209 stars 72 forks source link

AttributeError: 'dict' object has no attribute 'data' on on List of Nested fields #62

Closed bnopne closed 6 years ago

bnopne commented 6 years ago

I get 'dict' object has no attribute 'data' when i try to generate JSON schema for a model which contains List of Nested fields, here is an example of broken code:

        class User(Schema):
            f1 = fields.Integer()

        class UserList(Schema):
            f2 = fields.List(fields.Nested(User))

        JSONSchema().dump(UserList())

Python 3.6.4 marshmallow==3.0.0b11 marshmallow-jsonschema==0.5.0

fuhrysteve commented 6 years ago

Thanks for the report!

Please see #61

this library is not yet compatible with marshmallow >= 3, but once we get a couple minor things sorted out on #61 we'll be good to go.

If you want to start playing around with it on v3, installing from @edgeware's fork should work in the meantime:

pip install -e 'git+https://github.com/edgeware/marshmallow-jsonschema.git@21633cfdbb13eb572727e14ca7b862613f0985d3#egg=marshmallow-jsonschema-dev'
bnopne commented 6 years ago

Thanks for clarification and help!

Switching marshmallow to 2.x.x helped me to solve the problem.

alkanen commented 6 years ago

@bnopne a proper fix for the issue was merged yesterday so you can use Marshmallow 3.x now if you want to.

bnopne commented 6 years ago

@alkanen Thanks a lot! May the Force be with you!