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

code completion breaks when anyOf defines required properties. #205

Open
manoj-pillay-10gen opened this issue Sep 8, 2023 · 2 comments
Open

Comments

@manoj-pillay-10gen
Copy link

#204 describes an issue with anyOf (and oneOf) error messaging. However, one way to solve this is to provide a schema-specific error message using the custom JSON property errorMessage as illustrated in this example.

However, the use of the required property (or the dependencies property) on anyOf subschemas will prevent monaco from surfacing it as a valid suggestion. In my example above, p1.shape can be fulfilled by both rectangle and square. However, the only autocomplete option that gets offered is rectangle

Screenshot 2023-09-08 at 12 25 21 PM

The reason this occurs is because the square subschema defines a required field side that is only available within that schema. It essentially ends up making square a hidden option for p1.shape critically breaking the expected completion.

PS: If side were to be removed from the required array in L62 of the example, completions start working as expected.

Screenshot 2023-09-08 at 2 19 18 PM

@jeremyfiel
Copy link
Contributor

if you remove type: string it surfaces the error. This is a bug in the monaco implementation.

image

This one has got it right. https://json-schema.hyperjump.io

image

@manoj-pillay-10gen
Copy link
Author

The problem highlighted in this github issue is that code completion does not work as expected and only offers one among many choices that may be available for the property defined using the oneOf/anyOf construct. I wonder if the issue is more with vscode-json-languageservice treatment of oneOf/anyOf rather than it being with monaco itself.

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

2 participants