malli icon indicating copy to clipboard operation
malli copied to clipboard

Feature request: enum value descriptions

Open viebel opened this issue 2 years ago • 1 comments

Sometimes, the enumerated values are not clear enough by themselves. It would be nice to have a standard way to provide a description for each enumerated value.

Following our discussion on Slack, a nice solution would be to have :enumn (similar to :catn) that support description of enumerated values, like this:

[:enumn 
   ["foo" {:description "foo means that you don't know how to name things"}] 
   ["bar"] 
   "baz"]

Where some enumerated values have description and some don't.

Open question

Is there a way to pass the description of enumerated values to Swagger? JSON Schema doesn't seem to support description for enumerated values.

viebel avatar Jan 10 '22 09:01 viebel

If https://github.com/metosin/malli/issues/651 makes it in, enums values could be vars:

[:enum #'foo #'bar #'baz] ;; equivalent to [:enum foo bar baz]

So one could get the description of #'foo by querying its :doc metadata (per standard Clojure semantics).

vemv avatar Mar 07 '22 15:03 vemv