s-knibbs / dataclasses-jsonschema

JSON schema generation from dataclasses
MIT License
167 stars 38 forks source link

Optional type check fails with optional union type #76

Closed s-knibbs closed 5 years ago

s-knibbs commented 5 years ago

The following type does not currently get identified as optional:

Optional[Union[int, float]]

This is because the code is looking for type(None) as the second value in the __args__ array but does not take into account the flattening of Union types (Optional is an alias of Union[T, type(None)]).