Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: nested anyof const #888

Merged

Conversation

p-spacek
Copy link
Contributor

@p-spacek p-spacek commented Jun 2, 2023

What does this PR do?

fix validation of nested anyOf consts
schema:

{
  "type": "object",
  "properties": {
    "options": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "form": {
              "type": "string"
            },
            "provider": {
              "type": "string",
              "const": "test1"
            }
          },
          "required": [
            "form",
            "provider"
          ]
        },
        {
          "type": "object",
          "properties": {
            "form": {
              "type": "string"
            },
            "provider": {
              "anyOf": [
                {
                  "type": "string",
                  "const": "testX"
                }
              ]
            }
          },
          "required": [
            "form",
            "provider"
          ]
        }
      ]
    }
  }
}

will produce this error:
image

Screen.Recording.2023-06-02.at.12.59.40.mov

note that 'missing form property' is necessary to trigger the bug (there has to be some problem in both subSchemas)
order of the object in anyOf is also important

What issues does this PR fix or reference?

no existing issue

Is it tested? How?

unit test

@coveralls
Copy link

Coverage Status

coverage: 83.328% (+0.02%) from 83.304% when pulling 85360c8 on jigx-com:fix/nested-anyof-const into 53d58ed on redhat-developer:main.

Copy link
Collaborator

@gorkem gorkem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good. If you can rebase and adjust to the testing changes main we are good to go.

},
},
};
languageService.addSchema(SCHEMA_ID, schema);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you rebase this commit to head and use schemaProvider.addSchema it is the new mechanism for feeding schemas for tests and since we have removed the earlier hack in the parser this will probably fail.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, @gorkem done,

I also pushed a small change for const matching.
there was a small inconsistency between enum and const match.
Enum allows having a partial match, but const had to be exactly the same.

It's a little bit related to this PR, so sorry for putting it together...

@coveralls
Copy link

Coverage Status

coverage: 83.8% (+0.04%) from 83.762% when pulling 20c9b2e on jigx-com:fix/nested-anyof-const into bddfbff on redhat-developer:main.

@p-spacek p-spacek requested a review from gorkem July 7, 2023 11:32
Copy link
Collaborator

@gorkem gorkem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@msivasubramaniaan msivasubramaniaan merged commit c2c2979 into redhat-developer:main Jul 10, 2023
4 checks passed
Copy link
Contributor

@msivasubramaniaan msivasubramaniaan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants