-
Notifications
You must be signed in to change notification settings - Fork 106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for meta:enum #227
Comments
PR merged and released, thanks! |
I've been looking for documentation on this feature, and great to see it merged! It might be worth mentioning some already-existing real-world use of this feature :-)
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
JSON Schema does not allow enum values to be documented. The project recommends using oneOf/anyOf combined with an object with a const and description as a workaround. This is documented here. This approach, while it does work, breaks most documentation tools that assume a choice like that has limited options, verses a list of enums with a lot more options to choose from. IMO, this is a workaround that does not address the core issue that the enum support in JSON schema has serious design issues.
To work around this issue, Adobe devises a simple way using a
meta:enum
property to document the enums and their descriptions. This method was originally proposed by the JSON Schema authors themselves as a possible solution. Support formeta:enum
can be found at https://github.com/adobe/jsonschema2md and is additionally supported by other open source and commercial tools. The approach is briefly discussed here: https://stackoverflow.com/questions/64233370/in-json-schema-how-to-define-an-enum-with-description-of-each-elements-in-the-eCurrently some schemas overload the description field with a long list of enum descriptions. It's an ugly approach since JSON does not support line breaks, and in using this approach, it makes merging and identifying diffs very difficult, since everything is on a single line of text.
Proposal
Add
meta:enum
support so that simple enum values (typically strings) can be easily documented.An actual implementation looks like this:
When implemented, the generated Javascript documentation can look like this:
If implemented in the markdown templates, this could result in a table with two columns, one for the enum value and another for the description, such as:
The text was updated successfully, but these errors were encountered: