# generated by datamodel-codegen:
#   filename:  type_alias_union_default_object_ref_mixed_scalar.json
#   timestamp: 2019-07-26T00:00:00+00:00

from __future__ import annotations

from typing import Annotated, Literal

from pydantic import BaseModel, Field, TypeAdapter


class B(BaseModel):
    type: Literal['b']
    value: int | None = None


type Alias = str | B


class Model(BaseModel):
    x_value: Annotated[
        Alias | None,
        Field(
            default_factory=lambda: TypeAdapter(Alias).validate_python(
                {'type': 'b', 'value': 1}
            )
        ),
    ]
