Open
Description
What should this feature add?
I defined an enum like so:
Datasets = Enum("Datasets", ((s, s) for s in list_available_datasets()), type=str)
and it shows up okay in /docs:
[excerpt from the invocation's section in /docs]
Markov Name Data Loader
description: | Load data for the Markov Name Generator. |
---|---|
id* | Id[...] |
is_intermediate | Is Intermediate[...] |
workflow | Workflow[...] |
use_cache | Use Cache[...] |
name* | string - title: Datasets - input: any - ui_hidden: false - An enumeration.Enum:[ religions, cities_worldwide, pokemon_modern, snakes_common_names, english_towns, breakfast_cereals, … ] |
type* | Type[...] |
but the field doesn't display as an input on the node editor. the browser log says
Skipping unknown input field type
Alternatives
We can also use "Literals" for the purpose of giving OpenAPI a list of permissible values:
Datasets = Literal[tuple(list_available_datasets())]
but I feel like using Python's provided Enum constructor is a less hacky approach than giving a non-literal initializer to Literal
.
and enums should work according to https://docs.pydantic.dev/latest/usage/types/enums/