fuhrysteve/marshmallow-jsonschema

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

Closed this issue · 0 comments

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! ❤️