Created
March 17, 2016 20:10
-
-
Save MTen/1e57622cbb98734bff47 to your computer and use it in GitHub Desktop.
Example of how to use oneOf on a required property instead of on the object body.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"type": "array", | |
"items": { | |
"type": "object", | |
"description": "A product or piece of merchandise purchased with, points.", | |
"properties": { | |
"giftID": { | |
"type": "string", | |
"description": "A unique ID for differentiating gift objects" | |
}, | |
"inventoryCount": { | |
"type": "integer", | |
"description": "The number of gifts currently available. This property allows the gift's availability to differ from its item or merchandise. Specify -1 for unknown." | |
}, | |
"unitPoints": { | |
"type": "number", | |
"description": "The points required to purchase a single unit of this gift." | |
}, | |
"item": { | |
"properties": { | |
"itemID": {"type": "string"}, | |
"inventoryCount":{ "type":"number"} | |
}, | |
"required": ["itemID", "inventoryCount"] | |
}, | |
"merchandise": { | |
"type": "object", | |
"properties": { | |
"merchID": { | |
"type": "string" | |
} | |
}, | |
"required": ["merchID"] | |
} | |
}, | |
"required": [ | |
"giftID", | |
"inventoryCount", | |
"unitPoints" | |
], | |
"oneOf": [{"required": ["item"]}, {"required": ["merchandise"]}] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
working example of above on TV4