# --------------------------------------------------------------------------------
# |
# |  WARNING:
# |  This file was generated; any local changes will be overwritten during
# |  future invocations of the generator!
# |
# |  Generated by: <SimpleSchemaGenerator>/Plugins/Impl/PythonSerializationImpl.py
# |  Generated on: 2021-06-08 20:09:30.098585
# |
# --------------------------------------------------------------------------------
import copy
import sys

from collections import OrderedDict

import six

import CommonEnvironment
from CommonEnvironment.TypeInfo import Arity
from CommonEnvironment.TypeInfo.AnyOfTypeInfo import AnyOfTypeInfo
from CommonEnvironment.TypeInfo.ClassTypeInfo import ClassTypeInfo
from CommonEnvironment.TypeInfo.DictTypeInfo import DictTypeInfo
from CommonEnvironment.TypeInfo.GenericTypeInfo import GenericTypeInfo
from CommonEnvironment.TypeInfo.ListTypeInfo import ListTypeInfo

from CommonEnvironment.TypeInfo.FundamentalTypes.Serialization.PythonCodeVisitor import PythonCodeVisitor
from CommonEnvironment.TypeInfo.FundamentalTypes.Serialization.StringSerialization import StringSerialization

# <Unused import> pylint: disable = W0611
# <Unused import> pylint: disable = W0614
from CommonEnvironment.TypeInfo.FundamentalTypes.All import *               # <Wildcard import> pylint: disable = W0401

# <Standard import should be placed before...> pylint: disable = C0411

# ----------------------------------------------------------------------
import rtyaml

from CommonEnvironment.CallOnExit import CallOnExit
from CommonEnvironment import FileSystem
from CommonEnvironment.TypeInfo.FundamentalTypes.Serialization.YamlSerialization import YamlSerialization


# ----------------------------------------------------------------------
# <Method name "..." doesn't conform to PascalCase naming style> pylint: disable = C0103
# <Line too long> pylint: disable = C0301
# <Too many lines in module> pylint: disable = C0302
# <Wrong hanging indentation> pylint: disable = C0330

# <Too few public methods> pylint: disable = R0903
# <Too many public methods> pylint: disable = R0904
# <Too many branches> pylint: disable = R0912
# <Too many statements> pylint: disable = R0915


# ----------------------------------------------------------------------
class SerializationException(Exception):
    # ----------------------------------------------------------------------
    def __init__(self, ex_or_string):
        if isinstance(ex_or_string, six.string_types):
            super(SerializationException, self).__init__(ex_or_string)
        else:
            super(SerializationException, self).__init__(str(ex_or_string))

            self.__dict__ = copy.deepcopy(ex_or_string.__dict__)

    # ----------------------------------------------------------------------
    def __str__(self):
        result = super(SerializationException, self).__str__()

        if hasattr(self, "stack"):
            result += " [{}]".format(" -> ".join(self.stack))

        return result

    # ----------------------------------------------------------------------
    def __repr__(self):
        return CommonEnvironment.ObjectReprImpl(self)


class KeySerializationException(SerializationException):                    pass
class SerializeException(SerializationException):                           pass
class DeserializeException(SerializationException):                         pass


class DoesNotExist(object):                                                 pass


# ----------------------------------------------------------------------
# |
# |  Utility Methods
# |
# ----------------------------------------------------------------------
def Serialize(
    root,
    process_additional_data=False,
    always_include_optional=False,
    to_string=False,
):
    """Convenience method that serializes all top-level elements"""

    # No convenience conversions

    result = _CreatePythonObject(
        attributes=None,
    )

    this_result = Serialize_simple_schema_content(
        root,
        is_root=True,
    )
    if this_result is not DoesNotExist:
        setattr(result, "simple_schema_content", this_result)
    elif always_include_optional:
        setattr(result, "simple_schema_content", None)

    this_result = Serialize_endpoints(
        root,
        is_root=True,
        process_additional_data=process_additional_data,
        always_include_optional=always_include_optional,

    )
    if this_result is not DoesNotExist:
        setattr(result, "endpoints", this_result)
    elif always_include_optional:
        setattr(result, "endpoints", [])

    if to_string:
        result = rtyaml.dump(result)

    return result


# ----------------------------------------------------------------------
def Deserialize(
    root,
    process_additional_data=False,
    always_include_optional=False,
):
    """Convenience method that deserializes all top-level elements"""

    if isinstance(root, six.string_types):
        if FileSystem.IsFilename(root):
            with open(root) as f:
                root = rtyaml.load(f)
        else:
            root = rtyaml.load(root)

    result = _CreatePythonObject(
        attributes=None,
    )

    this_result = Deserialize_simple_schema_content(
        root,
        is_root=True,
    )
    if this_result is not DoesNotExist:
        setattr(result, "simple_schema_content", this_result)
    elif always_include_optional:
        setattr(result, "simple_schema_content", None)

    this_result = Deserialize_endpoints(
        root,
        is_root=True,
        process_additional_data=process_additional_data,
        always_include_optional=always_include_optional,

    )
    if this_result is not DoesNotExist:
        setattr(result, "endpoints", this_result)
    elif always_include_optional:
        setattr(result, "endpoints", [])

    return result


# ----------------------------------------------------------------------
def Serialize_simple_schema_content(
    item,
    to_string=False,
    pretty_print=False,
    is_root=False,
):
    """Serializes 'simple_schema_content' from a python object to a YAML object"""

    if not isinstance(item, list):
        if isinstance(item, dict) and "simple_schema_content" in item:
            item = item["simple_schema_content"]
        elif not isinstance(item, dict) and hasattr(item, "simple_schema_content"):
            item = getattr(item, "simple_schema_content")
        elif is_root:
            item = DoesNotExist

    try:
        try:
            item = Serializer().simple_schema_content(
                item,
            )
        except:
            _DecorateActiveException("simple_schema_content")
    except SerializationException:
        raise
    except Exception as ex:
        raise SerializeException(ex)

    if to_string and item not in [DoesNotExist, None]:
        item = rtyaml.dump(item)

    return item


# ----------------------------------------------------------------------
def Serialize_endpoints(
    items,
    process_additional_data=False,
    always_include_optional=False,
    to_string=False,
    pretty_print=False,
    is_root=False,
):
    """Serializes 'endpoints' from a python object to a YAML object"""

    if not isinstance(items, list):
        if isinstance(items, dict) and "endpoints" in items:
            items = items["endpoints"]
        elif not isinstance(items, dict) and hasattr(items, "endpoints"):
            items = getattr(items, "endpoints")
        elif is_root:
            items = DoesNotExist

    try:
        try:
            items = Serializer().endpoints(
                items,
                process_additional_data=process_additional_data,
                always_include_optional=always_include_optional,
            )
        except:
            _DecorateActiveException("endpoints")
    except SerializationException:
        raise
    except Exception as ex:
        raise SerializeException(ex)

    if to_string and items not in [DoesNotExist, None]:
        items = rtyaml.dump(items)

    return items


# ----------------------------------------------------------------------
def Deserialize_simple_schema_content(
    item,
    is_root=False,
):
    """Deserializes 'simple_schema_content' from a YAML object to a python object"""

    if isinstance(item, six.string_types):
        if FileSystem.IsFilename(item):
            with open(item) as f:
                item = rtyaml.load(f)
        else:
            item = rtyaml.load(item)

    if not isinstance(item, list):
        if isinstance(item, dict) and "simple_schema_content" in item:
            item = item["simple_schema_content"]
        elif not isinstance(item, dict) and hasattr(item, "simple_schema_content"):
            item = getattr(item, "simple_schema_content")
        elif is_root:
            item = DoesNotExist

    try:
        try:
            item = Deserializer().simple_schema_content(
                item,
            )
        except:
            _DecorateActiveException("simple_schema_content")
    except SerializationException:
        raise
    except Exception as ex:
        raise DeserializeException(ex)

    return item


# ----------------------------------------------------------------------
def Deserialize_endpoints(
    items,
    process_additional_data=False,
    always_include_optional=False,
    is_root=False,
):
    """Deserializes 'endpoints' from a YAML object to a python object"""

    if isinstance(items, six.string_types):
        if FileSystem.IsFilename(items):
            with open(items) as f:
                items = rtyaml.load(f)
        else:
            items = rtyaml.load(items)

    if not isinstance(items, list):
        if isinstance(items, dict) and "endpoints" in items:
            items = items["endpoints"]
        elif not isinstance(items, dict) and hasattr(items, "endpoints"):
            items = getattr(items, "endpoints")
        elif is_root:
            items = DoesNotExist

    try:
        try:
            items = Deserializer().endpoints(
                items,
                process_additional_data=process_additional_data,
                always_include_optional=always_include_optional,
            )
        except:
            _DecorateActiveException("endpoints")
    except SerializationException:
        raise
    except Exception as ex:
        raise DeserializeException(ex)

    return items


# ----------------------------------------------------------------------
# |
# |  Type Infos
# |
# ----------------------------------------------------------------------
_type_description_TypeInfo_Contents                                         = OrderedDict([("description", GenericTypeInfo(arity=Arity.FromString('?'))), ("simple_schema", GenericTypeInfo())])
_type_descriptions_TypeInfo_Contents                                        = OrderedDict([("name", GenericTypeInfo()), ("description", GenericTypeInfo(arity=Arity.FromString('?'))), ("simple_schema", GenericTypeInfo())])
_endpoints_TypeInfo_Contents                                                = OrderedDict([("uri", GenericTypeInfo()), ("variables", GenericTypeInfo(arity=Arity.FromString('*'))), ("group", GenericTypeInfo(arity=Arity.FromString('?'))), ("summary", GenericTypeInfo(arity=Arity.FromString('?'))), ("description", GenericTypeInfo(arity=Arity.FromString('?'))), ("simple_schema_content", GenericTypeInfo(arity=Arity.FromString('?'))), ("context", GenericTypeInfo(arity=Arity.FromString('?'))), ("methods", GenericTypeInfo(arity=Arity.FromString('*'))), ("children", GenericTypeInfo(arity=Arity.FromString('*')))])
_endpoints_methods_TypeInfo_Contents                                        = OrderedDict([("verb", GenericTypeInfo()), ("summary", GenericTypeInfo(arity=Arity.FromString('?'))), ("description", GenericTypeInfo(arity=Arity.FromString('?'))), ("simple_schema_content", GenericTypeInfo(arity=Arity.FromString('?'))), ("context", GenericTypeInfo(arity=Arity.FromString('?'))), ("default_request", GenericTypeInfo(arity=Arity.FromString('?'))), ("requests", GenericTypeInfo(arity=Arity.FromString('*'))), ("responses", GenericTypeInfo(arity=Arity.FromString('*')))])
_endpoints_methods_RequestContent_TypeInfo_Contents                         = OrderedDict([("headers", GenericTypeInfo(arity=Arity.FromString('*'))), ("query_items", GenericTypeInfo(arity=Arity.FromString('*'))), ("form_items", GenericTypeInfo(arity=Arity.FromString('*'))), ("body", GenericTypeInfo(arity=Arity.FromString('?')))])
_endpoints_methods_requests_TypeInfo_Contents                               = OrderedDict([("content_type", GenericTypeInfo()), ("headers", GenericTypeInfo(arity=Arity.FromString('*'))), ("query_items", GenericTypeInfo(arity=Arity.FromString('*'))), ("form_items", GenericTypeInfo(arity=Arity.FromString('*'))), ("body", GenericTypeInfo(arity=Arity.FromString('?')))])
_endpoints_methods_ResponseContent_TypeInfo_Contents                        = OrderedDict([("headers", GenericTypeInfo(arity=Arity.FromString('*'))), ("body", GenericTypeInfo(arity=Arity.FromString('?')))])
_endpoints_methods_responses_TypeInfo_Contents                              = OrderedDict([("code", GenericTypeInfo()), ("summary", GenericTypeInfo(arity=Arity.FromString('?'))), ("description", GenericTypeInfo(arity=Arity.FromString('?'))), ("simple_schema_content", GenericTypeInfo(arity=Arity.FromString('?'))), ("context", GenericTypeInfo(arity=Arity.FromString('?'))), ("default_content", GenericTypeInfo(arity=Arity.FromString('?'))), ("contents", GenericTypeInfo(arity=Arity.FromString('*')))])
_endpoints_methods_responses_contents_TypeInfo_Contents                     = OrderedDict([("content_type", GenericTypeInfo()), ("headers", GenericTypeInfo(arity=Arity.FromString('*'))), ("body", GenericTypeInfo(arity=Arity.FromString('?')))])

