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

anyOf with differing types in schema results in incorrect validation error #1690

Closed
therockstorm opened this issue Aug 26, 2020 · 3 comments
Closed
Assignees

Comments

@therockstorm
Copy link

therockstorm commented Aug 26, 2020

Version

4.0.0-milestone4

Do you have a reproducer?

Using the below schema, if I make the below request with an invalid field name such that if fails to match any of the anyOf types, I get the error, $.data.relationships.source.data.id: object found, string expected. However, the field can be either a string or an object.

Minimal reproducible schema

relationships:
  type: object
  required: [source]
  properties:
    source:
      anyOf:
        - type: object
          required: [data]
          properties:
            data:
              type: object
              required: [id]
              properties:
                id:
                  type: string
        - type: object
          required: [data]
          properties:
            data:
              type: object
              required: [id]
              properties:
                id:
                  anyOf:
                    - type: string
                    - type: object
                      required: [pId, rId]
                      properties:
                        pId:
                          type: string
                        rId:
                          type: string

Request body causing error

"relationships": {
  "source": {
    "data": {
      "type": "animal",
      "id": {
        "xxx": "x",
        "rId": "y"
      }
    }
  }
}

@therockstorm therockstorm added the bug Something isn't working label Aug 26, 2020
@tsegismont tsegismont added component/openapi and removed bug Something isn't working labels Aug 27, 2020
@tsegismont
Copy link
Contributor

@slinkydeveloper can you have a look? Thanks!

@slinkydeveloper
Copy link
Member

Hi @therockstorm thanks for opening the issue, can you open the issue here? https://github.com/eclipse-vertx/vertx-json-schema

I think the reason is that we're just picking one of the validation failures https://github.com/eclipse-vertx/vertx-json-schema/blob/master/src/main/java/io/vertx/ext/json/schema/common/AnyOfValidatorFactory.java

@therockstorm
Copy link
Author

Created eclipse-vertx/vertx-json-schema#14

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

No branches or pull requests

3 participants