ui5-tooling
ui5-tooling copied to clipboard
No code suggestions/auto-completion for `ui5.yaml` based on JSON schema
For SAP UI5 Tooling ui5.yaml there is a JSON schema https://sap.github.io/ui5-tooling/schema/ui5.yaml.json, which is supposed to assist when working with ui5.yaml.
The problem is that this schema doesn't provide a code suggestions/auto-completion aka IntelliSense.
More precisely, it does it but only for the two items: specVersion and kind:

And when I chose specVersion, it suggests me a version number: 2.5, 2.4, etc. But when I chose one of the proposed values, it turns out that it's specVersion: 2.5 instead of required specVersion: "2.5", so the specVersion is proposed as a number rather than a string.
For the rest of the items there is no suggestions at all.
Context
- UI5 Module Version (output of
ui5 --versionwhen using the CLI):"@ui5/cli": "^2.12.1" - Node.js Version:
16.9.1 - npm Version:
7.23.0 - OS/Platform:
Winndows 10 x64 21H1
Once you declared a specification version greater than 2 (e.g. specVersion: "2.5"), additional suggestions should come up. Can you confirm that?
It's indeed an issue that the autocompletion does not put the version number into quotes. I'm not sure whether this is an issue with the schema or the way we validate it though.
Can you confirm that?
No! That's the point, no suggestions appear:

It's indeed an issue that the auto-completion does not put the version number into quotes. I'm not sure whether this is an issue with the schema or the way we validate it though.
It's a schema problem, there is a need to add "type": "string" to the specVersion definition:
"specVersion": {
"enum": [
"2.5",
"2.4",
"2.3",
"2.2",
"2.1",
"2.0",
"1.1",
"1.0",
"0.1"
],
"type": "string",
"errorMessage": "Unsupported \"specVersion\"\nYour UI5 CLI installation might be outdated.\nSupported specification versions: \"2.5\", \"2.4\", \"2.3\", \"2.2\", \"2.1\", \"2.0\", \"1.1\", \"1.0\", \"0.1\"\nFor details see: https://sap.github.io/ui5-tooling/pages/Configuration/#specification-versions"
}
Can you confirm that?
No! That's the point, no suggestions appear:
This I cannot reproduce. Once a spec-version >2 is set, suggestions work with the LSP-yaml plugin for Sublime Text:

May I ask which IDE (and schema-plugin, if any) you are using?
It's a schema problem, there is a need to add
"type": "string"to thespecVersiondefinition:
Thanks! We will look into it 👍
May I ask which IDE (and schema-plugin, if any) you are using?
IntelliJ IDEA 2021.2.2
Schema file: https://sap.github.io/ui5-tooling/schema/ui5.yaml.json
What do you mean under «schema-plugin»?
@matz3 could you look into the missing "type": "string" declaration mentioned in https://github.com/SAP/ui5-tooling/issues/560#issuecomment-923271887 ?
I asked @svbender to check whether he can reproduce the missing suggestions in WebStorm
Even when adding "type": "string", the auto-suggestion (via https://github.com/redhat-developer/yaml-language-server) uses a number.
So this seems to be a bug in the yaml-language-server.
@pubmikeb can you confirm that adding "type": "string" solves this problem in your IDE?
Can you confirm that adding
"type": "string"solves this problem in your IDE?
I've tested the case on two file types:
- On JSON-file, there everything is OK:

- On YAML-file, there
"type": "string"doesn't ensure a string-type for the proposed value.
P.S. What is the added-value to use YAML over JSON as a config file for UI5 Tooling?
I have tested the schema with WebStorm and can reproduce the issues.
-
If you start with an empty
ui5.yamlthe IDE proposes to add the missing requirementsspecVersionandtype, if I accept it, they are added with 1 indentation (2 spaces) which results in further confusion because there is no auto-completion for both and on top level the auto-completion suggests anotherspecVersionentry. You need to remove the spaces. -
Auto-completion suggestions for
kindare working but not fortype. The good thing is that in the "Problems" tab/window of the IDE all possible enum values are shown correctly. For example:Schema validation: Value should be one of: "application", "library", "theme-library", "module" -
The
specVersionstring handling is not working as expected. Auto-completion is showing all available versions but they are not added with quotes.- Adding
"type":"string"tospecVersionin the schema has no effect beside that the IDE shows the problemSchema validation: Incompatible types. Required: string. Actual: number.. The quotes are not added automatically. - Adding single quotes in the schema works, but had the effect that the validator is not able to recognize the value even if it is in the enum list:
Schema validation: Value should be one of: "2.5", "'2.4'", "2.3", "2.2", "2.1", "2.0", "1.1", "1.0", "0.1"
- Adding
I think this issues are related to the IDE and the used parser.
WebStorm/IntelliJ is not using a separate plugin for that, it is a built-in feature. The schema is used automatically from https://www.schemastore.org/json/ , but you can overwrite the usage in the configuration: https://www.jetbrains.com/help/ruby/yaml.html#remote_json (It should be the same configuration for all IntelliJ based IDEs.)
I've opened a ticket at WebStorm: https://youtrack.jetbrains.com/issue/WEB-52885
Closing, as it's a third-party issue.