s-knibbs / dataclasses-jsonschema

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

Fields inherited from a base can now be narrowed. #112

Closed jameskeane closed 4 years ago

jameskeane commented 4 years ago

This is useful if, for example, an inherited object specifies a string literal in place of the more generic 'str'.

Shape(type=str)
Rectangle(type='rect')
Triangle(type='tri')

fixes #108

s-knibbs commented 4 years ago

Looks good to me.

In theory it should be possible to raise an error if a conflicting type is used in a base class (e.g str & int) since this will create a schema that won't validate against anything. But this is good enough for now.

jameskeane commented 4 years ago

Thanks!