Aller au contenu principal

JSON Schema Validation (without LSP)

If you are using an editor that does not yet support LSP, or if you simply want lightweight YAML validation without the full LSP server, you can use any YAML Language Server — such as the RedHat YAML extension for VS Code — pointed at the OPC UA Modeler JSON Schema.

Note: This gives you JSON Schema validation only (Layer 1 — structural checks: wrong keys, missing required fields, bad value types). For semantic validation (type references, browse path checks, hover docs, quick fixes) you need the full LSP server instead.


Step 1 — Install the RedHat YAML extension

The schema-based validation relies on the YAML Language Server provided by the YAML extension by RedHat.

Install everything in one command

If you already have opcua-modeler installed, running:

opcua-modeler install-extension

automatically installs both the OPC UA Modeler extension and the RedHat YAML extension as a companion — no separate step needed. Skip to Step 2 if you used this command.

If you want to install the RedHat YAML extension on its own:

code --install-extension redhat.vscode-yaml

Or via the VS Code Marketplace (Ctrl+Shift+X → search "YAML" by RedHat).


Step 2 — Add the schema pragma to your YAML file

The YAML Language Server reads a special pragma comment on the very first line of your .model.yaml file to know which JSON Schema to apply:

# yaml-language-server: $schema=https://support.sterfive.com/nodeset2.schema.json

This single comment is enough — the extension fetches the schema automatically and activates IntelliSense for that file. No other configuration is required.

What is this pragma?

The # yaml-language-server: $schema=<url> comment is a convention understood by any editor running the yaml-language-server. It works in VS Code (RedHat YAML extension), Neovim (with yaml-language-server configured), Zed, and others.

Using a local copy of the schema

New in v2.6.0

If you are working offline or want to pin a specific schema version, install a local copy first:

# Copy the schema into your project folder (current directory)
opcua-modeler install-schema

# Or specify an output directory
opcua-modeler install-schema --output ./schemas

Then reference it with a path relative to your YAML file:

# yaml-language-server: $schema=./schemas/nodeset2.schema.json

Step 3 — (Optional) Set a workspace-wide schema mapping

Instead of adding the pragma to every file, you can configure the schema once for all .model.yaml / .nodeset.yaml files in your project.

Add the following to your .vscode/settings.json:

{
"yaml.schemas": {
"https://support.sterfive.com/nodeset2.schema.json": [
"*.model.yaml",
"*.nodeset.yaml",
"*.model.yml",
"*.nodeset.yml"
]
}
}

With this in place, every matching file gets schema validation automatically — no pragma comment needed on each file.


What you get

Once set up, the RedHat YAML extension provides:

FeatureAvailable
Unknown key detection
Required field checking
Value type validation
Enum value suggestions (fixed-value fields)
OPC UA type reference validation❌ (needs LSP)
Browse path completions❌ (needs LSP)
Hover documentation❌ (needs LSP)
Quick-fix code actions❌ (needs LSP)

Upgrade path

Once you install the full opcua-modeler CLI and the VS Code Extension, the LSP server supersedes the YAML extension's schema checking entirely. You can keep the pragma comment — it is harmless — or remove it once the extension is active.