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

Error when validating Json against a schema defining oneOf #360

Open
alvaroacev opened this issue Jan 17, 2021 · 0 comments
Open

Error when validating Json against a schema defining oneOf #360

alvaroacev opened this issue Jan 17, 2021 · 0 comments

Comments

@alvaroacev
Copy link

Hi,
The method validate from com.fasterxml.jackson.databind.JsonNode is returning following error:

com.github.fge.jsonschema.core.report.ListProcessingReport: failure
--- BEGIN MESSAGES ---
error: object instance has properties which are not allowed by the schema: ["postal_code","street"]
    level: "error"
    schema: {"loadingURI":"#","pointer":"/properties/address"}
    instance: {"pointer":"/address"}
    domain: "validation"
    keyword: "additionalProperties"
    unwanted: ["postal_code","street"]
---  END MESSAGES  ---

When validating what it seems a valid schema and test

Schema:

"schemas": {
      "Legal": {
        "title": "Legal",
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "solicitor": {
            "type": "string"
          },
          "address": {
            "oneOf": [
              {
                "properties": {
                  "street": {
                    "type": "string"
                  },
                  "postal_code": {
                    "type": "string"
                  }
                },
                "required": [
                  "street"
                ]
              },
              {
                "properties": {
                  "email": {
                    "type": "string",
                    "format": "email"
                  }
                },
                "required": [
                  "email"
                ]
              }
            ],
            "type": "object"
          }
        },
        "required": [
          "id"
        ]
      }
    }
  }

Test:

{
  "id": 1,
  "solicitor": "My solicitor",
  "address": {
    "street": "Mark Lane 55",
    "postal_code": "NE1 3DQ"
  }
}

Please can you have a look at it?

Many thanks

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

No branches or pull requests

1 participant