def __message_to_schema(self, message_type):
name = self.__normalized_name(message_type)<EOL>schema = {<EOL>'<STR_LIT:id>': name,<EOL>'<STR_LIT:type>': '<STR_LIT:object>',<EOL>}<EOL>if message_type.__doc__:<EOL><INDENT>schema['<STR_LIT:description>'] = message_type.__doc__<EOL><DEDENT>properties = {}<EOL>for field in message_type.all_fields():<EOL><INDENT>descriptor = {}<EOL>type_info = {}<EOL>if type(field) == messages.MessageField:<EOL><INDENT>field_type = field.type().__class__<EOL>type_info['<STR_LIT>'] = self.add_message(field_type)<EOL>if field_type.__doc__:<EOL><INDENT>descriptor['<STR_LIT:description>'] = field_type.__doc__<EOL><DEDENT><DEDENT>else:<EOL><INDENT>schema_type = self.__FIELD_TO_SCHEMA_TYPE_MAP.get(<EOL>type(field), self.__DEFAULT_SCHEMA_TYPE)<EOL>if isinstance(schema_type, dict):<EOL><INDENT>variant_map = schema_type<EOL>variant = getattr(field, '<STR_LIT>', None)<EOL>if variant in variant_map:<EOL><INDENT>schema_type = variant_map[variant]<EOL><DEDENT>else:<EOL><INDENT>schema_type = variant_map[None]<EOL><DEDENT><DEDENT>type_info['<STR_LIT:type>'] = schema_type[<NUM_LIT:0>]<EOL>if schema_type[<NUM_LIT:1>]:<EOL><INDENT>type_info['<STR_LIT>'] = schema_type[<NUM_LIT:1>]<EOL><DEDENT><DEDENT>if type(field) == messages.EnumField:<EOL><INDENT>sorted_enums = sorted([enum_info for enum_info in field.type],<EOL>key=lambda enum_info: enum_info.number)<EOL>type_info['<STR_LIT>'] = [enum_info.name for enum_info in sorted_enums]<EOL><DEDENT>if field.required:<EOL><INDENT>descriptor['<STR_LIT>'] = True<EOL><DEDENT>if field.default:<EOL><INDENT>if type(field) == messages.EnumField:<EOL><INDENT>descriptor['<STR_LIT:default>'] = str(field.default)<EOL><DEDENT>else:<EOL><INDENT>descriptor['<STR_LIT:default>'] = field.default<EOL><DEDENT><DEDENT>if field.repeated:<EOL><INDENT>descriptor['<STR_LIT>'] = type_info<EOL>descriptor['<STR_LIT:type>'] = '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>descriptor.update(type_info)<EOL><DEDENT>properties[field.name] = descriptor<EOL><DEDENT>schema['<STR_LIT>'] = properties<EOL>return schema<EOL>
Parse a single message into JSON Schema.

        Will recursively descend the message structure
        and also parse other messages references via MessageFields.

        Args:
          message_type: protorpc.messages.Message class to parse.

        Returns:
          An object representation of the schema.