Skip to content

Instantly share code, notes, and snippets.

@MTen
Created March 17, 2016 20:10
Show Gist options
  • Save MTen/1e57622cbb98734bff47 to your computer and use it in GitHub Desktop.
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.
{
"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"]}]
}
}
@MTen
Copy link
Author

MTen commented Mar 17, 2016

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