Hi All, what are some options for documenting the individual items in an enum? I'd like to do something similar to these examples, which obviously do not work:
[:enum [:and {:doc "the first integer greater than zero"} 1] 2 3]
[:enum ^{:doc "the first integer greater than zero"} 1 2 3]I find it hard to get my head around this. Enums are usually self-descriptive: "these are all the possible values". What is the use-case for having the need to document the values and not the enum itself?
My use case is values which are short forms of longer, more descriptive names. For example:
[:enum "l" "m" "h"]
You can probably infer that this is low, medium, and high, but I would prefer to document exactly what these short strings mean.Is the documentation for the developer or for some other users of the schema / data?
Currently just for me
In that case I would either just use the longer names in the enum, unless there's a good reason to use the abbreviations. If there's a reason, then you could have something like this
(def sizes
{"l" "large"
"m" "medium"
"s" "small"})
(def my-schema (into [:enum] (keys sizes)))Thanks, I'll go with that second option and just document on the enum where to go for more info about the values.
Yep, if your editor is configured correctly, you should be able to "jump to definition" directly from sizes symbol in the schema.
OpenAPI doesn't support docstring per enum value either. They recommend using the description field of the enum schema: https://swagger.io/docs/specification/v3_0/data-models/enums/