description_TypeInfo                                                        = StringTypeInfo(min_length=1, arity=Arity.FromString('?'))
summary_TypeInfo                                                            = StringTypeInfo(min_length=1, max_length=120, arity=Arity.FromString('?'))
type_description_TypeInfo                                                   = AnyOfTypeInfo([ClassTypeInfo(_type_description_TypeInfo_Contents, require_exact_match=False), DictTypeInfo(_type_description_TypeInfo_Contents, require_exact_match=False)])
type_description__value__TypeInfo                                           = StringTypeInfo(min_length=1)
type_descriptions_TypeInfo                                                  = AnyOfTypeInfo([ClassTypeInfo(_type_descriptions_TypeInfo_Contents, require_exact_match=False), DictTypeInfo(_type_descriptions_TypeInfo_Contents, require_exact_match=False)], arity=Arity.FromString('*'))
type_descriptions__value__TypeInfo                                          = StringTypeInfo(min_length=1)
type_descriptions_name_TypeInfo                                             = StringTypeInfo(min_length=1)
context_TypeInfo                                                            = StringTypeInfo(min_length=1, arity=Arity.FromString('?'))
simple_schema_content_TypeInfo                                              = StringTypeInfo(min_length=1, arity=Arity.FromString('?'))
endpoints_TypeInfo                                                          = AnyOfTypeInfo([ClassTypeInfo(_endpoints_TypeInfo_Contents, require_exact_match=False), DictTypeInfo(_endpoints_TypeInfo_Contents, require_exact_match=False)], arity=Arity.FromString('+'))
endpoints_uri_TypeInfo                                                      = StringTypeInfo(min_length=1)
endpoints_group_TypeInfo                                                    = StringTypeInfo(min_length=1, arity=Arity.FromString('?'))
endpoints_methods_TypeInfo                                                  = AnyOfTypeInfo([ClassTypeInfo(_endpoints_methods_TypeInfo_Contents, require_exact_match=False), DictTypeInfo(_endpoints_methods_TypeInfo_Contents, require_exact_match=False)], arity=Arity.FromString('*'))
endpoints_methods_verb_TypeInfo                                             = EnumTypeInfo([ 'POST', 'GET', 'PUT', 'PATCH', 'DELETE', 'OPTIONS', 'HEAD', 'TRACE', 'CONNECT', ])
endpoints_methods_RequestContent_TypeInfo                                   = AnyOfTypeInfo([ClassTypeInfo(_endpoints_methods_RequestContent_TypeInfo_Contents, require_exact_match=False), DictTypeInfo(_endpoints_methods_RequestContent_TypeInfo_Contents, require_exact_match=False)])
endpoints_methods_RequestContent_body_TypeInfo                              = AnyOfTypeInfo([ClassTypeInfo(_type_description_TypeInfo_Contents, require_exact_match=False), DictTypeInfo(_type_description_TypeInfo_Contents, require_exact_match=False)], arity=Arity.FromString('?'))
endpoints_methods_RequestContent_body__value__TypeInfo                      = StringTypeInfo(min_length=1)
endpoints_methods_default_request_TypeInfo                                  = AnyOfTypeInfo([ClassTypeInfo(_endpoints_methods_RequestContent_TypeInfo_Contents, require_exact_match=False), DictTypeInfo(_endpoints_methods_RequestContent_TypeInfo_Contents, require_exact_match=False)], arity=Arity.FromString('?'))
endpoints_methods_requests_TypeInfo                                         = AnyOfTypeInfo([ClassTypeInfo(_endpoints_methods_requests_TypeInfo_Contents, require_exact_match=False), DictTypeInfo(_endpoints_methods_requests_TypeInfo_Contents, require_exact_match=False)], arity=Arity.FromString('*'))
endpoints_methods_requests_content_type_TypeInfo                            = StringTypeInfo(min_length=1)
endpoints_methods_ResponseContent_TypeInfo                                  = AnyOfTypeInfo([ClassTypeInfo(_endpoints_methods_ResponseContent_TypeInfo_Contents, require_exact_match=False), DictTypeInfo(_endpoints_methods_ResponseContent_TypeInfo_Contents, require_exact_match=False)])
endpoints_methods_ResponseContent_body_TypeInfo                             = AnyOfTypeInfo([ClassTypeInfo(_type_description_TypeInfo_Contents, require_exact_match=False), DictTypeInfo(_type_description_TypeInfo_Contents, require_exact_match=False)], arity=Arity.FromString('?'))
endpoints_methods_ResponseContent_body__value__TypeInfo                     = StringTypeInfo(min_length=1)
endpoints_methods_responses_TypeInfo                                        = AnyOfTypeInfo([ClassTypeInfo(_endpoints_methods_responses_TypeInfo_Contents, require_exact_match=False), DictTypeInfo(_endpoints_methods_responses_TypeInfo_Contents, require_exact_match=False)], arity=Arity.FromString('*'))
endpoints_methods_responses_code_TypeInfo                                   = IntTypeInfo(min=0, max=99999)
endpoints_methods_responses_default_content_TypeInfo                        = AnyOfTypeInfo([ClassTypeInfo(_endpoints_methods_ResponseContent_TypeInfo_Contents, require_exact_match=False), DictTypeInfo(_endpoints_methods_ResponseContent_TypeInfo_Contents, require_exact_match=False)], arity=Arity.FromString('?'))
endpoints_methods_responses_contents_TypeInfo                               = AnyOfTypeInfo([ClassTypeInfo(_endpoints_methods_responses_contents_TypeInfo_Contents, require_exact_match=False), DictTypeInfo(_endpoints_methods_responses_contents_TypeInfo_Contents, require_exact_match=False)], arity=Arity.FromString('*'))
endpoints_methods_responses_contents_content_type_TypeInfo                  = StringTypeInfo(min_length=1)
endpoints_children_TypeInfo                                                 = AnyOfTypeInfo([ClassTypeInfo(_endpoints_TypeInfo_Contents, require_exact_match=False), DictTypeInfo(_endpoints_TypeInfo_Contents, require_exact_match=False)], arity=Arity.FromString('*'))

