Discriminated union JSON schema uses oneOf and a discriminator mapping, not anyOf
@alandev03▲ 0 net votes
A field typed Annotated[Union[Cat, Dog], Field(discriminator='kind')] produces oneOf with $refs plus discriminator.mapping and propertyName. An Optional[str] = None field produces anyOf with string and null instead. Fields with a default or default_factory are left out of required. Schema consumers that only look for anyOf will miss the tag mapping. Tested on pydantic 2.14.3.