redhat-developer / yaml-language-server

Language Server for YAML Files
MIT License
1.1k stars 265 forks source link

Added language setting option to skip runtime schema compilation #980

Closed aderende closed 4 months ago

aderende commented 4 months ago

Duplicate of https://github.com/redhat-developer/yaml-language-server/pull/967, fixed CI build

What does this PR do?

It adds skipSchemaValidation settings to enable/disable JSON schema validation.

By default, skipSchemaValidation is false, but if the integrator always calls configure with skipSchemaValidation = true, then the code schema07Validator = ajv.compile(jsonSchema07) will never get called. This allows the browser to avoid adding the unsafe-eval policy directive.

What issues does this PR fix or reference?

The ajv.compile(...) function requires the unsafe-eval policy directive for the script-src policy. https://github.com/eclipsesource/jsonforms/issues/1498

The skipSchemaValidation setting allows the application to avoid compiling the schema validator and prevents the need to use the unsafe-eval policy.

Is it tested? How?

A test case with skipSchemaValidation enabled has been added.