✔️ JSON Schemahard
7. One of two shapes (oneOf)
Write a schema for an object with a required "id" that may be EITHER a string OR an integer — but nothing else (no boolean, no object). Use oneOf.
How to approach this
"oneOf" (also "anyOf") lets a value satisfy one of several sub-schemas — the way a field accepts multiple valid forms. Put "oneOf": [ { "type": "string" }, { "type": "integer" } ] on the property. "oneOf" requires EXACTLY one branch to match; "anyOf" requires at least one. A boolean matches neither branch, so it is rejected.
schema.json