Skip to content
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

Show enum values on hover #941

Closed
twelvelabs opened this issue Dec 3, 2023 · 1 comment · Fixed by #942
Closed

Show enum values on hover #941

twelvelabs opened this issue Dec 3, 2023 · 1 comment · Fixed by #942

Comments

@twelvelabs
Copy link
Contributor

Is your enhancement related to a problem? Please describe.

I maintain a JSON Schema document for a YAML config file. That document has a number of ENUMs, and when my users hover over those fields they see the title and description from the schema, but not the allowed values.

The values are shown on autocomplete, but that's much less discoverable that having it displayed on hover w/ the other documentation.

Describe the solution you would like

I would like to see enum options shown underneath the description on hover - much like how example values are displayed:

ENUM TITLE

Some description...


Allowed values:

- `ENUM1`
- `ENUM2`
- `ENUM3`
@twelvelabs
Copy link
Contributor Author

twelvelabs commented Dec 3, 2023

Digging through the code, it looks like there is some logic to show enums

if (s.schema.enum) {
const idx = s.schema.enum.indexOf(getNodeValue(node));
if (s.schema.markdownEnumDescriptions) {
markdownEnumValueDescription = s.schema.markdownEnumDescriptions[idx];
} else if (s.schema.enumDescriptions) {
markdownEnumValueDescription = toMarkdown(s.schema.enumDescriptions[idx]);
}
if (markdownEnumValueDescription) {
enumValue = s.schema.enum[idx];
if (typeof enumValue !== 'string') {
enumValue = JSON.stringify(enumValue);
}
}
}

But:

  • It requires the use of some non-standard properties (at least according to the JSON Schema spec): markdownEnumDescription, enumDescriptions.
  • It only shows info for the currently selected enum - not the full list of available options.

What do y'all think about changing the behavior so that:

  • It displays all enum options (maybe truncated to some upper bound w/ a "... plus N more" note).
  • Keep the *Descriptions logic, but fall back to just showing the enum sans-description if no descriptions are present.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant