# generated by datamodel-codegen:
#   filename:  discriminator_in_array.yaml
#   timestamp: 2023-07-27T00:00:00+00:00

from __future__ import annotations

from enum import Enum
from typing import Annotated, Literal

from pydantic import BaseModel, Field


class Type(Enum):
    my_first_object = 'my_first_object'
    my_second_object = 'my_second_object'


class ObjectBase(BaseModel):
    name: str | None = Field(None, description='Name of the object')
    type: Literal['type1'] = Field(..., description='Object type')


class CreateObjectRequest(ObjectBase):
    name: str = Field(..., description='Name of the object')
    type: Literal['type2'] = Field(..., description='Object type')


class UpdateObjectRequest(ObjectBase):
    type: Literal['type3']


class Demo(BaseModel):
    myArray: list[
        Annotated[
            ObjectBase | CreateObjectRequest | UpdateObjectRequest,
            Field(discriminator='type'),
        ]
    ]
