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

from __future__ import annotations

from typing import Any

from pydantic import BaseModel, Field, RootModel, constr


class Model(RootModel[Any]):
    root: Any


class MyArrayItem(RootModel[str]):
    root: str = Field(..., title='MyArrayItem')


class MyArray(RootModel[list[MyArrayItem]]):
    root: list[MyArrayItem] = Field(..., title='MyArray')


class MyObjectProp(RootModel[str]):
    root: str = Field(..., title='MyObjectProp')


class MyObject(RootModel[dict[str, MyObjectProp]]):
    root: dict[str, MyObjectProp] = Field(..., title='MyObject')


class MyOneOfBranch(RootModel[str]):
    root: str = Field(..., title='MyOneOfBranch')


class MyOneOf(RootModel[MyOneOfBranch | float]):
    root: MyOneOfBranch | float = Field(..., title='MyOneOf')


class MyAnyOfBranch(RootModel[bool]):
    root: bool = Field(..., title='MyAnyOfBranch')


class MyAnyOf(RootModel[MyAnyOfBranch | int]):
    root: MyAnyOfBranch | int = Field(..., title='MyAnyOf')


class MyDeepItem(RootModel[int]):
    root: int = Field(..., title='MyDeepItem')


class MyNestedArrayItem(RootModel[list[MyDeepItem]]):
    root: list[MyDeepItem] = Field(..., title='MyNestedArrayItem')


class MyNestedArray(RootModel[list[MyNestedArrayItem]]):
    root: list[MyNestedArrayItem] = Field(..., title='MyNestedArray')


class MyPatternValue(RootModel[str]):
    root: str = Field(..., title='MyPatternValue')


class MyPatternObj(RootModel[dict[constr(pattern=r'^S_'), MyPatternValue]]):
    root: dict[constr(pattern=r'^S_'), MyPatternValue] = Field(
        ..., title='MyPatternObj'
    )


class MyPropValue(RootModel[int]):
    root: int = Field(..., title='MyPropValue')


class MyPropNamesObj(RootModel[dict[constr(pattern=r'^[a-z]+$'), MyPropValue]]):
    root: dict[constr(pattern=r'^[a-z]+$'), MyPropValue] = Field(
        ..., title='MyPropNamesObj'
    )


class Foo(BaseModel):
    array: MyArray | None = Field(None, title='MyArray')
    object: MyObject | None = Field(None, title='MyObject')
    oneOf: MyOneOf | None = Field(None, title='MyOneOf')
    anyOf: MyAnyOf | None = Field(None, title='MyAnyOf')
    nestedArray: MyNestedArray | None = Field(None, title='MyNestedArray')
    patternObj: MyPatternObj | None = Field(None, title='MyPatternObj')
    propNamesObj: MyPropNamesObj | None = Field(None, title='MyPropNamesObj')
