redhat-developer / yaml-language-server

Language Server for YAML Files
MIT License
1.01k stars 244 forks source link

fix: default value with special chars with anyOf #963

Open p-spacek opened 2 months ago

p-spacek commented 2 months ago

What does this PR do?

1) fixes a small specific issue when schema contains default value with special chars next to anyOf.

This schema

       {
          type: 'object',
          properties: {
            car: {
              type: 'object',
              required: ['engine'],
              properties: {
                engine: {
                  anyOf: [
                    {
                      type: 'object',
                    },
                    {
                      type: 'string',
                    },
                  ],
                  default: 'type$1234',
                },
              },
            },
          },

doesn't escape default value

note that an object with anyOf (engine) needs to be inside another object (car), then getInserTextForObject is called with schema { car: {engine: anyOf}}

2) fixes condition to allow null, 0, emptyString, false as a default or const

What issues does this PR fix or reference?

no ref

Is it tested? How?

unit-test

coveralls commented 2 months ago

Coverage Status

coverage: 84.305% (+0.1%) from 84.174% when pulling 26ec17a4f3f8621809ae8569e32fb6028f1c63b0 on jigx-com:fix/default-value-with-special-chars-with-anyOf into 7203630540f35c88731bcf03ac41ca90b5919125 on redhat-developer:main.

msivasubramaniaan commented 1 month ago

@p-spacek please rebase the repo