Adam Matan
Adam Matan

Reputation: 136341

JSON Schema: Definitions for array items

I am trying to define an array element in a JSON Schema. They array contains items from a type that is already defined in the definitions section of the schema.

I have tried:

"properties": {
    "userId": {"$ref": "#/definitions/userId"},
    "beacons": {
        "type": "array",
        "items": { "$ref": "#/definitions/beaconSchema" }
    }
}

The userId part is parsed with #/definitions/userId. The list items, however, ignore the #/definitions/beaconSchema and allow any old junk in it.

How can I use a JSON schema definition to parse all items in a JSON array?

Upvotes: 1

Views: 439

Answers (1)

Jason Desrosiers
Jason Desrosiers

Reputation: 24479

The schema fragment you posted is correct. I suggest you look for typos in the $ref path and definitions property name. If you don't find the problem there, try posting more of the schema.

Upvotes: 1

Related Questions