s-knibbs / dataclasses-jsonschema

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

Any type should generate an empty field schema #100

Closed ZdenekM closed 5 years ago

ZdenekM commented 5 years ago

The following definition:

@dataclass
class Parameter(JsonSchemaMixin):

    id: str
    type: ParameterTypeEnum
    value: Any

leads to schema like this:

{'type': 'object', 'required': ['id', 'type', 'value'], 'properties': {'id': {'type': 'string'}, 'type': {'type': 'string', 'enum': ['string', 'double']}, 'value': {'type': 'object'}}}

But I would rather see:

{'type': 'object', 'required': ['id', 'type', 'value'], 'properties': {'id': {'type': 'string'}, 'type': {'type': 'string', 'enum': ['string', 'double']}, 'value': {}}}

...where type for value is ommited, which means that value could be data of any type (string or number in this case). Is there a way how to achieve it? Many thanks.

ZdenekM commented 5 years ago

Great, thanks!