Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 1 of 1 for FirstItem (0.04 sec)

  1. tests/test_union_body_discriminator.py

    def test_discriminator_pydantic_v2() -> None:
        from pydantic import Tag
    
        app = FastAPI()
    
        class FirstItem(BaseModel):
            value: Literal["first"]
            price: int
    
        class OtherItem(BaseModel):
            value: Literal["other"]
            price: float
    
        Item = Annotated[
            Union[Annotated[FirstItem, Tag("first")], Annotated[OtherItem, Tag("other")]],
            Field(discriminator="value"),
        ]
    
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Dec 27 18:19:10 UTC 2025
    - 7.1K bytes
    - Viewed (0)
Back to top