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 description" of json schemas when suggesting values #236074

Closed
ewen-lbh opened this issue Dec 13, 2024 · 4 comments
Closed

Show "enum description" of json schemas when suggesting values #236074

ewen-lbh opened this issue Dec 13, 2024 · 4 comments
Assignees

Comments

@ewen-lbh
Copy link

As per json-schema-org/json-schema-spec#57, documenting enum values of JSON schemas is done via a combination of oneOf and const subschemas.

However, when choosing which enum value to pick, the description of the corresponding const subschema is not shown on the right, making it kinda hard to pick a value.

Image

The description of the chosen value is shown on hover once the value is selected however.

Image

the relevant part of the JSON schema looks like this:

"orientation": {
			"description": "The orientation member is a string that serves as the default orientation for all  top-level browsing contexts of the web application.",
			"oneOf": [
				{
					"const": "any",
					"description": "Displays the web app in any orientation allowed by the device's operating system or user settings. It allows the app to rotate freely to match the orientation of the device when it is rotated. "
				},
				{
					"const": "natural",
					"description": "Displays the web app in the orientation considered most natural for the device, as determined by the browser, operating system, user settings, or the screen itself. It corresponds to how the device is most commonly held or used: On devices typically held vertically, such as mobile phones, natural is usually portrait-primary.  On devices typically used horizontally, such as computer monitors and tablets, natural is usually landscape-primary.  When the device is rotated, the app may or may not rotate so as to match the device's natural orientation; this behavior may vary depending on the specific device, browser implementation, and user settings."
				},
				{
					"const": "landscape",
					"description": "Displays the web app with width greater than height. It allows the app to switch between landscape-primary and landscape-secondary orientations when the device is rotated."
				},
				{
					"const": "portrait",
					"description": "Displays the web app with height greater than width. It allows the app to switch between portrait-primary and portrait-secondary orientations when the device is rotated."
				},
				{
					"const": "portrait-primary",
					"description": "Displays the web app in portrait mode, typically with the device held upright. This is usually the default app orientation on devices that are naturally portrait. Depending on the device and browser implementation, the app will typically maintain this orientation even when the device is rotated."
				},
				{
					"const": "portrait-secondary",
					"description": "Displays the web app in inverted portrait mode, which is portrait-primary rotated 180 degrees. Depending on the device and browser implementation, the app will typically maintain this orientation even when the device is rotated."
				},
				{
					"const": "landscape-primary",
					"description": "Displays the web app in landscape mode, typically with the device held in its standard horizontal position. This is usually the default app orientation on devices that are naturally landscape. Depending on the device and browser implementation, the app will typically maintain this orientation even when the device is rotated."
				},
				{
					"const": "landscape-secondary",
					"description": "Displays the web app in inverted landscape mode, which is landscape-primary rotated 180 degrees. Depending on the device and browser implementation, the app will typically maintain this orientation even when the device is rotated."
				}
			]
		},
@RedCMD
Copy link
Contributor

RedCMD commented Dec 13, 2024

VSCode also supports using "enumDescriptions" to list descriptions along side an enum
https://github.com/RedCMD/TmLanguage-Syntax-Highlighter/blob/main/vscode.tmLanguage.schema.json#L1013-L1152

@aeschli
Copy link
Contributor

aeschli commented Dec 16, 2024

This already works for me:

Image

To see the description press Ctrl + Space while the completion window is open ('See more')

@aeschli aeschli closed this as completed Dec 16, 2024
@ewen-lbh
Copy link
Author

huh weird... i guess the schema was cached by vscode somehow? i'll try again when i can

@RedCMD
Copy link
Contributor

RedCMD commented Dec 16, 2024

I dont think you're talking about the same schema file

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

No branches or pull requests

3 participants