redhat-developer / yaml-language-server

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

fix: array default value #968

Open p-spacek opened 6 months ago

p-spacek commented 6 months ago

What does this PR do?

fix the issue when a default value is an array with object items

this schema

        {
          type: 'object',
          properties: {
            garage: {
              type: 'array',
              items: {
                type: 'object',
              },
              default: [
                {
                  car: {
                    engine: { fuel: 'gasoline' },
                    wheel: [1, 2],
                  },
                },
                {
                  car: {
                    engine: { fuel: 'diesel' },
                  },
                },
              ],
            },
          },

produced invalid yaml before:

garage:
 - [Object object]

after fix:

garage:
  - car:
      engine: 
         fuel: gasoline
      wheel:
         - 1
         - 2
  - car:
       engine:
          fuel: diesel

after the fix, it will correctly process the default value with the object array

Is it tested? How?

added tests

coveralls commented 6 months ago

Coverage Status

coverage: 84.201% (+0.03%) from 84.174% when pulling ce643a9b89c84d3d457637840481bb2da74c101c on jigx-com:fix/array-default-value into 7203630540f35c88731bcf03ac41ca90b5919125 on redhat-developer:main.