dbt-labs / hologram

A library for automatically generating Draft 7 JSON Schemas from Python dataclasses
MIT License
9 stars 13 forks source link

Support decoding `Any` fields as "Any valid JSON" #18

Closed beckjake closed 5 years ago

beckjake commented 5 years ago

When I say "JSON value" below, I mean any of None, str, bool, int, float, lists of JSON values, or dicts of str -> JSON values.

When decoding values that can be any valid JSON object, instead of emitting a useless warning about "Unable to decode a value" just return the value: basically assume it's a valid JSON value. The encoder already does this for all unknown values, and the schema generator adds no information (Dict[str, Any] becomes {"type": "object"}).

There's reasonable precedent: hologram already uses Any in its JsonDict type definition to implicitly mean "Any JSON value".