dbt-labs / hologram

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

add shorthand for literal / simple enum types #2

Open cmcarthur opened 5 years ago

cmcarthur commented 5 years ago

json schema trivially supports enums with:

{
  "type": "string",
  "enum": ["option_one", "option_two"]
}

and the same syntax can be leveraged for literals:

{
  "type": "string",
  "enum": ["only_one_possible_value"]
}

however, in Python we have to convert our simple list "enums" into python Enums to get this behavior.

it'd be nice to have a shorthand for generating capital-E Enums from our list "enums" (and to also use it for simple literal values)