I'm migrating some API endpoints to a more concise way. But I'm having some issues about how to handle nested objects.
For example:
I have an object Foo
and a Bar
.
Foo v1.0
{
"field_one": "String",
"field_two": "String"
}
Foo v1.1
{
"field_one": "String",
"field_two": "String",
"field_three": "String"
}
Bar v1.0
{
"foo": "Foo",
"field_one": "String",
"field_two": "String"
}
For an endpoint to get Foo
the version is pretty straightforward, is v1.0
or v1.1
,
but how do I handle an endpoint for Bar
? Every change to a child should "generate"
a new version for the parent? How to handle if the parent have more than one versioned child?
If Bar
has another child Baz
with two different versions, the versioning of Bar
will keep
going with the iterations of the children?
Bar v1.0 -> Foo v1.0
Bar v1.1 -> Foo v1.1
Bar v2.0 -> Foo v1.1 + Baz v1.0
How to make it straightforward so, if the consumer want to use the Foo v1.1
on his whole application, he knows which version of Bar
should he get? Just documentation or there are some pattern behind it?