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

from __future__ import annotations

from typing import Literal

from pydantic import BaseModel, Field, RootModel


class UserMessage(BaseModel):
    type: Literal['message']
    role: Literal['user']
    content: str


class AssistantMessage(BaseModel):
    type: Literal['message']
    role: Literal['assistant']
    content: str


class EasyInputMessage(BaseModel):
    type: Literal['message']
    role: Literal['easy']
    content: str


class ItemReference(BaseModel):
    type: Literal['item_reference']
    id: str


class MessageWrapper(RootModel[UserMessage]):
    root: UserMessage


class MissingType(BaseModel):
    value: str


class MissingTypeWrapper(RootModel[MissingType]):
    root: MissingType


class UniqueA(BaseModel):
    type: Literal['a']


class UniqueB(BaseModel):
    type: Literal['b']


class UniqueC(BaseModel):
    type: Literal['c']


class Envelope(BaseModel):
    items: list[EasyInputMessage | ItemReference | UserMessage | AssistantMessage]
    grouped: ItemReference | UserMessage | AssistantMessage
    mixed: str | ItemReference | None
    wrapped: MessageWrapper | UserMessage | ItemReference
    nested_missing: MissingTypeWrapper | ItemReference
    container: list[UniqueA | UniqueB] | ItemReference
    recursive: ItemReference
    unique: UniqueC | UniqueA | UniqueB = Field(..., discriminator='type')
    nullable_unique: UniqueA | UniqueB | None = Field(..., discriminator='type')
