Skip to content

Can't validate array of items with anyOf #647

Closed
@ovidals

Description

@ovidals

I have an object with two properties, one of them is type array and can contain multiple definitions inside, my schema definition is this:

{ "id": "public/doc/json_schema", "type": "object", "required": [ "code", "data" ], "additionalProperties": false, "properties": { "code": { "type": "number", "example": 200 }, "data": { "type": "object", "required": [ "message", "feed" ], "additionalProperties": false, "properties": { "message": { "type": "string", "example": "User feed information" }, "feed": { "type": "array", "items": { "anyOf": [ { "$ref": "./event/event_sport_activity_rewarded.json" }, { "$ref": "./event/event_voucher_acquired.json" }, { "$ref": "./event/event_challenge_accepted.json" }, { "$ref": "./event/event_challenge_completed.json" }, { "$ref": "./event/event_challenge_abandoned.json" }, { "$ref": "./event/event_challenge_expired.json" } ] } } } } } }

All the schemas inside anyOf starts like this:

{ "type": "object",

Am I missing something? when I try to validate an array with some events that match any of theses, random errors are fired indicating that some field is missing (a field from another schema).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions