The first schema would always match both possibilities (additional properties are always allowed and ignored), so the assumption that only one schema ever matches is not true.
We don't want to use anyOf all the time though, because it makes some cases harder e.g. when you have string|int because here the assumption is correct.
The current assumption that a union type is equivalent to oneOf is not correct.
The PHP type annotation
would mean the JSON would always be either
or
The OpenAPI spec mandates that exactly ONE schema matches the data. No more no less. Our generated spec would look like
The first schema would always match both possibilities (additional properties are always allowed and ignored), so the assumption that only one schema ever matches is not true.
We don't want to use anyOf all the time though, because it makes some cases harder e.g. when you have
string|int
because here the assumption is correct.