Closed a0js closed 1 month ago
I like this idea (although I'm not a maintainer of this project).
Although, it might be cool to instead using the meta:enum
syntax that the https://github.com/adobe/jsonschema2md library already supports for documenting enums.
It might help for projects that use both this library and that library!
For reference, the syntax is instead an object of enum value to enum description, e.g. (adapted from https://github.com/adobe/jsonschema2md/blob/e6c52a8e1d5806717f3070adda67bd9173613056/test/fixtures/enums/enum-meta-enum.schema.json):
{
"type": "string",
"enum": [
"baa",
"bad",
"bag",
"bah",
"bam",
"ban",
"bap",
"bas",
"bat",
"bay"
],
"meta:enum": {
"baa": "the sounds of sheeps",
"bad": "German bathroom",
"bag": "holding device",
"bah": "humbug!",
"bam": "a loud sound",
"ban": "don't do this",
"bap": "a British soft bread roll",
"bas": "from ancient Egyptian religion, an aspect of the soul",
"bat": "…out of hell",
"bay": ", sitting by the dock of the"
}
}
Is there a reason you need enum comments specifically? JSON-Schema supports this today, you just need to express it a little differently, using anyOf
and const
. See https://stackoverflow.com/a/64296043/435124.
Hi! 👋
Firstly, thanks for your work on this project! 🙂
Today I used patch-package to patch
json-schema-to-typescript@14.0.5
for the project I'm working on.I needed a way to add JSDoc descriptions for each enum value in a named enum. I'd be happy to open a PR for adding this functionality, if you think it would be worth doing.
Here is the diff that solved my problem:
This issue body was partially generated by patch-package.