------------Josn schema-----------
{
\"type\": \"object\",
\"properties\": {
\"street_address\": {
\"type\": \"string\"
}
You would need to use "oneOf". Like so:
{
"type": "object",
"oneOf": [
{
"properties": {
"street_address": {
"type": "string"
},
"city": {
"type": "string"
}
},
"required": [
"street_address"
]
},
{
"properties": {
"street_address": {
"type": "string"
},
"state": {
"type": "string"
}
},
"required": [
"street_address"
]
}
]
}
You'll notice, it's a bit repetitive. Since, in your example, you only provide a "type" for each property, the repetition is not so bad. But if you have more complex properties, you could consider using deifinitions to define each property only once, at the top and then using $ref to reference the definition. Here's a good article on that.