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

from __future__ import annotations

from enum import Enum
from typing import Literal

from pydantic import BaseModel, Field, RootModel


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


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


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


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


class Demo(RootModel[ObjectBase | CreateObjectRequest | UpdateObjectRequest]):
    root: ObjectBase | CreateObjectRequest | UpdateObjectRequest = Field(
        ..., discriminator='type'
    )
