fuhrysteve / marshmallow-jsonschema

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

JSON Schema generation raises UnsupportedValueError on marshmallow.fields.* subclasses #79

Closed yeralin closed 5 years ago

yeralin commented 5 years ago

Hi,

I have a rather unusual problem. I have a wrapper on top of marshmallow.fields.* classes. Something similar to:

from marshmallow.fields import String

class CustomString(String):
    ...

When I try to generate a JSON schema that contains one of those wrapped fields like CustomString, the generator raises UnsupportedValueError. After looking at the code, I noticed this line: https://github.com/fuhrysteve/marshmallow-jsonschema/blob/master/marshmallow_jsonschema/base.py#L158

Where my field.__class__ resolves to CustomString while mapping contains marshmallow.fields.String.

That was a bummer. I wrote a quick PR for this issue that instead checks whether field's class is a subclass of one of the marshmallow.fields.*.

Feel free to share your thoughts about it!

Thank you! ❤️