I need to represent various data and basically combine multiple json schema into one. As far as I understand this can be accomplished in two ways:
- using allOf
- using properties
Is there any difference between them? Could something that I would write as property be invalid if I write in a new schema appended in allOf-> property and vice-versa?
They are pretty different. Informal meaning:
Relating to your last question, if you make exactly the same constraints in a property, and in a schema within the allOf key, you will have the same semantics.
But in an allOf clause you may have a more rich set of constraints that affect not only a property but the object itself (maxProperties, additionalProperties, patternProperties, etc.). It can also be used to organize complex schemas or split domains.