cardinalby / schema-validator-action

JSON Schema validator Action
MIT License
11 stars 2 forks source link

YAML parser does not support inheritance #13

Open richardhj opened 1 week ago

richardhj commented 1 week ago

There is a YAML feature called "inheritance and include".

Example:

# Define a base configuration
base_config: &base
  key1: value1
  key2: value2

# Inherit from the base configuration
derived_config:
  <<: *base
  key3: value3

The npm yaml package does not support this syntax. There is an easy fix for this: using js-yaml.

Current error demonstrating that inheritance/include is not working:

 Contents of 'config.yaml' has been parsed as yaml object
Error: Invalid #/applications/app/php (schema path: #/properties/applications/additionalProperties/required) <-- it shows me a required attribute is missing even though it is there in the base
Error: Invalid #/applications/app/<< (schema path: #/properties/applications/additionalProperties/additionalProperties) <-- it interpretes "<<" as property (which is not there)
cardinalby commented 1 week ago

Hi! Thanks for the note, added js-yaml, updated @master. Can you check it on your examples and confirm it works?

richardhj commented 1 week ago

I am testing against the master version, it is working like a charm. Thanks!!

Screenshot 2024-06-27 at 21 58 21
cardinalby commented 1 week ago

Thanks, merged to v3 as well