# ----------------------------------------------------------------------
# |
# |  Serializer
# |
# ----------------------------------------------------------------------
class Serializer(object):

    # ----------------------------------------------------------------------
    @classmethod
    def description(cls, item):
        if item in [DoesNotExist, None]:
            description_TypeInfo.ValidateArity(None)
            return DoesNotExist

        description_TypeInfo.ValidateArity(item)

        result = cls._description_Item(item)

        return result

    # ----------------------------------------------------------------------
    @classmethod
    def summary(cls, item):
        if item in [DoesNotExist, None]:
            summary_TypeInfo.ValidateArity(None)
            return DoesNotExist

        summary_TypeInfo.ValidateArity(item)

        result = cls._summary_Item(item)

        return result

    # ----------------------------------------------------------------------
    @classmethod
    def type_description(cls, item, always_include_optional, process_additional_data):
        if item in [DoesNotExist, None]:
            type_description_TypeInfo.ValidateArity(None)
            return DoesNotExist

        if not process_additional_data:
            type_description_TypeInfo.ValidateArity(item)

        result = cls._type_description_Item(item, always_include_optional, process_additional_data)

        return result

    # ----------------------------------------------------------------------
    @classmethod
    def type_description_description(cls, item):
        return cls.description(item)

    # ----------------------------------------------------------------------
    @classmethod
    def type_descriptions(cls, items, always_include_optional, process_additional_data):
        if items in [DoesNotExist, None, []]:
            type_descriptions_TypeInfo.ValidateArity(None)
            return DoesNotExist

        if not process_additional_data:
            type_descriptions_TypeInfo.ValidateArity(items)

        _ValidateKeys("name", items)

        results = []

        for this_index, this_item in enumerate(items or []):
            try:
                results.append(cls._type_descriptions_Item(this_item, always_include_optional, process_additional_data))
            except:
                _DecorateActiveException("Index {}".format(this_index))

        return results

    # ----------------------------------------------------------------------
    @classmethod
    def type_descriptions_name(cls, item):
        if item in [DoesNotExist, None]:
            type_descriptions_name_TypeInfo.ValidateArity(None)
            return DoesNotExist

        type_descriptions_name_TypeInfo.ValidateArity(item)

        result = cls._type_descriptions_name_Item(item)

        return result

    # ----------------------------------------------------------------------
    @classmethod
    def type_descriptions_description(cls, item):
        return cls.description(item)

    # ----------------------------------------------------------------------
    @classmethod
    def context(cls, item):
        if item in [DoesNotExist, None]:
            context_TypeInfo.ValidateArity(None)
            return DoesNotExist

        context_TypeInfo.ValidateArity(item)

        result = cls._context_Item(item)

        return result

    # ----------------------------------------------------------------------
    @classmethod
    def simple_schema_content(cls, item):
        if item in [DoesNotExist, None]:
            simple_schema_content_TypeInfo.ValidateArity(None)
            return DoesNotExist

        simple_schema_content_TypeInfo.ValidateArity(item)

        result = cls._simple_schema_content_Item(item)

        return result

    # ----------------------------------------------------------------------
    @classmethod
    def endpoints(cls, items, always_include_optional, process_additional_data):
        if items in [DoesNotExist, None, []]:
            endpoints_TypeInfo.ValidateArity(None)
            return DoesNotExist

        if not process_additional_data:
            endpoints_TypeInfo.ValidateArity(items)

        _ValidateKeys("uri", items)

        results = []

        for this_index, this_item in enumerate(items or []):
            try:
                results.append(cls._endpoints_Item(this_item, always_include_optional, process_additional_data))
            except:
                _DecorateActiveException("Index {}".format(this_index))

        return results

    # ----------------------------------------------------------------------
    @classmethod
    def endpoints_uri(cls, item):
        if item in [DoesNotExist, None]:
            endpoints_uri_TypeInfo.ValidateArity(None)
            return DoesNotExist

        endpoints_uri_TypeInfo.ValidateArity(item)

        result = cls._endpoints_uri_Item(item)

        return result

    # ----------------------------------------------------------------------
    @classmethod
    def endpoints_variables(cls, items, always_include_optional, process_additional_data):
        return cls.type_descriptions(items, always_include_optional, process_additional_data)

    # ----------------------------------------------------------------------
    @classmethod
    def endpoints_group(cls, item):
        if item in [DoesNotExist, None]:
            endpoints_group_TypeInfo.ValidateArity(None)
            return DoesNotExist

        endpoints_group_TypeInfo.ValidateArity(item)

        result = cls._endpoints_group_Item(item)

        return result

    # ----------------------------------------------------------------------
    @classmethod
    def endpoints_summary(cls, item):
        return cls.summary(item)

    # ----------------------------------------------------------------------
    @classmethod
    def endpoints_description(cls, item):
        return cls.description(item)

    # ----------------------------------------------------------------------
    @classmethod
    def endpoints_simple_schema_content(cls, item):
        return cls.simple_schema_content(item)

    # ----------------------------------------------------------------------
    @classmethod
    def endpoints_context(cls, item):
        return cls.context(item)

    # ----------------------------------------------------------------------
    @classmethod
    def endpoints_methods(cls, items, always_include_optional, process_additional_data):
        if items in [DoesNotExist, None, []]:
            endpoints_methods_TypeInfo.ValidateArity(None)
            return DoesNotExist

        if not process_additional_data:
            endpoints_methods_TypeInfo.ValidateArity(items)

        _ValidateKeys("verb", items)

        results = []

        for this_index, this_item in enumerate(items or []):
            try:
                results.append(cls._endpoints_methods_Item(this_item, always_include_optional, process_additional_data))
            except:
                _DecorateActiveException("Index {}".format(this_index))

        return results

    # ----------------------------------------------------------------------
    @classmethod
    def endpoints_methods_verb(cls, item):
        if item in [DoesNotExist, None]:
            endpoints_methods_verb_TypeInfo.ValidateArity(None)
            return DoesNotExist

        endpoints_methods_verb_TypeInfo.ValidateArity(item)

        result = cls._endpoints_methods_verb_Item(item)

        return result

    # ----------------------------------------------------------------------
    @classmethod
    def endpoints_methods_summary(cls, item):
        return cls.endpoints_summary(item)

    # ----------------------------------------------------------------------
    @classmethod
    def endpoints_methods_description(cls, item):
        return cls.endpoints_description(item)

    # ----------------------------------------------------------------------
    @classmethod
    def endpoints_methods_simple_schema_content(cls, item):
        return cls.endpoints_simple_schema_content(item)

    # ----------------------------------------------------------------------
    @classmethod
    def endpoints_methods_context(cls, item):
        return cls.endpoints_context(item)

    # ----------------------------------------------------------------------
    @classmethod
    def endpoints_methods_RequestContent(cls, item, always_include_optional, process_additional_data):
        if item in [DoesNotExist, None]:
            endpoints_methods_RequestContent_TypeInfo.ValidateArity(None)
            return DoesNotExist

        if not process_additional_data:
            endpoints_methods_RequestContent_TypeInfo.ValidateArity(item)

        result = cls._endpoints_methods_RequestContent_Item(item, always_include_optional, process_additional_data)

        return result

    # ----------------------------------------------------------------------
    @classmethod
    def endpoints_methods_RequestContent_headers(cls, items, always_include_optional, process_additional_data):
        return cls.type_descriptions(items, always_include_optional, process_additional_data)

    # ----------------------------------------------------------------------
    @classmethod
    def endpoints_methods_RequestContent_query_items(cls, items, always_include_optional, process_additional_data):
        return cls.type_descriptions(items, always_include_optional, process_additional_data)

    # ----------------------------------------------------------------------
    @classmethod
    def endpoints_methods_RequestContent_form_items(cls, items, always_include_optional, process_additional_data):
        return cls.type_descriptions(items, always_include_optional, process_additional_data)

    # ----------------------------------------------------------------------
    @classmethod
    def endpoints_methods_RequestContent_body(cls, item, always_include_optional, process_additional_data):
        if item in [DoesNotExist, None]:
            endpoints_methods_RequestContent_body_TypeInfo.ValidateArity(None)
            return DoesNotExist

        if not process_additional_data:
            endpoints_methods_RequestContent_body_TypeInfo.ValidateArity(item)

        result = cls._endpoints_methods_RequestContent_body_Item(item, always_include_optional, process_additional_data)

        return result

    # ----------------------------------------------------------------------
    @classmethod
    def endpoints_methods_default_request(cls, item, always_include_optional, process_additional_data):
        if item in [DoesNotExist, None]:
            endpoints_methods_default_request_TypeInfo.ValidateArity(None)
            return DoesNotExist

        if not process_additional_data:
            endpoints_methods_default_request_TypeInfo.ValidateArity(item)

        result = cls._endpoints_methods_default_request_Item(item, always_include_optional, process_additional_data)

        return result

    # ----------------------------------------------------------------------
    @classmethod
    def endpoints_methods_requests(cls, items, always_include_optional, process_additional_data):
        if items in [DoesNotExist, None, []]:
            endpoints_methods_requests_TypeInfo.ValidateArity(None)
            return DoesNotExist

        if not process_additional_data:
            endpoints_methods_requests_TypeInfo.ValidateArity(items)

        _ValidateKeys("content_type", items)

        results = []

        for this_index, this_item in enumerate(items or []):
            try:
                results.append(cls._endpoints_methods_requests_Item(this_item, always_include_optional, process_additional_data))
            except:
                _DecorateActiveException("Index {}".format(this_index))

        return results

    # ----------------------------------------------------------------------
    @classmethod
    def endpoints_methods_requests_content_type(cls, item):
        if item in [DoesNotExist, None]:
            endpoints_methods_requests_content_type_TypeInfo.ValidateArity(None)
            return DoesNotExist

        endpoints_methods_requests_content_type_TypeInfo.ValidateArity(item)

        result = cls._endpoints_methods_requests_content_type_Item(item)

        return result

    # ----------------------------------------------------------------------
    @classmethod
    def endpoints_methods_ResponseContent(cls, item, always_include_optional, process_additional_data):
        if item in [DoesNotExist, None]:
            endpoints_methods_ResponseContent_TypeInfo.ValidateArity(None)
            return DoesNotExist

        if not process_additional_data:
            endpoints_methods_ResponseContent_TypeInfo.ValidateArity(item)

        result = cls._endpoints_methods_ResponseContent_Item(item, always_include_optional, process_additional_data)

        return result

    # ----------------------------------------------------------------------
    @classmethod
    def endpoints_methods_ResponseContent_headers(cls, items, always_include_optional, process_additional_data):
        return cls.type_descriptions(items, always_include_optional, process_additional_data)

    # ----------------------------------------------------------------------
    @classmethod
    def endpoints_methods_ResponseContent_body(cls, item, always_include_optional, process_additional_data):
        if item in [DoesNotExist, None]:
            endpoints_methods_ResponseContent_body_TypeInfo.ValidateArity(None)
            return DoesNotExist

        if not process_additional_data:
            endpoints_methods_ResponseContent_body_TypeInfo.ValidateArity(item)

        result = cls._endpoints_methods_ResponseContent_body_Item(item, always_include_optional, process_additional_data)

        return result

    # ----------------------------------------------------------------------
    @classmethod
    def endpoints_methods_responses(cls, items, always_include_optional, process_additional_data):
        if items in [DoesNotExist, None, []]:
            endpoints_methods_responses_TypeInfo.ValidateArity(None)
            return DoesNotExist

        if not process_additional_data:
            endpoints_methods_responses_TypeInfo.ValidateArity(items)

        _ValidateKeys("code", items)

        results = []

        for this_index, this_item in enumerate(items or []):
            try:
                results.append(cls._endpoints_methods_responses_Item(this_item, always_include_optional, process_additional_data))
            except:
                _DecorateActiveException("Index {}".format(this_index))

        return results

    # ----------------------------------------------------------------------
    @classmethod
    def endpoints_methods_responses_code(cls, item):
        if item in [DoesNotExist, None]:
            endpoints_methods_responses_code_TypeInfo.ValidateArity(None)
            return DoesNotExist

        endpoints_methods_responses_code_TypeInfo.ValidateArity(item)

        result = cls._endpoints_methods_responses_code_Item(item)

        return result

    # ----------------------------------------------------------------------
    @classmethod
    def endpoints_methods_responses_summary(cls, item):
        return cls.endpoints_methods_summary(item)

    # ----------------------------------------------------------------------
    @classmethod
    def endpoints_methods_responses_description(cls, item):
        return cls.endpoints_methods_description(item)

    # ----------------------------------------------------------------------
    @classmethod
    def endpoints_methods_responses_simple_schema_content(cls, item):
        return cls.endpoints_methods_simple_schema_content(item)

    # ----------------------------------------------------------------------
    @classmethod
    def endpoints_methods_responses_context(cls, item):
        return cls.endpoints_methods_context(item)

    # ----------------------------------------------------------------------
    @classmethod
    def endpoints_methods_responses_default_content(cls, item, always_include_optional, process_additional_data):
        if item in [DoesNotExist, None]:
            endpoints_methods_responses_default_content_TypeInfo.ValidateArity(None)
            return DoesNotExist

        if not process_additional_data:
            endpoints_methods_responses_default_content_TypeInfo.ValidateArity(item)

        result = cls._endpoints_methods_responses_default_content_Item(item, always_include_optional, process_additional_data)

        return result

    # ----------------------------------------------------------------------
    @classmethod
    def endpoints_methods_responses_contents(cls, items, always_include_optional, process_additional_data):
        if items in [DoesNotExist, None, []]:
            endpoints_methods_responses_contents_TypeInfo.ValidateArity(None)
            return DoesNotExist

        if not process_additional_data:
            endpoints_methods_responses_contents_TypeInfo.ValidateArity(items)

        _ValidateKeys("content_type", items)

        results = []

        for this_index, this_item in enumerate(items or []):
            try:
                results.append(cls._endpoints_methods_responses_contents_Item(this_item, always_include_optional, process_additional_data))
            except:
                _DecorateActiveException("Index {}".format(this_index))

        return results

    # ----------------------------------------------------------------------
    @classmethod
    def endpoints_methods_responses_contents_content_type(cls, item):
        if item in [DoesNotExist, None]:
            endpoints_methods_responses_contents_content_type_TypeInfo.ValidateArity(None)
            return DoesNotExist

        endpoints_methods_responses_contents_content_type_TypeInfo.ValidateArity(item)

        result = cls._endpoints_methods_responses_contents_content_type_Item(item)

        return result

    # ----------------------------------------------------------------------
    @classmethod
    def endpoints_children(cls, items, always_include_optional, process_additional_data):
        if items in [DoesNotExist, None, []]:
            endpoints_children_TypeInfo.ValidateArity(None)
            return DoesNotExist

        if not process_additional_data:
            endpoints_children_TypeInfo.ValidateArity(items)

        _ValidateKeys("uri", items)

        results = []

        for this_index, this_item in enumerate(items or []):
            try:
                results.append(cls._endpoints_children_Item(this_item, always_include_optional, process_additional_data))
            except:
                _DecorateActiveException("Index {}".format(this_index))

        return results

    # ----------------------------------------------------------------------
    # ----------------------------------------------------------------------
    # ----------------------------------------------------------------------
    @classmethod
    def _description_Item(cls, item):
        return YamlSerialization.SerializeItem(description_TypeInfo, item, **{})

    # ----------------------------------------------------------------------
    @classmethod
    def _summary_Item(cls, item):
        return YamlSerialization.SerializeItem(summary_TypeInfo, item, **{})

    # ----------------------------------------------------------------------
    @classmethod
    def _type_description_Item(cls, item, always_include_optional, process_additional_data):
        type_description_TypeInfo.ValidateItem(
            item,
            recurse=False,
            require_exact_match=not process_additional_data,
        )

        # <fundamental value>
        try:
            fundamental_value = YamlSerialization.SerializeItem(type_description__value__TypeInfo, cls._GetPythonAttribute(
                item,
                "simple_schema",
                is_optional=False,
            )
            , **{})
        except:
            _DecorateActiveException("value type")

        result = _CreatePythonObject(
            attributes=None,
            **{"simple_schema": fundamental_value, "_text_attribute_name": "simple_schema"},
        )


        # description
        try:
            cls._ApplyOptionalChild(item, "description", result, cls.type_description_description, always_include_optional)
        except:
            _DecorateActiveException("description")

        # Additional data
        if process_additional_data:
            cls._ApplyAdditionalData(
                item,
                result,
                exclude_names={"description", "simple_schema"},
            )

        return result

    # ----------------------------------------------------------------------
    @classmethod
    def _type_descriptions_Item(cls, item, always_include_optional, process_additional_data):
        type_descriptions_TypeInfo.ValidateItem(
            item,
            recurse=False,
            require_exact_match=not process_additional_data,
        )

        attributes = OrderedDict()

        # name
        try:
            attributes["name"] = cls.type_descriptions_name(
                cls._GetPythonAttribute(
                    item,
                    "name",
                    is_optional=False,
                ),
            )
        except:
            _DecorateActiveException("name")

        # <fundamental value>
        try:
            fundamental_value = YamlSerialization.SerializeItem(type_descriptions__value__TypeInfo, cls._GetPythonAttribute(
                item,
                "simple_schema",
                is_optional=False,
            )
            , **{})
        except:
            _DecorateActiveException("value type")

        result = _CreatePythonObject(
            attributes=attributes,
            **{"simple_schema": fundamental_value, "_text_attribute_name": "simple_schema"},
        )


        # description
        try:
            cls._ApplyOptionalChild(item, "description", result, cls.type_descriptions_description, always_include_optional)
        except:
            _DecorateActiveException("description")

        # Additional data
        if process_additional_data:
            cls._ApplyAdditionalData(
                item,
                result,
                exclude_names={"name", "description", "simple_schema"},
            )

        return result

    # ----------------------------------------------------------------------
    @classmethod
    def _type_descriptions_name_Item(cls, item):
        return YamlSerialization.SerializeItem(type_descriptions_name_TypeInfo, item, **{})

    # ----------------------------------------------------------------------
    @classmethod
    def _context_Item(cls, item):
        return YamlSerialization.SerializeItem(context_TypeInfo, item, **{})

    # ----------------------------------------------------------------------
    @classmethod
    def _simple_schema_content_Item(cls, item):
        return YamlSerialization.SerializeItem(simple_schema_content_TypeInfo, item, **{})

    # ----------------------------------------------------------------------
    @classmethod
    def _endpoints_Item(cls, item, always_include_optional, process_additional_data):
        endpoints_TypeInfo.ValidateItem(
            item,
            recurse=False,
            require_exact_match=not process_additional_data,
        )

        attributes = OrderedDict()

        # uri
        try:
            attributes["uri"] = cls.endpoints_uri(
                cls._GetPythonAttribute(
                    item,
                    "uri",
                    is_optional=False,
                ),
            )
        except:
            _DecorateActiveException("uri")

        # group
        try:
            cls._ApplyOptionalAttribute(item, "group", attributes, cls.endpoints_group, always_include_optional)
        except:
            _DecorateActiveException("group")

        result = _CreatePythonObject(
            attributes=attributes,
        )

        # variables
        try:
            cls._ApplyOptionalChildren(item, "variables", result, lambda value: cls.endpoints_variables(value, always_include_optional, process_additional_data), always_include_optional)
        except:
            _DecorateActiveException("variables")

        # summary
        try:
            cls._ApplyOptionalChild(item, "summary", result, cls.endpoints_summary, always_include_optional)
        except:
            _DecorateActiveException("summary")

        # description
        try:
            cls._ApplyOptionalChild(item, "description", result, cls.endpoints_description, always_include_optional)
        except:
            _DecorateActiveException("description")

        # simple_schema_content
        try:
            cls._ApplyOptionalChild(item, "simple_schema_content", result, cls.endpoints_simple_schema_content, always_include_optional)
        except:
            _DecorateActiveException("simple_schema_content")

        # context
        try:
            cls._ApplyOptionalChild(item, "context", result, cls.endpoints_context, always_include_optional)
        except:
            _DecorateActiveException("context")

        # methods
        try:
            cls._ApplyOptionalChildren(item, "methods", result, lambda value: cls.endpoints_methods(value, always_include_optional, process_additional_data), always_include_optional)
        except:
            _DecorateActiveException("methods")

        # children
        try:
            cls._ApplyOptionalChildren(item, "children", result, lambda value: cls.endpoints_children(value, always_include_optional, process_additional_data), always_include_optional)
        except:
            _DecorateActiveException("children")

        # Additional data
        if process_additional_data:
            cls._ApplyAdditionalData(
                item,
                result,
                exclude_names={"uri", "variables", "group", "summary", "description", "simple_schema_content", "context", "methods", "children"},
            )

        return result

    # ----------------------------------------------------------------------
    @classmethod
    def _endpoints_uri_Item(cls, item):
        return YamlSerialization.SerializeItem(endpoints_uri_TypeInfo, item, **{})

    # ----------------------------------------------------------------------
    @classmethod
    def _endpoints_group_Item(cls, item):
        return YamlSerialization.SerializeItem(endpoints_group_TypeInfo, item, **{})

    # ----------------------------------------------------------------------
    @classmethod
    def _endpoints_methods_Item(cls, item, always_include_optional, process_additional_data):
        endpoints_methods_TypeInfo.ValidateItem(
            item,
            recurse=False,
            require_exact_match=not process_additional_data,
        )

        attributes = OrderedDict()

        # verb
        try:
            attributes["verb"] = cls.endpoints_methods_verb(
                cls._GetPythonAttribute(
                    item,
                    "verb",
                    is_optional=False,
                ),
            )
        except:
            _DecorateActiveException("verb")

        result = _CreatePythonObject(
            attributes=attributes,
        )

        # summary
        try:
            cls._ApplyOptionalChild(item, "summary", result, cls.endpoints_methods_summary, always_include_optional)
        except:
            _DecorateActiveException("summary")

        # description
        try:
            cls._ApplyOptionalChild(item, "description", result, cls.endpoints_methods_description, always_include_optional)
        except:
            _DecorateActiveException("description")

        # simple_schema_content
        try:
            cls._ApplyOptionalChild(item, "simple_schema_content", result, cls.endpoints_methods_simple_schema_content, always_include_optional)
        except:
            _DecorateActiveException("simple_schema_content")

        # context
        try:
            cls._ApplyOptionalChild(item, "context", result, cls.endpoints_methods_context, always_include_optional)
        except:
            _DecorateActiveException("context")

        # default_request
        try:
            cls._ApplyOptionalChild(item, "default_request", result, lambda value: cls.endpoints_methods_default_request(value, always_include_optional, process_additional_data), always_include_optional)
        except:
            _DecorateActiveException("default_request")

        # requests
        try:
            cls._ApplyOptionalChildren(item, "requests", result, lambda value: cls.endpoints_methods_requests(value, always_include_optional, process_additional_data), always_include_optional)
        except:
            _DecorateActiveException("requests")

        # responses
        try:
            cls._ApplyOptionalChildren(item, "responses", result, lambda value: cls.endpoints_methods_responses(value, always_include_optional, process_additional_data), always_include_optional)
        except:
            _DecorateActiveException("responses")

        # Additional data
        if process_additional_data:
            cls._ApplyAdditionalData(
                item,
                result,
                exclude_names={"verb", "summary", "description", "simple_schema_content", "context", "default_request", "requests", "responses"},
            )

        return result

    # ----------------------------------------------------------------------
    @classmethod
    def _endpoints_methods_verb_Item(cls, item):
        return YamlSerialization.SerializeItem(endpoints_methods_verb_TypeInfo, item, **{})

    # ----------------------------------------------------------------------
    @classmethod
    def _endpoints_methods_RequestContent_Item(cls, item, always_include_optional, process_additional_data):
        endpoints_methods_RequestContent_TypeInfo.ValidateItem(
            item,
            recurse=False,
            require_exact_match=not process_additional_data,
        )

        result = _CreatePythonObject(
            attributes=None,
        )

        # headers
        try:
            cls._ApplyOptionalChildren(item, "headers", result, lambda value: cls.endpoints_methods_RequestContent_headers(value, always_include_optional, process_additional_data), always_include_optional)
        except:
            _DecorateActiveException("headers")

        # query_items
        try:
            cls._ApplyOptionalChildren(item, "query_items", result, lambda value: cls.endpoints_methods_RequestContent_query_items(value, always_include_optional, process_additional_data), always_include_optional)
        except:
            _DecorateActiveException("query_items")

        # form_items
        try:
            cls._ApplyOptionalChildren(item, "form_items", result, lambda value: cls.endpoints_methods_RequestContent_form_items(value, always_include_optional, process_additional_data), always_include_optional)
        except:
            _DecorateActiveException("form_items")

        # body
        try:
            cls._ApplyOptionalChild(item, "body", result, lambda value: cls.endpoints_methods_RequestContent_body(value, always_include_optional, process_additional_data), always_include_optional)
        except:
            _DecorateActiveException("body")

        # Additional data
        if process_additional_data:
            cls._ApplyAdditionalData(
                item,
                result,
                exclude_names={"headers", "query_items", "form_items", "body"},
            )

        return result

    # ----------------------------------------------------------------------
    @classmethod
    def _endpoints_methods_RequestContent_body_Item(cls, item, always_include_optional, process_additional_data):
        endpoints_methods_RequestContent_body_TypeInfo.ValidateItem(
            item,
            recurse=False,
            require_exact_match=not process_additional_data,
        )

        # <fundamental value>
        try:
            fundamental_value = YamlSerialization.SerializeItem(endpoints_methods_RequestContent_body__value__TypeInfo, cls._GetPythonAttribute(
                item,
                "simple_schema",
                is_optional=False,
            )
            , **{})
        except:
            _DecorateActiveException("value type")

        result = _CreatePythonObject(
            attributes=None,
            **{"simple_schema": fundamental_value, "_text_attribute_name": "simple_schema"},
        )


        # description
        try:
            cls._ApplyOptionalChild(item, "description", result, cls.type_description_description, always_include_optional)
        except:
            _DecorateActiveException("description")

        # Additional data
        if process_additional_data:
            cls._ApplyAdditionalData(
                item,
                result,
                exclude_names={"description", "simple_schema"},
            )

        return result

    # ----------------------------------------------------------------------
    @classmethod
    def _endpoints_methods_default_request_Item(cls, item, always_include_optional, process_additional_data):
        endpoints_methods_default_request_TypeInfo.ValidateItem(
            item,
            recurse=False,
            require_exact_match=not process_additional_data,
        )

        result = _CreatePythonObject(
            attributes=None,
        )

        # headers
        try:
            cls._ApplyOptionalChildren(item, "headers", result, lambda value: cls.endpoints_methods_RequestContent_headers(value, always_include_optional, process_additional_data), always_include_optional)
        except:
            _DecorateActiveException("headers")

        # query_items
        try:
            cls._ApplyOptionalChildren(item, "query_items", result, lambda value: cls.endpoints_methods_RequestContent_query_items(value, always_include_optional, process_additional_data), always_include_optional)
        except:
            _DecorateActiveException("query_items")

        # form_items
        try:
            cls._ApplyOptionalChildren(item, "form_items", result, lambda value: cls.endpoints_methods_RequestContent_form_items(value, always_include_optional, process_additional_data), always_include_optional)
        except:
            _DecorateActiveException("form_items")

        # body
        try:
            cls._ApplyOptionalChild(item, "body", result, lambda value: cls.endpoints_methods_RequestContent_body(value, always_include_optional, process_additional_data), always_include_optional)
        except:
            _DecorateActiveException("body")

        # Additional data
        if process_additional_data:
            cls._ApplyAdditionalData(
                item,
                result,
                exclude_names={"headers", "query_items", "form_items", "body"},
            )

        return result

    # ----------------------------------------------------------------------
    @classmethod
    def _endpoints_methods_requests_Item(cls, item, always_include_optional, process_additional_data):
        endpoints_methods_requests_TypeInfo.ValidateItem(
            item,
            recurse=False,
            require_exact_match=not process_additional_data,
        )

        attributes = OrderedDict()

        # content_type
        try:
            attributes["content_type"] = cls.endpoints_methods_requests_content_type(
                cls._GetPythonAttribute(
                    item,
                    "content_type",
                    is_optional=False,
                ),
            )
        except:
            _DecorateActiveException("content_type")

        result = _CreatePythonObject(
            attributes=attributes,
        )

        # headers
        try:
            cls._ApplyOptionalChildren(item, "headers", result, lambda value: cls.endpoints_methods_RequestContent_headers(value, always_include_optional, process_additional_data), always_include_optional)
        except:
            _DecorateActiveException("headers")

        # query_items
        try:
            cls._ApplyOptionalChildren(item, "query_items", result, lambda value: cls.endpoints_methods_RequestContent_query_items(value, always_include_optional, process_additional_data), always_include_optional)
        except:
            _DecorateActiveException("query_items")

        # form_items
        try:
            cls._ApplyOptionalChildren(item, "form_items", result, lambda value: cls.endpoints_methods_RequestContent_form_items(value, always_include_optional, process_additional_data), always_include_optional)
        except:
            _DecorateActiveException("form_items")

        # body
        try:
            cls._ApplyOptionalChild(item, "body", result, lambda value: cls.endpoints_methods_RequestContent_body(value, always_include_optional, process_additional_data), always_include_optional)
        except:
            _DecorateActiveException("body")

        # Additional data
        if process_additional_data:
            cls._ApplyAdditionalData(
                item,
                result,
                exclude_names={"content_type", "headers", "query_items", "form_items", "body"},
            )

        return result

    # ----------------------------------------------------------------------
    @classmethod
    def _endpoints_methods_requests_content_type_Item(cls, item):
        return YamlSerialization.SerializeItem(endpoints_methods_requests_content_type_TypeInfo, item, **{})

    # ----------------------------------------------------------------------
    @classmethod
    def _endpoints_methods_ResponseContent_Item(cls, item, always_include_optional, process_additional_data):
        endpoints_methods_ResponseContent_TypeInfo.ValidateItem(
            item,
            recurse=False,
            require_exact_match=not process_additional_data,
        )

        result = _CreatePythonObject(
            attributes=None,
        )

        # headers
        try:
            cls._ApplyOptionalChildren(item, "headers", result, lambda value: cls.endpoints_methods_ResponseContent_headers(value, always_include_optional, process_additional_data), always_include_optional)
        except:
            _DecorateActiveException("headers")

        # body
        try:
            cls._ApplyOptionalChild(item, "body", result, lambda value: cls.endpoints_methods_ResponseContent_body(value, always_include_optional, process_additional_data), always_include_optional)
        except:
            _DecorateActiveException("body")

        # Additional data
        if process_additional_data:
            cls._ApplyAdditionalData(
                item,
                result,
                exclude_names={"headers", "body"},
            )

        return result

    # ----------------------------------------------------------------------
    @classmethod
    def _endpoints_methods_ResponseContent_body_Item(cls, item, always_include_optional, process_additional_data):
        endpoints_methods_ResponseContent_body_TypeInfo.ValidateItem(
            item,
            recurse=False,
            require_exact_match=not process_additional_data,
        )

        # <fundamental value>
        try:
            fundamental_value = YamlSerialization.SerializeItem(endpoints_methods_ResponseContent_body__value__TypeInfo, cls._GetPythonAttribute(
                item,
                "simple_schema",
                is_optional=False,
            )
            , **{})
        except:
            _DecorateActiveException("value type")

        result = _CreatePythonObject(
            attributes=None,
            **{"simple_schema": fundamental_value, "_text_attribute_name": "simple_schema"},
        )


        # description
        try:
            cls._ApplyOptionalChild(item, "description", result, cls.type_description_description, always_include_optional)
        except:
            _DecorateActiveException("description")

        # Additional data
        if process_additional_data:
            cls._ApplyAdditionalData(
                item,
                result,
                exclude_names={"description", "simple_schema"},
            )

        return result

    # ----------------------------------------------------------------------
    @classmethod
    def _endpoints_methods_responses_Item(cls, item, always_include_optional, process_additional_data):
        endpoints_methods_responses_TypeInfo.ValidateItem(
            item,
            recurse=False,
            require_exact_match=not process_additional_data,
        )

        attributes = OrderedDict()

        # code
        try:
            attributes["code"] = cls.endpoints_methods_responses_code(
                cls._GetPythonAttribute(
                    item,
                    "code",
                    is_optional=False,
                ),
            )
        except:
            _DecorateActiveException("code")

        result = _CreatePythonObject(
            attributes=attributes,
        )

        # summary
        try:
            cls._ApplyOptionalChild(item, "summary", result, cls.endpoints_methods_responses_summary, always_include_optional)
        except:
            _DecorateActiveException("summary")

        # description
        try:
            cls._ApplyOptionalChild(item, "description", result, cls.endpoints_methods_responses_description, always_include_optional)
        except:
            _DecorateActiveException("description")

        # simple_schema_content
        try:
            cls._ApplyOptionalChild(item, "simple_schema_content", result, cls.endpoints_methods_responses_simple_schema_content, always_include_optional)
        except:
            _DecorateActiveException("simple_schema_content")

        # context
        try:
            cls._ApplyOptionalChild(item, "context", result, cls.endpoints_methods_responses_context, always_include_optional)
        except:
            _DecorateActiveException("context")

        # default_content
        try:
            cls._ApplyOptionalChild(item, "default_content", result, lambda value: cls.endpoints_methods_responses_default_content(value, always_include_optional, process_additional_data), always_include_optional)
        except:
            _DecorateActiveException("default_content")

        # contents
        try:
            cls._ApplyOptionalChildren(item, "contents", result, lambda value: cls.endpoints_methods_responses_contents(value, always_include_optional, process_additional_data), always_include_optional)
        except:
            _DecorateActiveException("contents")

        # Additional data
        if process_additional_data:
            cls._ApplyAdditionalData(
                item,
                result,
                exclude_names={"code", "summary", "description", "simple_schema_content", "context", "default_content", "contents"},
            )

        return result

    # ----------------------------------------------------------------------
    @classmethod
    def _endpoints_methods_responses_code_Item(cls, item):
        return YamlSerialization.SerializeItem(endpoints_methods_responses_code_TypeInfo, item, **{})

    # ----------------------------------------------------------------------
    @classmethod
    def _endpoints_methods_responses_default_content_Item(cls, item, always_include_optional, process_additional_data):
        endpoints_methods_responses_default_content_TypeInfo.ValidateItem(
            item,
            recurse=False,
            require_exact_match=not process_additional_data,
        )

        result = _CreatePythonObject(
            attributes=None,
        )

        # headers
        try:
            cls._ApplyOptionalChildren(item, "headers", result, lambda value: cls.endpoints_methods_ResponseContent_headers(value, always_include_optional, process_additional_data), always_include_optional)
        except:
            _DecorateActiveException("headers")

        # body
        try:
            cls._ApplyOptionalChild(item, "body", result, lambda value: cls.endpoints_methods_ResponseContent_body(value, always_include_optional, process_additional_data), always_include_optional)
        except:
            _DecorateActiveException("body")

        # Additional data
        if process_additional_data:
            cls._ApplyAdditionalData(
                item,
                result,
                exclude_names={"headers", "body"},
            )

        return result

    # ----------------------------------------------------------------------
    @classmethod
    def _endpoints_methods_responses_contents_Item(cls, item, always_include_optional, process_additional_data):
        endpoints_methods_responses_contents_TypeInfo.ValidateItem(
            item,
            recurse=False,
            require_exact_match=not process_additional_data,
        )

        attributes = OrderedDict()

        # content_type
        try:
            attributes["content_type"] = cls.endpoints_methods_responses_contents_content_type(
                cls._GetPythonAttribute(
                    item,
                    "content_type",
                    is_optional=False,
                ),
            )
        except:
            _DecorateActiveException("content_type")

        result = _CreatePythonObject(
            attributes=attributes,
        )

        # headers
        try:
            cls._ApplyOptionalChildren(item, "headers", result, lambda value: cls.endpoints_methods_ResponseContent_headers(value, always_include_optional, process_additional_data), always_include_optional)
        except:
            _DecorateActiveException("headers")

        # body
        try:
            cls._ApplyOptionalChild(item, "body", result, lambda value: cls.endpoints_methods_ResponseContent_body(value, always_include_optional, process_additional_data), always_include_optional)
        except:
            _DecorateActiveException("body")

        # Additional data
        if process_additional_data:
            cls._ApplyAdditionalData(
                item,
                result,
                exclude_names={"content_type", "headers", "body"},
            )

        return result

    # ----------------------------------------------------------------------
    @classmethod
    def _endpoints_methods_responses_contents_content_type_Item(cls, item):
        return YamlSerialization.SerializeItem(endpoints_methods_responses_contents_content_type_TypeInfo, item, **{})

    # ----------------------------------------------------------------------
    @classmethod
    def _endpoints_children_Item(cls, item, always_include_optional, process_additional_data):
        endpoints_children_TypeInfo.ValidateItem(
            item,
            recurse=False,
            require_exact_match=not process_additional_data,
        )

        attributes = OrderedDict()

        # uri
        try:
            attributes["uri"] = cls.endpoints_uri(
                cls._GetPythonAttribute(
                    item,
                    "uri",
                    is_optional=False,
                ),
            )
        except:
            _DecorateActiveException("uri")

        # group
        try:
            cls._ApplyOptionalAttribute(item, "group", attributes, cls.endpoints_group, always_include_optional)
        except:
            _DecorateActiveException("group")

        result = _CreatePythonObject(
            attributes=attributes,
        )

        # variables
        try:
            cls._ApplyOptionalChildren(item, "variables", result, lambda value: cls.endpoints_variables(value, always_include_optional, process_additional_data), always_include_optional)
        except:
            _DecorateActiveException("variables")

        # summary
        try:
            cls._ApplyOptionalChild(item, "summary", result, cls.endpoints_summary, always_include_optional)
        except:
            _DecorateActiveException("summary")

        # description
        try:
            cls._ApplyOptionalChild(item, "description", result, cls.endpoints_description, always_include_optional)
        except:
            _DecorateActiveException("description")

        # simple_schema_content
        try:
            cls._ApplyOptionalChild(item, "simple_schema_content", result, cls.endpoints_simple_schema_content, always_include_optional)
        except:
            _DecorateActiveException("simple_schema_content")

        # context
        try:
            cls._ApplyOptionalChild(item, "context", result, cls.endpoints_context, always_include_optional)
        except:
            _DecorateActiveException("context")

        # methods
        try:
            cls._ApplyOptionalChildren(item, "methods", result, lambda value: cls.endpoints_methods(value, always_include_optional, process_additional_data), always_include_optional)
        except:
            _DecorateActiveException("methods")

        # children
        try:
            cls._ApplyOptionalChildren(item, "children", result, lambda value: cls.endpoints_children(value, always_include_optional, process_additional_data), always_include_optional)
        except:
            _DecorateActiveException("children")

        # Additional data
        if process_additional_data:
            cls._ApplyAdditionalData(
                item,
                result,
                exclude_names={"uri", "variables", "group", "summary", "description", "simple_schema_content", "context", "methods", "children"},
            )

        return result

    # ----------------------------------------------------------------------
    # ----------------------------------------------------------------------
    # ----------------------------------------------------------------------
    @classmethod
    def _ApplyOptionalChild(cls, item, attribute_name, dest, apply_func, always_include_optional, default_value_func=None):
        value = cls._GetPythonAttribute(
            item,
            attribute_name,
            is_optional=True,
        )

        if value is not DoesNotExist:
            value = apply_func(value)
            if value is not DoesNotExist:
                setattr(dest, attribute_name, value)
                return

        if default_value_func:
            setattr(dest, attribute_name, default_value_func())
            return

        if always_include_optional:
            setattr(dest, attribute_name, None)

    # ----------------------------------------------------------------------
    @classmethod
    def _ApplyOptionalChildren(cls, items, attribute_name, dest, apply_func, always_include_optional):
        value = cls._GetPythonAttribute(
            items,
            attribute_name,
            is_optional=True,
        )

        if value is not DoesNotExist:
            value = apply_func(value)
            if value is not DoesNotExist:
                setattr(dest, attribute_name, value)
                return

        # No default statement

        if always_include_optional:
            setattr(dest, attribute_name, [])

    # ----------------------------------------------------------------------
    @classmethod
    def _ApplyOptionalAttribute(cls, item, attribute_name, dest, apply_func, always_include_optional, default_value_func=None):
        value = cls._GetPythonAttribute(
            item,
            attribute_name,
            is_optional=True,
        )

        if value is not DoesNotExist:
            value = apply_func(value)
            if value is not DoesNotExist:
                dest[attribute_name] = value
                return

        if default_value_func:
            dest[attribute_name] = default_value_func()
            return

        if always_include_optional:
            dest[attribute_name] = None

    # ----------------------------------------------------------------------
    @classmethod
    def _ApplyAdditionalData(
        cls,
        source,
        dest,
        exclude_names,
    ):
        for name, child in [(k, v) for k, v in six.iteritems(source if isinstance(source, dict) else getattr(source, "__dict__", {})) if not k.startswith("_") and k not in exclude_names]:
            try:
                if isinstance(child, list):
                    children = []

                    for index, item in enumerate(child):
                        item_name = "Index {}".format(index)

                        try:
                            children.append(cls._CreateAdditionalDataItem(item_name, item))
                        except:
                            _DecorateActiveException(item_name)

                    setattr(dest, name, children)
                else:
                    setattr(dest, name, cls._CreateAdditionalDataItem(name, child))
            except:
                _DecorateActiveException(name)

    # ----------------------------------------------------------------------
    @classmethod
    def _RejectAdditionalData(cls, source, exclude_names):
        errors = []

        for name, child in [(k, v) for k, v in six.iteritems(source if isinstance(source, dict) else getattr(source, "__dict__", {})) if not k.startswith("_") and k not in exclude_names]:
            errors.append(name)

        if errors:
            raise Exception("The item contains unexpected children: {}".format(", ".join(['"{}"'.format(error) for error in errors])))

    # ----------------------------------------------------------------------
    @classmethod
    def _CreateAdditionalDataItem(cls, name, source):
        # The following types should be returned directly without additional conversion
        if isinstance(source, (int, float, str, bool)):
            return source

        assert not isinstance(source, list), source

        if not isinstance(source, dict):
            source = source.__dict__

        source_attribute_names = source.get("_attribute_names", set())

        attributes = OrderedDict()
        items = OrderedDict()

        for k, v in six.iteritems(source):
            if k.startswith("_"):
                continue

            if k in source_attribute_names:
                attributes[k] = v
            else:
                items[k] = v

        if len(items) == 1 and next(six.iterkeys(items)) == source.get("_text_attribute_name", None):
            return _CreatePythonObject(
                attributes=attributes,
                **{"simple_value": source[source["_text_attribute_name"]], "_text_attribute_name": "simple_value"},
            )

        result = _CreatePythonObject(
            attributes=attributes,
        )

        for k, v in six.iteritems(items):
            try:
                if isinstance(v, list):
                    new_items = []

                    for index, child in enumerate(v):
                        try:
                            new_items.append(cls._CreateAdditionalDataItem("item", child))
                        except:
                            _DecorateActiveException("Index {}".format(index))

                    setattr(result, k, new_items)
                else:
                    new_item = cls._CreateAdditionalDataItem(k, v)

                    setattr(result, k, new_item)
            except:
                _DecorateActiveException(k)

        return result

    # ----------------------------------------------------------------------
    @staticmethod
    def _GetPythonAttribute(
        item,
        attribute_name,
        is_optional=False,
    ):
        if not isinstance(item, dict):
            if hasattr(item, "__dict__"):
                item = item.__dict__
            else:
                item = {}

        value = item.get(attribute_name, DoesNotExist)
        if value is DoesNotExist and not is_optional:
            raise SerializeException("No items were found")

        return value


# ----------------------------------------------------------------------
class Object(object):
    def __init__(self):
        self._attribute_names = set()

    def __repr__(self):
        return CommonEnvironment.ObjectReprImpl(self)


# ----------------------------------------------------------------------
def _CreatePythonObject(
    attributes=None,
    **kwargs
):
    attributes = attributes or {}

    result = Object()

    for d in [attributes, kwargs]:
        for k, v in six.iteritems(d):
            setattr(result, k, v)

    for k in six.iterkeys(attributes):
        result._attribute_names.add(k)

    return result


# ----------------------------------------------------------------------
# |
# |  Deserializer
# |
# ----------------------------------------------------------------------
class Deserializer(object):

    # ----------------------------------------------------------------------
    @classmethod
    def description(cls, item):
        if item in [DoesNotExist, None]:
            description_TypeInfo.ValidateArity(None)
            return DoesNotExist

        result = cls._description_Item(item)

        description_TypeInfo.ValidateArity(result)

        return result

    # ----------------------------------------------------------------------
    @classmethod
    def summary(cls, item):
        if item in [DoesNotExist, None]:
            summary_TypeInfo.ValidateArity(None)
            return DoesNotExist

        result = cls._summary_Item(item)

        summary_TypeInfo.ValidateArity(result)

        return result

    # ----------------------------------------------------------------------
    @classmethod
    def type_description(cls, item, always_include_optional, process_additional_data):
        if item in [DoesNotExist, None]:
            type_description_TypeInfo.ValidateArity(None)
            return DoesNotExist

        result = cls._type_description_Item(item, always_include_optional, process_additional_data)

        if not process_additional_data:
            type_description_TypeInfo.ValidateArity(result)

        return result

    # ----------------------------------------------------------------------
    @classmethod
    def type_description_description(cls, item):
        return cls.description(item)

    # ----------------------------------------------------------------------
    @classmethod
    def type_descriptions(cls, items, always_include_optional, process_additional_data):
        if items in [DoesNotExist, None, []]:
            type_descriptions_TypeInfo.ValidateArity(None)
            return DoesNotExist

        results = []

        for this_index, this_item in enumerate(items or []):
            try:
                results.append(cls._type_descriptions_Item(this_item, always_include_optional, process_additional_data))
            except:
                _DecorateActiveException("Index {}".format(this_index))

        _ValidateKeys("name", results)


        if not process_additional_data:
            type_descriptions_TypeInfo.ValidateArity(results)

        return results

    # ----------------------------------------------------------------------
    @classmethod
    def type_descriptions_name(cls, item):
        if item in [DoesNotExist, None]:
            type_descriptions_name_TypeInfo.ValidateArity(None)
            return DoesNotExist

        result = cls._type_descriptions_name_Item(item)

        type_descriptions_name_TypeInfo.ValidateArity(result)

        return result

    # ----------------------------------------------------------------------
    @classmethod
    def type_descriptions_description(cls, item):
        return cls.description(item)

    # ----------------------------------------------------------------------
    @classmethod
    def context(cls, item):
        if item in [DoesNotExist, None]:
            context_TypeInfo.ValidateArity(None)
            return DoesNotExist

        result = cls._context_Item(item)

        context_TypeInfo.ValidateArity(result)

        return result

    # ----------------------------------------------------------------------
    @classmethod
    def simple_schema_content(cls, item):
        if item in [DoesNotExist, None]:
            simple_schema_content_TypeInfo.ValidateArity(None)
            return DoesNotExist

        result = cls._simple_schema_content_Item(item)

        simple_schema_content_TypeInfo.ValidateArity(result)

        return result

    # ----------------------------------------------------------------------
    @classmethod
    def endpoints(cls, items, always_include_optional, process_additional_data):
        if items in [DoesNotExist, None, []]:
            endpoints_TypeInfo.ValidateArity(None)
            return DoesNotExist

        results = []

        for this_index, this_item in enumerate(items or []):
            try:
                results.append(cls._endpoints_Item(this_item, always_include_optional, process_additional_data))
            except:
                _DecorateActiveException("Index {}".format(this_index))

        _ValidateKeys("uri", results)


        if not process_additional_data:
            endpoints_TypeInfo.ValidateArity(results)

        return results

    # ----------------------------------------------------------------------
    @classmethod
    def endpoints_uri(cls, item):
        if item in [DoesNotExist, None]:
            endpoints_uri_TypeInfo.ValidateArity(None)
            return DoesNotExist

        result = cls._endpoints_uri_Item(item)

        endpoints_uri_TypeInfo.ValidateArity(result)

        return result

    # ----------------------------------------------------------------------
    @classmethod
    def endpoints_variables(cls, items, always_include_optional, process_additional_data):
        return cls.type_descriptions(items, always_include_optional, process_additional_data)

    # ----------------------------------------------------------------------
    @classmethod
    def endpoints_group(cls, item):
        if item in [DoesNotExist, None]:
            endpoints_group_TypeInfo.ValidateArity(None)
            return DoesNotExist

        result = cls._endpoints_group_Item(item)

        endpoints_group_TypeInfo.ValidateArity(result)

        return result

    # ----------------------------------------------------------------------
    @classmethod
    def endpoints_summary(cls, item):
        return cls.summary(item)

    # ----------------------------------------------------------------------
    @classmethod
    def endpoints_description(cls, item):
        return cls.description(item)

    # ----------------------------------------------------------------------
    @classmethod
    def endpoints_simple_schema_content(cls, item):
        return cls.simple_schema_content(item)

    # ----------------------------------------------------------------------
    @classmethod
    def endpoints_context(cls, item):
        return cls.context(item)

    # ----------------------------------------------------------------------
    @classmethod
    def endpoints_methods(cls, items, always_include_optional, process_additional_data):
        if items in [DoesNotExist, None, []]:
            endpoints_methods_TypeInfo.ValidateArity(None)
            return DoesNotExist

        results = []

        for this_index, this_item in enumerate(items or []):
            try:
                results.append(cls._endpoints_methods_Item(this_item, always_include_optional, process_additional_data))
            except:
                _DecorateActiveException("Index {}".format(this_index))

        _ValidateKeys("verb", results)


        if not process_additional_data:
            endpoints_methods_TypeInfo.ValidateArity(results)

        return results

    # ----------------------------------------------------------------------
    @classmethod
    def endpoints_methods_verb(cls, item):
        if item in [DoesNotExist, None]:
            endpoints_methods_verb_TypeInfo.ValidateArity(None)
            return DoesNotExist

        result = cls._endpoints_methods_verb_Item(item)

        endpoints_methods_verb_TypeInfo.ValidateArity(result)

        return result

    # ----------------------------------------------------------------------
    @classmethod
    def endpoints_methods_summary(cls, item):
        return cls.endpoints_summary(item)

    # ----------------------------------------------------------------------
    @classmethod
    def endpoints_methods_description(cls, item):
        return cls.endpoints_description(item)

    # ----------------------------------------------------------------------
    @classmethod
    def endpoints_methods_simple_schema_content(cls, item):
        return cls.endpoints_simple_schema_content(item)

    # ----------------------------------------------------------------------
    @classmethod
    def endpoints_methods_context(cls, item):
        return cls.endpoints_context(item)

    # ----------------------------------------------------------------------
    @classmethod
    def endpoints_methods_RequestContent(cls, item, always_include_optional, process_additional_data):
        if item in [DoesNotExist, None]:
            endpoints_methods_RequestContent_TypeInfo.ValidateArity(None)
            return DoesNotExist

        result = cls._endpoints_methods_RequestContent_Item(item, always_include_optional, process_additional_data)

        if not process_additional_data:
            endpoints_methods_RequestContent_TypeInfo.ValidateArity(result)

        return result

    # ----------------------------------------------------------------------
    @classmethod
    def endpoints_methods_RequestContent_headers(cls, items, always_include_optional, process_additional_data):
        return cls.type_descriptions(items, always_include_optional, process_additional_data)

    # ----------------------------------------------------------------------
    @classmethod
    def endpoints_methods_RequestContent_query_items(cls, items, always_include_optional, process_additional_data):
        return cls.type_descriptions(items, always_include_optional, process_additional_data)

    # ----------------------------------------------------------------------
    @classmethod
    def endpoints_methods_RequestContent_form_items(cls, items, always_include_optional, process_additional_data):
        return cls.type_descriptions(items, always_include_optional, process_additional_data)

    # ----------------------------------------------------------------------
    @classmethod
    def endpoints_methods_RequestContent_body(cls, item, always_include_optional, process_additional_data):
        if item in [DoesNotExist, None]:
            endpoints_methods_RequestContent_body_TypeInfo.ValidateArity(None)
            return DoesNotExist

        result = cls._endpoints_methods_RequestContent_body_Item(item, always_include_optional, process_additional_data)

        if not process_additional_data:
            endpoints_methods_RequestContent_body_TypeInfo.ValidateArity(result)

        return result

    # ----------------------------------------------------------------------
    @classmethod
    def endpoints_methods_default_request(cls, item, always_include_optional, process_additional_data):
        if item in [DoesNotExist, None]:
            endpoints_methods_default_request_TypeInfo.ValidateArity(None)
            return DoesNotExist

        result = cls._endpoints_methods_default_request_Item(item, always_include_optional, process_additional_data)

        if not process_additional_data:
            endpoints_methods_default_request_TypeInfo.ValidateArity(result)

        return result

    # ----------------------------------------------------------------------
    @classmethod
    def endpoints_methods_requests(cls, items, always_include_optional, process_additional_data):
        if items in [DoesNotExist, None, []]:
            endpoints_methods_requests_TypeInfo.ValidateArity(None)
            return DoesNotExist

        results = []

        for this_index, this_item in enumerate(items or []):
            try:
                results.append(cls._endpoints_methods_requests_Item(this_item, always_include_optional, process_additional_data))
            except:
                _DecorateActiveException("Index {}".format(this_index))

        _ValidateKeys("content_type", results)


        if not process_additional_data:
            endpoints_methods_requests_TypeInfo.ValidateArity(results)

        return results

    # ----------------------------------------------------------------------
    @classmethod
    def endpoints_methods_requests_content_type(cls, item):
        if item in [DoesNotExist, None]:
            endpoints_methods_requests_content_type_TypeInfo.ValidateArity(None)
            return DoesNotExist

        result = cls._endpoints_methods_requests_content_type_Item(item)

        endpoints_methods_requests_content_type_TypeInfo.ValidateArity(result)

        return result

    # ----------------------------------------------------------------------
    @classmethod
    def endpoints_methods_ResponseContent(cls, item, always_include_optional, process_additional_data):
        if item in [DoesNotExist, None]:
            endpoints_methods_ResponseContent_TypeInfo.ValidateArity(None)
            return DoesNotExist

        result = cls._endpoints_methods_ResponseContent_Item(item, always_include_optional, process_additional_data)

        if not process_additional_data:
            endpoints_methods_ResponseContent_TypeInfo.ValidateArity(result)

        return result

    # ----------------------------------------------------------------------
    @classmethod
    def endpoints_methods_ResponseContent_headers(cls, items, always_include_optional, process_additional_data):
        return cls.type_descriptions(items, always_include_optional, process_additional_data)

    # ----------------------------------------------------------------------
    @classmethod
    def endpoints_methods_ResponseContent_body(cls, item, always_include_optional, process_additional_data):
        if item in [DoesNotExist, None]:
            endpoints_methods_ResponseContent_body_TypeInfo.ValidateArity(None)
            return DoesNotExist

        result = cls._endpoints_methods_ResponseContent_body_Item(item, always_include_optional, process_additional_data)

        if not process_additional_data:
            endpoints_methods_ResponseContent_body_TypeInfo.ValidateArity(result)

        return result

    # ----------------------------------------------------------------------
    @classmethod
    def endpoints_methods_responses(cls, items, always_include_optional, process_additional_data):
        if items in [DoesNotExist, None, []]:
            endpoints_methods_responses_TypeInfo.ValidateArity(None)
            return DoesNotExist

        results = []

        for this_index, this_item in enumerate(items or []):
            try:
                results.append(cls._endpoints_methods_responses_Item(this_item, always_include_optional, process_additional_data))
            except:
                _DecorateActiveException("Index {}".format(this_index))

        _ValidateKeys("code", results)


        if not process_additional_data:
            endpoints_methods_responses_TypeInfo.ValidateArity(results)

        return results

    # ----------------------------------------------------------------------
    @classmethod
    def endpoints_methods_responses_code(cls, item):
        if item in [DoesNotExist, None]:
            endpoints_methods_responses_code_TypeInfo.ValidateArity(None)
            return DoesNotExist

        result = cls._endpoints_methods_responses_code_Item(item)

        endpoints_methods_responses_code_TypeInfo.ValidateArity(result)

        return result

    # ----------------------------------------------------------------------
    @classmethod
    def endpoints_methods_responses_summary(cls, item):
        return cls.endpoints_methods_summary(item)

    # ----------------------------------------------------------------------
    @classmethod
    def endpoints_methods_responses_description(cls, item):
        return cls.endpoints_methods_description(item)

    # ----------------------------------------------------------------------
    @classmethod
    def endpoints_methods_responses_simple_schema_content(cls, item):
        return cls.endpoints_methods_simple_schema_content(item)

    # ----------------------------------------------------------------------
    @classmethod
    def endpoints_methods_responses_context(cls, item):
        return cls.endpoints_methods_context(item)

    # ----------------------------------------------------------------------
    @classmethod
    def endpoints_methods_responses_default_content(cls, item, always_include_optional, process_additional_data):
        if item in [DoesNotExist, None]:
            endpoints_methods_responses_default_content_TypeInfo.ValidateArity(None)
            return DoesNotExist

        result = cls._endpoints_methods_responses_default_content_Item(item, always_include_optional, process_additional_data)

        if not process_additional_data:
            endpoints_methods_responses_default_content_TypeInfo.ValidateArity(result)

        return result

    # ----------------------------------------------------------------------
    @classmethod
    def endpoints_methods_responses_contents(cls, items, always_include_optional, process_additional_data):
        if items in [DoesNotExist, None, []]:
            endpoints_methods_responses_contents_TypeInfo.ValidateArity(None)
            return DoesNotExist

        results = []

        for this_index, this_item in enumerate(items or []):
            try:
                results.append(cls._endpoints_methods_responses_contents_Item(this_item, always_include_optional, process_additional_data))
            except:
                _DecorateActiveException("Index {}".format(this_index))

        _ValidateKeys("content_type", results)


        if not process_additional_data:
            endpoints_methods_responses_contents_TypeInfo.ValidateArity(results)

        return results

    # ----------------------------------------------------------------------
    @classmethod
    def endpoints_methods_responses_contents_content_type(cls, item):
        if item in [DoesNotExist, None]:
            endpoints_methods_responses_contents_content_type_TypeInfo.ValidateArity(None)
            return DoesNotExist

        result = cls._endpoints_methods_responses_contents_content_type_Item(item)

        endpoints_methods_responses_contents_content_type_TypeInfo.ValidateArity(result)

        return result

    # ----------------------------------------------------------------------
    @classmethod
    def endpoints_children(cls, items, always_include_optional, process_additional_data):
        if items in [DoesNotExist, None, []]:
            endpoints_children_TypeInfo.ValidateArity(None)
            return DoesNotExist

        results = []

        for this_index, this_item in enumerate(items or []):
            try:
                results.append(cls._endpoints_children_Item(this_item, always_include_optional, process_additional_data))
            except:
                _DecorateActiveException("Index {}".format(this_index))

        _ValidateKeys("uri", results)


        if not process_additional_data:
            endpoints_children_TypeInfo.ValidateArity(results)

        return results

    # ----------------------------------------------------------------------
    # ----------------------------------------------------------------------
    # ----------------------------------------------------------------------
    @classmethod
    def _description_Item(cls, item):
        return YamlSerialization.DeserializeItem(description_TypeInfo, item, **{})

    # ----------------------------------------------------------------------
    @classmethod
    def _summary_Item(cls, item):
        return YamlSerialization.DeserializeItem(summary_TypeInfo, item, **{})

    # ----------------------------------------------------------------------
    @classmethod
    def _type_description_Item(cls, item, always_include_optional, process_additional_data):
        # <fundamental value>
        try:
            fundamental_value = YamlSerialization.DeserializeItem(type_description__value__TypeInfo, cls._GetPythonAttribute(
                item,
                "simple_schema",
                is_optional=False,
            )
            , **{})
        except:
            _DecorateActiveException("value type")

        result = _CreatePythonObject(
            attributes=None,
            **{"simple_schema": fundamental_value, "_text_attribute_name": "simple_schema"},
        )


        # description
        try:
            cls._ApplyOptionalChild(item, "description", result, cls.type_description_description, always_include_optional)
        except:
            _DecorateActiveException("description")

        # Additional data
        if process_additional_data:
            cls._ApplyAdditionalData(
                item,
                result,
                exclude_names={"description", "simple_schema"},
            )

        else:
            cls._RejectAdditionalData(
                item,
                exclude_names=["description", "simple_schema"],
            )

        type_description_TypeInfo.ValidateItem(
            result,
            recurse=False,
            require_exact_match=not process_additional_data,
        )

        return result

    # ----------------------------------------------------------------------
    @classmethod
    def _type_descriptions_Item(cls, item, always_include_optional, process_additional_data):
        attributes = OrderedDict()

        # name
        try:
            attributes["name"] = cls.type_descriptions_name(
                cls._GetPythonAttribute(
                    item,
                    "name",
                    is_optional=False,
                ),
            )
        except:
            _DecorateActiveException("name")

        # <fundamental value>
        try:
            fundamental_value = YamlSerialization.DeserializeItem(type_descriptions__value__TypeInfo, cls._GetPythonAttribute(
                item,
                "simple_schema",
                is_optional=False,
            )
            , **{})
        except:
            _DecorateActiveException("value type")

        result = _CreatePythonObject(
            attributes=attributes,
            **{"simple_schema": fundamental_value, "_text_attribute_name": "simple_schema"},
        )


        # description
        try:
            cls._ApplyOptionalChild(item, "description", result, cls.type_descriptions_description, always_include_optional)
        except:
            _DecorateActiveException("description")

        # Additional data
        if process_additional_data:
            cls._ApplyAdditionalData(
                item,
                result,
                exclude_names={"name", "description", "simple_schema"},
            )

        else:
            cls._RejectAdditionalData(
                item,
                exclude_names=["name", "description", "simple_schema"],
            )

        type_descriptions_TypeInfo.ValidateItem(
            result,
            recurse=False,
            require_exact_match=not process_additional_data,
        )

        return result

    # ----------------------------------------------------------------------
    @classmethod
    def _type_descriptions_name_Item(cls, item):
        return YamlSerialization.DeserializeItem(type_descriptions_name_TypeInfo, item, **{})

    # ----------------------------------------------------------------------
    @classmethod
    def _context_Item(cls, item):
        return YamlSerialization.DeserializeItem(context_TypeInfo, item, **{})

    # ----------------------------------------------------------------------
    @classmethod
    def _simple_schema_content_Item(cls, item):
        return YamlSerialization.DeserializeItem(simple_schema_content_TypeInfo, item, **{})

    # ----------------------------------------------------------------------
    @classmethod
    def _endpoints_Item(cls, item, always_include_optional, process_additional_data):
        attributes = OrderedDict()

        # uri
        try:
            attributes["uri"] = cls.endpoints_uri(
                cls._GetPythonAttribute(
                    item,
                    "uri",
                    is_optional=False,
                ),
            )
        except:
            _DecorateActiveException("uri")

        # group
        try:
            cls._ApplyOptionalAttribute(item, "group", attributes, cls.endpoints_group, always_include_optional)
        except:
            _DecorateActiveException("group")

        result = _CreatePythonObject(
            attributes=attributes,
        )

        # variables
        try:
            cls._ApplyOptionalChildren(item, "variables", result, lambda value: cls.endpoints_variables(value, always_include_optional, process_additional_data), always_include_optional)
        except:
            _DecorateActiveException("variables")

        # summary
        try:
            cls._ApplyOptionalChild(item, "summary", result, cls.endpoints_summary, always_include_optional)
        except:
            _DecorateActiveException("summary")

        # description
        try:
            cls._ApplyOptionalChild(item, "description", result, cls.endpoints_description, always_include_optional)
        except:
            _DecorateActiveException("description")

        # simple_schema_content
        try:
            cls._ApplyOptionalChild(item, "simple_schema_content", result, cls.endpoints_simple_schema_content, always_include_optional)
        except:
            _DecorateActiveException("simple_schema_content")

        # context
        try:
            cls._ApplyOptionalChild(item, "context", result, cls.endpoints_context, always_include_optional)
        except:
            _DecorateActiveException("context")

        # methods
        try:
            cls._ApplyOptionalChildren(item, "methods", result, lambda value: cls.endpoints_methods(value, always_include_optional, process_additional_data), always_include_optional)
        except:
            _DecorateActiveException("methods")

        # children
        try:
            cls._ApplyOptionalChildren(item, "children", result, lambda value: cls.endpoints_children(value, always_include_optional, process_additional_data), always_include_optional)
        except:
            _DecorateActiveException("children")

        # Additional data
        if process_additional_data:
            cls._ApplyAdditionalData(
                item,
                result,
                exclude_names={"uri", "variables", "group", "summary", "description", "simple_schema_content", "context", "methods", "children"},
            )

        else:
            cls._RejectAdditionalData(
                item,
                exclude_names=["uri", "variables", "group", "summary", "description", "simple_schema_content", "context", "methods", "children"],
            )

        endpoints_TypeInfo.ValidateItem(
            result,
            recurse=False,
            require_exact_match=not process_additional_data,
        )

        return result

    # ----------------------------------------------------------------------
    @classmethod
    def _endpoints_uri_Item(cls, item):
        return YamlSerialization.DeserializeItem(endpoints_uri_TypeInfo, item, **{})

    # ----------------------------------------------------------------------
    @classmethod
    def _endpoints_group_Item(cls, item):
        return YamlSerialization.DeserializeItem(endpoints_group_TypeInfo, item, **{})

    # ----------------------------------------------------------------------
    @classmethod
    def _endpoints_methods_Item(cls, item, always_include_optional, process_additional_data):
        attributes = OrderedDict()

        # verb
        try:
            attributes["verb"] = cls.endpoints_methods_verb(
                cls._GetPythonAttribute(
                    item,
                    "verb",
                    is_optional=False,
                ),
            )
        except:
            _DecorateActiveException("verb")

        result = _CreatePythonObject(
            attributes=attributes,
        )

        # summary
        try:
            cls._ApplyOptionalChild(item, "summary", result, cls.endpoints_methods_summary, always_include_optional)
        except:
            _DecorateActiveException("summary")

        # description
        try:
            cls._ApplyOptionalChild(item, "description", result, cls.endpoints_methods_description, always_include_optional)
        except:
            _DecorateActiveException("description")

        # simple_schema_content
        try:
            cls._ApplyOptionalChild(item, "simple_schema_content", result, cls.endpoints_methods_simple_schema_content, always_include_optional)
        except:
            _DecorateActiveException("simple_schema_content")

        # context
        try:
            cls._ApplyOptionalChild(item, "context", result, cls.endpoints_methods_context, always_include_optional)
        except:
            _DecorateActiveException("context")

        # default_request
        try:
            cls._ApplyOptionalChild(item, "default_request", result, lambda value: cls.endpoints_methods_default_request(value, always_include_optional, process_additional_data), always_include_optional)
        except:
            _DecorateActiveException("default_request")

        # requests
        try:
            cls._ApplyOptionalChildren(item, "requests", result, lambda value: cls.endpoints_methods_requests(value, always_include_optional, process_additional_data), always_include_optional)
        except:
            _DecorateActiveException("requests")

        # responses
        try:
            cls._ApplyOptionalChildren(item, "responses", result, lambda value: cls.endpoints_methods_responses(value, always_include_optional, process_additional_data), always_include_optional)
        except:
            _DecorateActiveException("responses")

        # Additional data
        if process_additional_data:
            cls._ApplyAdditionalData(
                item,
                result,
                exclude_names={"verb", "summary", "description", "simple_schema_content", "context", "default_request", "requests", "responses"},
            )

        else:
            cls._RejectAdditionalData(
                item,
                exclude_names=["verb", "summary", "description", "simple_schema_content", "context", "default_request", "requests", "responses"],
            )

        endpoints_methods_TypeInfo.ValidateItem(
            result,
            recurse=False,
            require_exact_match=not process_additional_data,
        )

        return result

    # ----------------------------------------------------------------------
    @classmethod
    def _endpoints_methods_verb_Item(cls, item):
        return YamlSerialization.DeserializeItem(endpoints_methods_verb_TypeInfo, item, **{})

    # ----------------------------------------------------------------------
    @classmethod
    def _endpoints_methods_RequestContent_Item(cls, item, always_include_optional, process_additional_data):
        result = _CreatePythonObject(
            attributes=None,
        )

        # headers
        try:
            cls._ApplyOptionalChildren(item, "headers", result, lambda value: cls.endpoints_methods_RequestContent_headers(value, always_include_optional, process_additional_data), always_include_optional)
        except:
            _DecorateActiveException("headers")

        # query_items
        try:
            cls._ApplyOptionalChildren(item, "query_items", result, lambda value: cls.endpoints_methods_RequestContent_query_items(value, always_include_optional, process_additional_data), always_include_optional)
        except:
            _DecorateActiveException("query_items")

        # form_items
        try:
            cls._ApplyOptionalChildren(item, "form_items", result, lambda value: cls.endpoints_methods_RequestContent_form_items(value, always_include_optional, process_additional_data), always_include_optional)
        except:
            _DecorateActiveException("form_items")

        # body
        try:
            cls._ApplyOptionalChild(item, "body", result, lambda value: cls.endpoints_methods_RequestContent_body(value, always_include_optional, process_additional_data), always_include_optional)
        except:
            _DecorateActiveException("body")

        # Additional data
        if process_additional_data:
            cls._ApplyAdditionalData(
                item,
                result,
                exclude_names={"headers", "query_items", "form_items", "body"},
            )

        else:
            cls._RejectAdditionalData(
                item,
                exclude_names=["headers", "query_items", "form_items", "body"],
            )

        endpoints_methods_RequestContent_TypeInfo.ValidateItem(
            result,
            recurse=False,
            require_exact_match=not process_additional_data,
        )

        return result

    # ----------------------------------------------------------------------
    @classmethod
    def _endpoints_methods_RequestContent_body_Item(cls, item, always_include_optional, process_additional_data):
        # <fundamental value>
        try:
            fundamental_value = YamlSerialization.DeserializeItem(endpoints_methods_RequestContent_body__value__TypeInfo, cls._GetPythonAttribute(
                item,
                "simple_schema",
                is_optional=False,
            )
            , **{})
        except:
            _DecorateActiveException("value type")

        result = _CreatePythonObject(
            attributes=None,
            **{"simple_schema": fundamental_value, "_text_attribute_name": "simple_schema"},
        )


        # description
        try:
            cls._ApplyOptionalChild(item, "description", result, cls.type_description_description, always_include_optional)
        except:
            _DecorateActiveException("description")

        # Additional data
        if process_additional_data:
            cls._ApplyAdditionalData(
                item,
                result,
                exclude_names={"description", "simple_schema"},
            )

        else:
            cls._RejectAdditionalData(
                item,
                exclude_names=["description", "simple_schema"],
            )

        endpoints_methods_RequestContent_body_TypeInfo.ValidateItem(
            result,
            recurse=False,
            require_exact_match=not process_additional_data,
        )

        return result

    # ----------------------------------------------------------------------
    @classmethod
    def _endpoints_methods_default_request_Item(cls, item, always_include_optional, process_additional_data):
        result = _CreatePythonObject(
            attributes=None,
        )

        # headers
        try:
            cls._ApplyOptionalChildren(item, "headers", result, lambda value: cls.endpoints_methods_RequestContent_headers(value, always_include_optional, process_additional_data), always_include_optional)
        except:
            _DecorateActiveException("headers")

        # query_items
        try:
            cls._ApplyOptionalChildren(item, "query_items", result, lambda value: cls.endpoints_methods_RequestContent_query_items(value, always_include_optional, process_additional_data), always_include_optional)
        except:
            _DecorateActiveException("query_items")

        # form_items
        try:
            cls._ApplyOptionalChildren(item, "form_items", result, lambda value: cls.endpoints_methods_RequestContent_form_items(value, always_include_optional, process_additional_data), always_include_optional)
        except:
            _DecorateActiveException("form_items")

        # body
        try:
            cls._ApplyOptionalChild(item, "body", result, lambda value: cls.endpoints_methods_RequestContent_body(value, always_include_optional, process_additional_data), always_include_optional)
        except:
            _DecorateActiveException("body")

        # Additional data
        if process_additional_data:
            cls._ApplyAdditionalData(
                item,
                result,
                exclude_names={"headers", "query_items", "form_items", "body"},
            )

        else:
            cls._RejectAdditionalData(
                item,
                exclude_names=["headers", "query_items", "form_items", "body"],
            )

        endpoints_methods_default_request_TypeInfo.ValidateItem(
            result,
            recurse=False,
            require_exact_match=not process_additional_data,
        )

        return result

    # ----------------------------------------------------------------------
    @classmethod
    def _endpoints_methods_requests_Item(cls, item, always_include_optional, process_additional_data):
        attributes = OrderedDict()

        # content_type
        try:
            attributes["content_type"] = cls.endpoints_methods_requests_content_type(
                cls._GetPythonAttribute(
                    item,
                    "content_type",
                    is_optional=False,
                ),
            )
        except:
            _DecorateActiveException("content_type")

        result = _CreatePythonObject(
            attributes=attributes,
        )

        # headers
        try:
            cls._ApplyOptionalChildren(item, "headers", result, lambda value: cls.endpoints_methods_RequestContent_headers(value, always_include_optional, process_additional_data), always_include_optional)
        except:
            _DecorateActiveException("headers")

        # query_items
        try:
            cls._ApplyOptionalChildren(item, "query_items", result, lambda value: cls.endpoints_methods_RequestContent_query_items(value, always_include_optional, process_additional_data), always_include_optional)
        except:
            _DecorateActiveException("query_items")

        # form_items
        try:
            cls._ApplyOptionalChildren(item, "form_items", result, lambda value: cls.endpoints_methods_RequestContent_form_items(value, always_include_optional, process_additional_data), always_include_optional)
        except:
            _DecorateActiveException("form_items")

        # body
        try:
            cls._ApplyOptionalChild(item, "body", result, lambda value: cls.endpoints_methods_RequestContent_body(value, always_include_optional, process_additional_data), always_include_optional)
        except:
            _DecorateActiveException("body")

        # Additional data
        if process_additional_data:
            cls._ApplyAdditionalData(
                item,
                result,
                exclude_names={"content_type", "headers", "query_items", "form_items", "body"},
            )

        else:
            cls._RejectAdditionalData(
                item,
                exclude_names=["content_type", "headers", "query_items", "form_items", "body"],
            )

        endpoints_methods_requests_TypeInfo.ValidateItem(
            result,
            recurse=False,
            require_exact_match=not process_additional_data,
        )

        return result

    # ----------------------------------------------------------------------
    @classmethod
    def _endpoints_methods_requests_content_type_Item(cls, item):
        return YamlSerialization.DeserializeItem(endpoints_methods_requests_content_type_TypeInfo, item, **{})

    # ----------------------------------------------------------------------
    @classmethod
    def _endpoints_methods_ResponseContent_Item(cls, item, always_include_optional, process_additional_data):
        result = _CreatePythonObject(
            attributes=None,
        )

        # headers
        try:
            cls._ApplyOptionalChildren(item, "headers", result, lambda value: cls.endpoints_methods_ResponseContent_headers(value, always_include_optional, process_additional_data), always_include_optional)
        except:
            _DecorateActiveException("headers")

        # body
        try:
            cls._ApplyOptionalChild(item, "body", result, lambda value: cls.endpoints_methods_ResponseContent_body(value, always_include_optional, process_additional_data), always_include_optional)
        except:
            _DecorateActiveException("body")

        # Additional data
        if process_additional_data:
            cls._ApplyAdditionalData(
                item,
                result,
                exclude_names={"headers", "body"},
            )

        else:
            cls._RejectAdditionalData(
                item,
                exclude_names=["headers", "body"],
            )

        endpoints_methods_ResponseContent_TypeInfo.ValidateItem(
            result,
            recurse=False,
            require_exact_match=not process_additional_data,
        )

        return result

    # ----------------------------------------------------------------------
    @classmethod
    def _endpoints_methods_ResponseContent_body_Item(cls, item, always_include_optional, process_additional_data):
        # <fundamental value>
        try:
            fundamental_value = YamlSerialization.DeserializeItem(endpoints_methods_ResponseContent_body__value__TypeInfo, cls._GetPythonAttribute(
                item,
                "simple_schema",
                is_optional=False,
            )
            , **{})
        except:
            _DecorateActiveException("value type")

        result = _CreatePythonObject(
            attributes=None,
            **{"simple_schema": fundamental_value, "_text_attribute_name": "simple_schema"},
        )


        # description
        try:
            cls._ApplyOptionalChild(item, "description", result, cls.type_description_description, always_include_optional)
        except:
            _DecorateActiveException("description")

        # Additional data
        if process_additional_data:
            cls._ApplyAdditionalData(
                item,
                result,
                exclude_names={"description", "simple_schema"},
            )

        else:
            cls._RejectAdditionalData(
                item,
                exclude_names=["description", "simple_schema"],
            )

        endpoints_methods_ResponseContent_body_TypeInfo.ValidateItem(
            result,
            recurse=False,
            require_exact_match=not process_additional_data,
        )

        return result

    # ----------------------------------------------------------------------
    @classmethod
    def _endpoints_methods_responses_Item(cls, item, always_include_optional, process_additional_data):
        attributes = OrderedDict()

        # code
        try:
            attributes["code"] = cls.endpoints_methods_responses_code(
                cls._GetPythonAttribute(
                    item,
                    "code",
                    is_optional=False,
                ),
            )
        except:
            _DecorateActiveException("code")

        result = _CreatePythonObject(
            attributes=attributes,
        )

        # summary
        try:
            cls._ApplyOptionalChild(item, "summary", result, cls.endpoints_methods_responses_summary, always_include_optional)
        except:
            _DecorateActiveException("summary")

        # description
        try:
            cls._ApplyOptionalChild(item, "description", result, cls.endpoints_methods_responses_description, always_include_optional)
        except:
            _DecorateActiveException("description")

        # simple_schema_content
        try:
            cls._ApplyOptionalChild(item, "simple_schema_content", result, cls.endpoints_methods_responses_simple_schema_content, always_include_optional)
        except:
            _DecorateActiveException("simple_schema_content")

        # context
        try:
            cls._ApplyOptionalChild(item, "context", result, cls.endpoints_methods_responses_context, always_include_optional)
        except:
            _DecorateActiveException("context")

        # default_content
        try:
            cls._ApplyOptionalChild(item, "default_content", result, lambda value: cls.endpoints_methods_responses_default_content(value, always_include_optional, process_additional_data), always_include_optional)
        except:
            _DecorateActiveException("default_content")

        # contents
        try:
            cls._ApplyOptionalChildren(item, "contents", result, lambda value: cls.endpoints_methods_responses_contents(value, always_include_optional, process_additional_data), always_include_optional)
        except:
            _DecorateActiveException("contents")

        # Additional data
        if process_additional_data:
            cls._ApplyAdditionalData(
                item,
                result,
                exclude_names={"code", "summary", "description", "simple_schema_content", "context", "default_content", "contents"},
            )

        else:
            cls._RejectAdditionalData(
                item,
                exclude_names=["code", "summary", "description", "simple_schema_content", "context", "default_content", "contents"],
            )

        endpoints_methods_responses_TypeInfo.ValidateItem(
            result,
            recurse=False,
            require_exact_match=not process_additional_data,
        )

        return result

    # ----------------------------------------------------------------------
    @classmethod
    def _endpoints_methods_responses_code_Item(cls, item):
        return YamlSerialization.DeserializeItem(endpoints_methods_responses_code_TypeInfo, item, **{})

    # ----------------------------------------------------------------------
    @classmethod
    def _endpoints_methods_responses_default_content_Item(cls, item, always_include_optional, process_additional_data):
        result = _CreatePythonObject(
            attributes=None,
        )

        # headers
        try:
            cls._ApplyOptionalChildren(item, "headers", result, lambda value: cls.endpoints_methods_ResponseContent_headers(value, always_include_optional, process_additional_data), always_include_optional)
        except:
            _DecorateActiveException("headers")

        # body
        try:
            cls._ApplyOptionalChild(item, "body", result, lambda value: cls.endpoints_methods_ResponseContent_body(value, always_include_optional, process_additional_data), always_include_optional)
        except:
            _DecorateActiveException("body")

        # Additional data
        if process_additional_data:
            cls._ApplyAdditionalData(
                item,
                result,
                exclude_names={"headers", "body"},
            )

        else:
            cls._RejectAdditionalData(
                item,
                exclude_names=["headers", "body"],
            )

        endpoints_methods_responses_default_content_TypeInfo.ValidateItem(
            result,
            recurse=False,
            require_exact_match=not process_additional_data,
        )

        return result

    # ----------------------------------------------------------------------
    @classmethod
    def _endpoints_methods_responses_contents_Item(cls, item, always_include_optional, process_additional_data):
        attributes = OrderedDict()

        # content_type
        try:
            attributes["content_type"] = cls.endpoints_methods_responses_contents_content_type(
                cls._GetPythonAttribute(
                    item,
                    "content_type",
                    is_optional=False,
                ),
            )
        except:
            _DecorateActiveException("content_type")

        result = _CreatePythonObject(
            attributes=attributes,
        )

        # headers
        try:
            cls._ApplyOptionalChildren(item, "headers", result, lambda value: cls.endpoints_methods_ResponseContent_headers(value, always_include_optional, process_additional_data), always_include_optional)
        except:
            _DecorateActiveException("headers")

        # body
        try:
            cls._ApplyOptionalChild(item, "body", result, lambda value: cls.endpoints_methods_ResponseContent_body(value, always_include_optional, process_additional_data), always_include_optional)
        except:
            _DecorateActiveException("body")

        # Additional data
        if process_additional_data:
            cls._ApplyAdditionalData(
                item,
                result,
                exclude_names={"content_type", "headers", "body"},
            )

        else:
            cls._RejectAdditionalData(
                item,
                exclude_names=["content_type", "headers", "body"],
            )

        endpoints_methods_responses_contents_TypeInfo.ValidateItem(
            result,
            recurse=False,
            require_exact_match=not process_additional_data,
        )

        return result

    # ----------------------------------------------------------------------
    @classmethod
    def _endpoints_methods_responses_contents_content_type_Item(cls, item):
        return YamlSerialization.DeserializeItem(endpoints_methods_responses_contents_content_type_TypeInfo, item, **{})

    # ----------------------------------------------------------------------
    @classmethod
    def _endpoints_children_Item(cls, item, always_include_optional, process_additional_data):
        attributes = OrderedDict()

        # uri
        try:
            attributes["uri"] = cls.endpoints_uri(
                cls._GetPythonAttribute(
                    item,
                    "uri",
                    is_optional=False,
                ),
            )
        except:
            _DecorateActiveException("uri")

        # group
        try:
            cls._ApplyOptionalAttribute(item, "group", attributes, cls.endpoints_group, always_include_optional)
        except:
            _DecorateActiveException("group")

        result = _CreatePythonObject(
            attributes=attributes,
        )

        # variables
        try:
            cls._ApplyOptionalChildren(item, "variables", result, lambda value: cls.endpoints_variables(value, always_include_optional, process_additional_data), always_include_optional)
        except:
            _DecorateActiveException("variables")

        # summary
        try:
            cls._ApplyOptionalChild(item, "summary", result, cls.endpoints_summary, always_include_optional)
        except:
            _DecorateActiveException("summary")

        # description
        try:
            cls._ApplyOptionalChild(item, "description", result, cls.endpoints_description, always_include_optional)
        except:
            _DecorateActiveException("description")

        # simple_schema_content
        try:
            cls._ApplyOptionalChild(item, "simple_schema_content", result, cls.endpoints_simple_schema_content, always_include_optional)
        except:
            _DecorateActiveException("simple_schema_content")

        # context
        try:
            cls._ApplyOptionalChild(item, "context", result, cls.endpoints_context, always_include_optional)
        except:
            _DecorateActiveException("context")

        # methods
        try:
            cls._ApplyOptionalChildren(item, "methods", result, lambda value: cls.endpoints_methods(value, always_include_optional, process_additional_data), always_include_optional)
        except:
            _DecorateActiveException("methods")

        # children
        try:
            cls._ApplyOptionalChildren(item, "children", result, lambda value: cls.endpoints_children(value, always_include_optional, process_additional_data), always_include_optional)
        except:
            _DecorateActiveException("children")

        # Additional data
        if process_additional_data:
            cls._ApplyAdditionalData(
                item,
                result,
                exclude_names={"uri", "variables", "group", "summary", "description", "simple_schema_content", "context", "methods", "children"},
            )

        else:
            cls._RejectAdditionalData(
                item,
                exclude_names=["uri", "variables", "group", "summary", "description", "simple_schema_content", "context", "methods", "children"],
            )

        endpoints_children_TypeInfo.ValidateItem(
            result,
            recurse=False,
            require_exact_match=not process_additional_data,
        )

        return result

    # ----------------------------------------------------------------------
    # ----------------------------------------------------------------------
    # ----------------------------------------------------------------------
    @classmethod
    def _ApplyOptionalChild(cls, item, attribute_name, dest, apply_func, always_include_optional, default_value_func=None):
        value = cls._GetPythonAttribute(
            item,
            attribute_name,
            is_optional=True,
        )

        if value is not DoesNotExist:
            value = apply_func(value)
            if value is not DoesNotExist:
                setattr(dest, attribute_name, value)
                return

        if default_value_func:
            setattr(dest, attribute_name, default_value_func())
            return

        if always_include_optional:
            setattr(dest, attribute_name, None)

    # ----------------------------------------------------------------------
    @classmethod
    def _ApplyOptionalChildren(cls, items, attribute_name, dest, apply_func, always_include_optional):
        value = cls._GetPythonAttribute(
            items,
            attribute_name,
            is_optional=True,
        )

        if value is not DoesNotExist:
            value = apply_func(value)
            if value is not DoesNotExist:
                setattr(dest, attribute_name, value)
                return

        # No default statement

        if always_include_optional:
            setattr(dest, attribute_name, [])

    # ----------------------------------------------------------------------
    @classmethod
    def _ApplyOptionalAttribute(cls, item, attribute_name, dest, apply_func, always_include_optional, default_value_func=None):
        value = cls._GetPythonAttribute(
            item,
            attribute_name,
            is_optional=True,
        )

        if value is not DoesNotExist:
            value = apply_func(value)
            if value is not DoesNotExist:
                dest[attribute_name] = value
                return

        if default_value_func:
            dest[attribute_name] = default_value_func()
            return

        if always_include_optional:
            dest[attribute_name] = None

    # ----------------------------------------------------------------------
    @classmethod
    def _ApplyAdditionalData(
        cls,
        source,
        dest,
        exclude_names,
    ):
        for name, child in [(k, v) for k, v in six.iteritems(source if isinstance(source, dict) else getattr(source, "__dict__", {})) if not k.startswith("_") and k not in exclude_names]:
            try:
                if isinstance(child, list):
                    children = []

                    for index, item in enumerate(child):
                        item_name = "Index {}".format(index)

                        try:
                            children.append(cls._CreateAdditionalDataItem(item_name, item))
                        except:
                            _DecorateActiveException(item_name)

                    setattr(dest, name, children)
                else:
                    setattr(dest, name, cls._CreateAdditionalDataItem(name, child))
            except:
                _DecorateActiveException(name)

    # ----------------------------------------------------------------------
    @classmethod
    def _RejectAdditionalData(cls, source, exclude_names):
        errors = []

        for name, child in [(k, v) for k, v in six.iteritems(source if isinstance(source, dict) else getattr(source, "__dict__", {})) if not k.startswith("_") and k not in exclude_names]:
            errors.append(name)

        if errors:
            raise Exception("The item contains unexpected children: {}".format(", ".join(['"{}"'.format(error) for error in errors])))

    # ----------------------------------------------------------------------
    @classmethod
    def _CreateAdditionalDataItem(cls, name, source):
        # The following types should be returned directly without additional conversion
        if isinstance(source, (int, float, str, bool)):
            return source

        assert not isinstance(source, list), source

        if not isinstance(source, dict):
            source = source.__dict__

        source_attribute_names = source.get("_attribute_names", set())

        attributes = OrderedDict()
        items = OrderedDict()

        for k, v in six.iteritems(source):
            if k.startswith("_"):
                continue

            if k in source_attribute_names:
                attributes[k] = v
            else:
                items[k] = v

        if len(items) == 1 and next(six.iterkeys(items)) == source.get("_text_attribute_name", None):
            return _CreatePythonObject(
                attributes=attributes,
                **{"simple_value": source[source["_text_attribute_name"]], "_text_attribute_name": "simple_value"},
            )

        result = _CreatePythonObject(
            attributes=attributes,
        )

        for k, v in six.iteritems(items):
            try:
                if isinstance(v, list):
                    new_items = []

                    for index, child in enumerate(v):
                        try:
                            new_items.append(cls._CreateAdditionalDataItem("item", child))
                        except:
                            _DecorateActiveException("Index {}".format(index))

                    setattr(result, k, new_items)
                else:
                    new_item = cls._CreateAdditionalDataItem(k, v)

                    setattr(result, k, new_item)
            except:
                _DecorateActiveException(k)

        return result

    # ----------------------------------------------------------------------
    @staticmethod
    def _GetPythonAttribute(
        item,
        attribute_name,
        is_optional=False,
    ):
        if not isinstance(item, dict):
            if hasattr(item, "__dict__"):
                item = item.__dict__
            else:
                item = {}

        value = item.get(attribute_name, DoesNotExist)
        if value is DoesNotExist and not is_optional:
            raise SerializeException("No items were found")

        return value


# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
def _DecorateActiveException(frame_desc):
    exception = sys.exc_info()[1]

    if not hasattr(exception, "stack"):
        setattr(exception, "stack", [])

    exception.stack.insert(0, frame_desc)

    # <The raise statement is not inside an except clause> pylint: disable = E0704
    raise

# ----------------------------------------------------------------------
def _ValidateKeys(key_attribute_name, items):
    keys = set()

    for item in items:
        if isinstance(item, dict):
            key = item.get(key_attribute_name)
        else:
            key = getattr(item, key_attribute_name)

        if key in keys:
            raise KeySerializationException("The key '{}' is not unique: '{}'".format(key_attribute_name, key))

        keys.add(key)


# ----------------------------------------------------------------------
def _ObjectToYaml(dumper, data):
    d = dict(data.__dict__)
    for k in list(six.iterkeys(d)):
        if k.startswith("_"):
            del d[k]

    return dumper.represent_dict(d)


rtyaml.Dumper.add_representer(Object, _ObjectToYaml)
