Repository: so1n/protobuf_to_pydantic (language: python)

Issue:
unbalanced when processing cases like SAME NAME BUT IN DIFFRENT DS
**Describe the bug**
当出现同名内嵌结构时，生成错乱结果

**To Reproduce**
Steps to reproduce the behavior:
1. Run `python -m grpc_tools.protoc -I. --protobuf-to-pydantic_out=. test.proto`

`test.proto`
```
syntax = "proto3";
package test;

option java_multiple_files = true;

message Test0 {
    message Body {
        string input_model = 1;
        map<string, string> input_info = 3;
    }
    Body body = 1;
}

message Test1 {
    message Body {
        string output_model = 1;
        map<string, string> output_info = 3;
    }
    Body body = 1;
}

message Test2 {
    message Body2 {
        string model = 1;
        map<string, string> info = 3;
    }
    Body2 body = 1;
}
```

**Expected behavior**
```
# This is an automatically generated file, please do not change
# gen by protobuf_to_pydantic[v0.3.0.1](https://github.com/so1n/protobuf_to_pydantic)
# Protobuf Version: 5.28.3 
# Pydantic Version: 2.9.2 
from google.protobuf.message import Message  # type: ignore
from pydantic import BaseModel
from pydantic import Field
import typing


class Test0(BaseModel):
    class Body(BaseModel):
        input_model: str = Field(default="")
        input_info: typing.Dict[str, str] = Field(default_factory=dict)

    body: "Test0.Body" = Field()

class Test1(BaseModel):
    class Body(BaseModel):
        output_model : str = Field(default="")
        output_info : typing.Dict[str, str] = Field(default_factory=dict)

    body: "Test1.Body" = Field()

class Test2(BaseModel):
    class Body2(BaseModel):
        model: str = Field(default="")
        info: typing.Dict[str, str] = Field(default_factory=dict)

    body: "Test2.Body2" = Field()
```

**Screenshots**
![image](https://github.com/user-attachments/assets/f902bd02-456a-4062-9303-70a0c3610b52)

**Desktop (please complete the following information):**
 - OS: Linux
 - Version [v0.3.0.1]



Discussion / hints:

Fix patch:
diff --git a/example/example_proto/demo/demo.proto b/example/example_proto/demo/demo.proto
index 5180a36..ca8ef3a 100644
--- a/example/example_proto/demo/demo.proto
+++ b/example/example_proto/demo/demo.proto
@@ -141,3 +141,21 @@ message AnOtherMessage {
     string text = 1;
   }
 }
+
+// Test inline structure of the same name
+// from: https://github.com/so1n/protobuf_to_pydantic/issues/76
+message TestSameName0 {
+    message Body {
+        string input_model = 1;
+        map<string, string> input_info = 3;
+    }
+    Body body = 1;
+}
+
+message TestSameName1 {
+    message Body {
+        string output_model = 1;
+        map<string, string> output_info = 3;
+    }
+    Body body = 1;
+}
diff --git a/example/gen_simple_code.py b/example/gen_simple_code.py
index ac936ce..2ac4e93 100644
--- a/example/gen_simple_code.py
+++ b/example/gen_simple_code.py
@@ -32,7 +32,7 @@
 def gen_code() -> None:
     pydantic_model_to_py_file(
         str(now_path.parent.joinpath(target_p, "demo_gen_code.py")),
-        *[msg_to_pydantic_model(model) for model in message_class_list if model.__name__ == "OptionalMessage"],
+        *[msg_to_pydantic_model(model) for model in message_class_list],
     )
 
 
diff --git a/example/proto_3_20_pydanticv1/demo_gen_code.py b/example/proto_3_20_pydanticv1/demo_gen_code.py
index 5e55120..0a95d28 100644
--- a/example/proto_3_20_pydanticv1/demo_gen_code.py
+++ b/example/proto_3_20_pydanticv1/demo_gen_code.py
@@ -1,13 +1,49 @@
 # This is an automatically generated file, please do not change
-# gen by protobuf_to_pydantic[v0.3.0](https://github.com/so1n/protobuf_to_pydantic)
+# gen by protobuf_to_pydantic[0.0.0](https://github.com/so1n/protobuf_to_pydantic)
 # Protobuf Version: 3.20.3
 # Pydantic Version: 1.10.7
 import typing
+from datetime import datetime
+from enum import IntEnum
 
+from google.protobuf.field_mask_pb2 import FieldMask  # type: ignore
+from google.protobuf.wrappers_pb2 import DoubleValue  # type: ignore
 from protobuf_to_pydantic.customer_validator.v1 import check_one_of
 from pydantic import BaseModel, Field, root_validator
 
 
+class AfterReferMessage(BaseModel):
+    uid: str = Field(default="")
+    age: int = Field(default=0)
+
+
+class AnOtherMessage(BaseModel):
+    class SubMessage(BaseModel):
+        text: str = Field(default="")
+
+    field1: str = Field(default="")
+    field2: SubMessage = Field()
+
+
+class EmptyMessage(BaseModel):
+    pass
+
+
+class InvoiceItem2(BaseModel):
+    name: str = Field(default="")
+    amount: int = Field(default=0)
+    quantity: int = Field(default=0)
+    items: typing.List["InvoiceItem2"] = Field(default_factory=list)
+    invoice: "Invoice3" = Field()
+
+
+class Invoice3(BaseModel):
+    name: str = Field(default="")
+    amount: int = Field(default=0)
+    quantity: int = Field(default=0)
+    items: typing.List[InvoiceItem2] = Field(default_factory=list)
+
+
 class InvoiceItem(BaseModel):
     name: str = Field(default="")
     amount: int = Field(default=0)
@@ -15,6 +51,71 @@ class InvoiceItem(BaseModel):
     items: typing.List["InvoiceItem"] = Field(default_factory=list)
 
 
+class SexType(IntEnum):
+    man = 0
+    women = 1
+
+
+class ExampleExampleProtoCommonSingleDemoEnum(IntEnum):
+    """Note: The current class does not belong to the package
+    ExampleExampleProtoCommonSingleDemoEnum protobuf path:example/example_proto/common/single.proto"""
+
+    zero = 0
+    one = 1
+    two = 3
+
+
+class ExampleExampleProtoCommonSingleDemoMessage(BaseModel):
+    """Note: The current class does not belong to the package
+    ExampleExampleProtoCommonSingleDemoMessage protobuf path:example/example_proto/common/single.proto"""
+
+    earth: str = Field(default="")
+    mercury: str = Field(default="")
+    mars: str = Field(default="")
+
+
+class UserMessage(BaseModel):
+    uid: str = Field(default="")
+    age: int = Field(default=0)
+    height: float = Field(default=0.0)
+    sex: SexType = Field(default=0)
+    demo: ExampleExampleProtoCommonSingleDemoEnum = Field(default=0)
+    is_adult: bool = Field(default=False)
+    user_name: str = Field(default="")
+    demo_message: ExampleExampleProtoCommonSingleDemoMessage = Field()
+
+
+class MapMessage(BaseModel):
+    user_map: typing.Dict[str, UserMessage] = Field(default_factory=dict)
+    user_flag: typing.Dict[str, bool] = Field(default_factory=dict)
+
+
+class RepeatedMessage(BaseModel):
+    str_list: typing.List[str] = Field(default_factory=list)
+    int_list: typing.List[int] = Field(default_factory=list)
+    user_list: typing.List[UserMessage] = Field(default_factory=list)
+
+
+class NestedMessage(BaseModel):
+    class UserPayMessage(BaseModel):
+        bank_number: str = Field(default="")
+        exp: datetime = Field(default_factory=datetime.now)
+        uuid: str = Field(default="")
+
+    class IncludeEnum(IntEnum):
+        zero = 0
+        one = 1
+        two = 2
+
+    user_list_map: typing.Dict[str, RepeatedMessage] = Field(default_factory=dict)
+    user_map: typing.Dict[str, MapMessage] = Field(default_factory=dict)
+    user_pay: UserPayMessage = Field()
+    include_enum: IncludeEnum = Field(default=0)
+    not_enable_user_pay: UserPayMessage = Field()
+    empty: typing.Any = Field()
+    after_refer: AfterReferMessage = Field()
+
+
 class OptionalMessage(BaseModel):
     _one_of_dict = {"user.OptionalMessage.a": {"fields": {"x", "y"}, "required": False}}
 
@@ -28,3 +129,33 @@ class OptionalMessage(BaseModel):
     default_template_test: float = Field(default=0.0)
 
     one_of_validator = root_validator(pre=True, allow_reuse=True)(check_one_of)
+
+
+class OtherMessage(BaseModel):
+    class Config:
+        arbitrary_types_allowed = True
+
+    metadata: typing.Dict[str, typing.Any] = Field(default_factory=dict)
+    double_value: DoubleValue = Field(default_factory=DoubleValue)
+    field_mask: typing.Optional[FieldMask] = Field(default_factory=FieldMask)
+
+
+class RootMessage(BaseModel):
+    field1: str = Field(default="")
+    field2: AnOtherMessage = Field()
+
+
+class TestSameName0(BaseModel):
+    class Body(BaseModel):
+        input_model: str = Field(default="")
+        input_info: typing.Dict[str, str] = Field(default_factory=dict)
+
+    body: Body = Field()
+
+
+class TestSameName1(BaseModel):
+    class Body(BaseModel):
+        output_model: str = Field(default="")
+        output_info: typing.Dict[str, str] = Field(default_factory=dict)
+
+    body: Body = Field()
diff --git a/example/proto_3_20_pydanticv1/demo_gen_code_by_p2p.py b/example/proto_3_20_pydanticv1/demo_gen_code_by_p2p.py
index 904db19..f71cf52 100644
--- a/example/proto_3_20_pydanticv1/demo_gen_code_by_p2p.py
+++ b/example/proto_3_20_pydanticv1/demo_gen_code_by_p2p.py
@@ -1,5 +1,5 @@
 # This is an automatically generated file, please do not change
-# gen by protobuf_to_pydantic[v0.3.0](https://github.com/so1n/protobuf_to_pydantic)
+# gen by protobuf_to_pydantic[0.0.0](https://github.com/so1n/protobuf_to_pydantic)
 # Protobuf Version: 3.20.3
 # Pydantic Version: 1.10.7
 import typing
diff --git a/example/proto_3_20_pydanticv1/demo_gen_code_by_pgv.py b/example/proto_3_20_pydanticv1/demo_gen_code_by_pgv.py
index 1a327b0..9a7fb76 100644
--- a/example/proto_3_20_pydanticv1/demo_gen_code_by_pgv.py
+++ b/example/proto_3_20_pydanticv1/demo_gen_code_by_pgv.py
@@ -1,5 +1,5 @@
 # This is an automatically generated file, please do not change
-# gen by protobuf_to_pydantic[v0.3.0](https://github.com/so1n/protobuf_to_pydantic)
+# gen by protobuf_to_pydantic[0.0.0](https://github.com/so1n/protobuf_to_pydantic)
 # Protobuf Version: 3.20.3
 # Pydantic Version: 1.10.7
 import typing
diff --git a/example/proto_3_20_pydanticv1/demo_gen_code_by_text_comment_protobuf_field.py b/example/proto_3_20_pydanticv1/demo_gen_code_by_text_comment_protobuf_field.py
index ba35f55..c4da662 100644
--- a/example/proto_3_20_pydanticv1/demo_gen_code_by_text_comment_protobuf_field.py
+++ b/example/proto_3_20_pydanticv1/demo_gen_code_by_text_comment_protobuf_field.py
@@ -1,5 +1,5 @@
 # This is an automatically generated file, please do not change
-# gen by protobuf_to_pydantic[v0.3.0](https://github.com/so1n/protobuf_to_pydantic)
+# gen by protobuf_to_pydantic[0.0.0](https://github.com/so1n/protobuf_to_pydantic)
 # Protobuf Version: 3.20.3
 # Pydantic Version: 1.10.7
 import typing
@@ -145,3 +145,19 @@ class Config:
 class RootMessage(BaseModel):
     field1: str = Field(default="")
     field2: AnOtherMessage = Field()
+
+
+class TestSameName0(BaseModel):
+    class Body(BaseModel):
+        input_model: str = Field(default="")
+        input_info: typing.Dict[str, str] = Field(default_factory=dict)
+
+    body: Body = Field()
+
+
+class TestSameName1(BaseModel):
+    class Body(BaseModel):
+        output_model: str = Field(default="")
+        output_info: typing.Dict[str, str] = Field(default_factory=dict)
+
+    body: Body = Field()
diff --git a/example/proto_3_20_pydanticv1/demo_gen_code_by_text_comment_pyi.py b/example/proto_3_20_pydanticv1/demo_gen_code_by_text_comment_pyi.py
index ba35f55..c4da662 100644
--- a/example/proto_3_20_pydanticv1/demo_gen_code_by_text_comment_pyi.py
+++ b/example/proto_3_20_pydanticv1/demo_gen_code_by_text_comment_pyi.py
@@ -1,5 +1,5 @@
 # This is an automatically generated file, please do not change
-# gen by protobuf_to_pydantic[v0.3.0](https://github.com/so1n/protobuf_to_pydantic)
+# gen by protobuf_to_pydantic[0.0.0](https://github.com/so1n/protobuf_to_pydantic)
 # Protobuf Version: 3.20.3
 # Pydantic Version: 1.10.7
 import typing
@@ -145,3 +145,19 @@ class Config:
 class RootMessage(BaseModel):
     field1: str = Field(default="")
     field2: AnOtherMessage = Field()
+
+
+class TestSameName0(BaseModel):
+    class Body(BaseModel):
+        input_model: str = Field(default="")
+        input_info: typing.Dict[str, str] = Field(default_factory=dict)
+
+    body: Body = Field()
+
+
+class TestSameName1(BaseModel):
+    class Body(BaseModel):
+        output_model: str = Field(default="")
+        output_info: typing.Dict[str, str] = Field(default_factory=dict)
+
+    body: Body = Field()
diff --git a/example/proto_3_20_pydanticv1/example/example_proto/common/single_p2p.py b/example/proto_3_20_pydanticv1/example/example_proto/common/single_p2p.py
index 863df17..e56e3d2 100644
--- a/example/proto_3_20_pydanticv1/example/example_proto/common/single_p2p.py
+++ b/example/proto_3_20_pydanticv1/example/example_proto/common/single_p2p.py
@@ -1,5 +1,5 @@
 # This is an automatically generated file, please do not change
-# gen by protobuf_to_pydantic[v0.3.0](https://github.com/so1n/protobuf_to_pydantic)
+# gen by protobuf_to_pydantic[0.0.0](https://github.com/so1n/protobuf_to_pydantic)
 # Protobuf Version: 3.20.3
 # Pydantic Version: 1.10.7
 from enum import IntEnum
diff --git a/example/proto_3_20_pydanticv1/example/example_proto/demo/alias_demo_p2p.py b/example/proto_3_20_pydanticv1/example/example_proto/demo/alias_demo_p2p.py
index 46ff522..fd768e9 100644
--- a/example/proto_3_20_pydanticv1/example/example_proto/demo/alias_demo_p2p.py
+++ b/example/proto_3_20_pydanticv1/example/example_proto/demo/alias_demo_p2p.py
@@ -1,5 +1,5 @@
 # This is an automatically generated file, please do not change
-# gen by protobuf_to_pydantic[v0.3.0](https://github.com/so1n/protobuf_to_pydantic)
+# gen by protobuf_to_pydantic[0.0.0](https://github.com/so1n/protobuf_to_pydantic)
 # Protobuf Version: 3.20.3
 # Pydantic Version: 1.10.7
 import typing
diff --git a/example/proto_3_20_pydanticv1/example/example_proto/demo/all_feidl_set_optional_demo_p2p.py b/example/proto_3_20_pydanticv1/example/example_proto/demo/all_feidl_set_optional_demo_p2p.py
index fc2074e..7c28faf 100644
--- a/example/proto_3_20_pydanticv1/example/example_proto/demo/all_feidl_set_optional_demo_p2p.py
+++ b/example/proto_3_20_pydanticv1/example/example_proto/demo/all_feidl_set_optional_demo_p2p.py
@@ -1,5 +1,5 @@
 # This is an automatically generated file, please do not change
-# gen by protobuf_to_pydantic[v0.3.0](https://github.com/so1n/protobuf_to_pydantic)
+# gen by protobuf_to_pydantic[0.0.0](https://github.com/so1n/protobuf_to_pydantic)
 # Protobuf Version: 3.20.3
 # Pydantic Version: 1.10.7
 import typing
diff --git a/example/proto_3_20_pydanticv1/example/example_proto/demo/demo_p2p.py b/example/proto_3_20_pydanticv1/example/example_proto/demo/demo_p2p.py
index e99f31f..486a664 100644
--- a/example/proto_3_20_pydanticv1/example/example_proto/demo/demo_p2p.py
+++ b/example/proto_3_20_pydanticv1/example/example_proto/demo/demo_p2p.py
@@ -1,5 +1,5 @@
 # This is an automatically generated file, please do not change
-# gen by protobuf_to_pydantic[v0.3.0](https://github.com/so1n/protobuf_to_pydantic)
+# gen by protobuf_to_pydantic[0.0.0](https://github.com/so1n/protobuf_to_pydantic)
 # Protobuf Version: 3.20.3
 # Pydantic Version: 1.10.7
 import typing
@@ -160,3 +160,24 @@ class RootMessage(BaseModel):
 
     field1: str = Field(default="")
     field2: AnOtherMessage = Field()
+
+
+class TestSameName0(BaseModel):
+    """
+        Test inline structure of the same name
+    from: https://github.com/so1n/protobuf_to_pydantic/issues/76
+    """
+
+    class Body(BaseModel):
+        input_model: str = Field(default="")
+        input_info: typing.Dict[str, str] = Field(default_factory=dict)
+
+    body: "TestSameName0.Body" = Field()
+
+
+class TestSameName1(BaseModel):
+    class Body(BaseModel):
+        output_model: str = Field(default="")
+        output_info: typing.Dict[str, str] = Field(default_factory=dict)
+
+    body: "TestSameName1.Body" = Field()
diff --git a/example/proto_3_20_pydanticv1/example/example_proto/demo/demo_pb2.py b/example/proto_3_20_pydanticv1/example/example_proto/demo/demo_pb2.py
index 9a0b2e3..929a113 100644
--- a/example/proto_3_20_pydanticv1/example/example_proto/demo/demo_pb2.py
+++ b/example/proto_3_20_pydanticv1/example/example_proto/demo/demo_pb2.py
@@ -26,7 +26,7 @@
   syntax='proto3',
   serialized_options=None,
   create_key=_descriptor._internal_create_key,
-  serialized_pb=b'\n%example/example_proto/demo/demo.proto\x12\x04user\x1a\x1bgoogle/protobuf/empty.proto\x1a\x1fgoogle/protobuf/timestamp.proto\x1a\x1cgoogle/protobuf/struct.proto\x1a google/protobuf/field_mask.proto\x1a\x1egoogle/protobuf/wrappers.proto\x1a)example/example_proto/common/single.proto\"\xc3\x01\n\x0bUserMessage\x12\x0b\n\x03uid\x18\x01 \x01(\t\x12\x0b\n\x03\x61ge\x18\x02 \x01(\x05\x12\x0e\n\x06height\x18\x03 \x01(\x02\x12\x1a\n\x03sex\x18\x04 \x01(\x0e\x32\r.user.SexType\x12\x1e\n\x04\x64\x65mo\x18\x06 \x01(\x0e\x32\x10.single.DemoEnum\x12\x10\n\x08is_adult\x18\x07 \x01(\x08\x12\x11\n\tuser_name\x18\x08 \x01(\t\x12)\n\x0c\x64\x65mo_message\x18\t \x01(\x0b\x32\x13.single.DemoMessage\"\xb1\x01\n\x0cOtherMessage\x12)\n\x08metadata\x18\x01 \x01(\x0b\x32\x17.google.protobuf.Struct\x12\x32\n\x0c\x64ouble_value\x18\x02 \x01(\x0b\x32\x1c.google.protobuf.DoubleValue\x12\x33\n\nfield_mask\x18\x64 \x01(\x0b\x32\x1a.google.protobuf.FieldMaskH\x00\x88\x01\x01\x42\r\n\x0b_field_mask\"\xe4\x01\n\nMapMessage\x12/\n\x08user_map\x18\x01 \x03(\x0b\x32\x1d.user.MapMessage.UserMapEntry\x12\x31\n\tuser_flag\x18\x02 \x03(\x0b\x32\x1e.user.MapMessage.UserFlagEntry\x1a\x41\n\x0cUserMapEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12 \n\x05value\x18\x02 \x01(\x0b\x32\x11.user.UserMessage:\x02\x38\x01\x1a/\n\rUserFlagEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\x08:\x02\x38\x01\"[\n\x0fRepeatedMessage\x12\x10\n\x08str_list\x18\x01 \x03(\t\x12\x10\n\x08int_list\x18\x02 \x03(\x05\x12$\n\tuser_list\x18\x03 \x03(\x0b\x32\x11.user.UserMessage\"\x99\x05\n\rNestedMessage\x12;\n\ruser_list_map\x18\x01 \x03(\x0b\x32$.user.NestedMessage.UserListMapEntry\x12\x32\n\x08user_map\x18\x02 \x03(\x0b\x32 .user.NestedMessage.UserMapEntry\x12\x34\n\x08user_pay\x18\x03 \x01(\x0b\x32\".user.NestedMessage.UserPayMessage\x12\x35\n\x0cinclude_enum\x18\x04 \x01(\x0e\x32\x1f.user.NestedMessage.IncludeEnum\x12?\n\x13not_enable_user_pay\x18\x05 \x01(\x0b\x32\".user.NestedMessage.UserPayMessage\x12%\n\x05\x65mpty\x18\x06 \x01(\x0b\x32\x16.google.protobuf.Empty\x12,\n\x0b\x61\x66ter_refer\x18\x07 \x01(\x0b\x32\x17.user.AfterReferMessage\x1a\\\n\x0eUserPayMessage\x12\x13\n\x0b\x62\x61nk_number\x18\x01 \x01(\t\x12\'\n\x03\x65xp\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x0c\n\x04uuid\x18\x03 \x01(\t\x1aI\n\x10UserListMapEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12$\n\x05value\x18\x02 \x01(\x0b\x32\x15.user.RepeatedMessage:\x02\x38\x01\x1a@\n\x0cUserMapEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\x1f\n\x05value\x18\x02 \x01(\x0b\x32\x10.user.MapMessage:\x02\x38\x01\")\n\x0bIncludeEnum\x12\x08\n\x04zero\x10\x00\x12\x07\n\x03one\x10\x01\x12\x07\n\x03two\x10\x02\"-\n\x11\x41\x66terReferMessage\x12\x0b\n\x03uid\x18\x01 \x01(\t\x12\x0b\n\x03\x61ge\x18\x02 \x01(\x05\"_\n\x0bInvoiceItem\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0e\n\x06\x61mount\x18\x02 \x01(\x05\x12\x10\n\x08quantity\x18\x03 \x01(\x05\x12 \n\x05items\x18\x04 \x03(\x0b\x32\x11.user.InvoiceItem\"\x0e\n\x0c\x45mptyMessage\"\xa9\x02\n\x0fOptionalMessage\x12\x0b\n\x01x\x18\x01 \x01(\tH\x00\x12\x0b\n\x01y\x18\x02 \x01(\x05H\x00\x12\x11\n\x04name\x18\x03 \x01(\tH\x01\x88\x01\x01\x12\x10\n\x03\x61ge\x18\x04 \x01(\x05H\x02\x88\x01\x01\x12$\n\x04item\x18\x05 \x01(\x0b\x32\x11.user.InvoiceItemH\x03\x88\x01\x01\x12\x10\n\x08str_list\x18\x06 \x03(\t\x12\x32\n\x07int_map\x18\x07 \x03(\x0b\x32!.user.OptionalMessage.IntMapEntry\x12\x1d\n\x15\x64\x65\x66\x61ult_template_test\x18\x08 \x01(\x02\x1a-\n\x0bIntMapEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\x05:\x02\x38\x01\x42\x03\n\x01\x61\x42\x07\n\x05_nameB\x06\n\x04_ageB\x07\n\x05_item\"\x82\x01\n\x0cInvoiceItem2\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0e\n\x06\x61mount\x18\x02 \x01(\x05\x12\x10\n\x08quantity\x18\x03 \x01(\x05\x12!\n\x05items\x18\x04 \x03(\x0b\x32\x12.user.InvoiceItem2\x12\x1f\n\x07invoice\x18\x05 \x01(\x0b\x32\x0e.user.Invoice3\"]\n\x08Invoice3\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0e\n\x06\x61mount\x18\x02 \x01(\x05\x12\x10\n\x08quantity\x18\x03 \x01(\x05\x12!\n\x05items\x18\x04 \x03(\x0b\x32\x12.user.InvoiceItem2\"C\n\x0bRootMessage\x12\x0e\n\x06\x66ield1\x18\x01 \x01(\t\x12$\n\x06\x66ield2\x18\x02 \x01(\x0b\x32\x14.user.AnOtherMessage\"m\n\x0e\x41nOtherMessage\x12\x0e\n\x06\x66ield1\x18\x01 \x01(\t\x12/\n\x06\x66ield2\x18\x02 \x01(\x0b\x32\x1f.user.AnOtherMessage.SubMessage\x1a\x1a\n\nSubMessage\x12\x0c\n\x04text\x18\x01 \x01(\t*\x1d\n\x07SexType\x12\x07\n\x03man\x10\x00\x12\t\n\x05women\x10\x01\x62\x06proto3'
+  serialized_pb=b'\n%example/example_proto/demo/demo.proto\x12\x04user\x1a\x1bgoogle/protobuf/empty.proto\x1a\x1fgoogle/protobuf/timestamp.proto\x1a\x1cgoogle/protobuf/struct.proto\x1a google/protobuf/field_mask.proto\x1a\x1egoogle/protobuf/wrappers.proto\x1a)example/example_proto/common/single.proto\"\xc3\x01\n\x0bUserMessage\x12\x0b\n\x03uid\x18\x01 \x01(\t\x12\x0b\n\x03\x61ge\x18\x02 \x01(\x05\x12\x0e\n\x06height\x18\x03 \x01(\x02\x12\x1a\n\x03sex\x18\x04 \x01(\x0e\x32\r.user.SexType\x12\x1e\n\x04\x64\x65mo\x18\x06 \x01(\x0e\x32\x10.single.DemoEnum\x12\x10\n\x08is_adult\x18\x07 \x01(\x08\x12\x11\n\tuser_name\x18\x08 \x01(\t\x12)\n\x0c\x64\x65mo_message\x18\t \x01(\x0b\x32\x13.single.DemoMessage\"\xb1\x01\n\x0cOtherMessage\x12)\n\x08metadata\x18\x01 \x01(\x0b\x32\x17.google.protobuf.Struct\x12\x32\n\x0c\x64ouble_value\x18\x02 \x01(\x0b\x32\x1c.google.protobuf.DoubleValue\x12\x33\n\nfield_mask\x18\x64 \x01(\x0b\x32\x1a.google.protobuf.FieldMaskH\x00\x88\x01\x01\x42\r\n\x0b_field_mask\"\xe4\x01\n\nMapMessage\x12/\n\x08user_map\x18\x01 \x03(\x0b\x32\x1d.user.MapMessage.UserMapEntry\x12\x31\n\tuser_flag\x18\x02 \x03(\x0b\x32\x1e.user.MapMessage.UserFlagEntry\x1a\x41\n\x0cUserMapEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12 \n\x05value\x18\x02 \x01(\x0b\x32\x11.user.UserMessage:\x02\x38\x01\x1a/\n\rUserFlagEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\x08:\x02\x38\x01\"[\n\x0fRepeatedMessage\x12\x10\n\x08str_list\x18\x01 \x03(\t\x12\x10\n\x08int_list\x18\x02 \x03(\x05\x12$\n\tuser_list\x18\x03 \x03(\x0b\x32\x11.user.UserMessage\"\x99\x05\n\rNestedMessage\x12;\n\ruser_list_map\x18\x01 \x03(\x0b\x32$.user.NestedMessage.UserListMapEntry\x12\x32\n\x08user_map\x18\x02 \x03(\x0b\x32 .user.NestedMessage.UserMapEntry\x12\x34\n\x08user_pay\x18\x03 \x01(\x0b\x32\".user.NestedMessage.UserPayMessage\x12\x35\n\x0cinclude_enum\x18\x04 \x01(\x0e\x32\x1f.user.NestedMessage.IncludeEnum\x12?\n\x13not_enable_user_pay\x18\x05 \x01(\x0b\x32\".user.NestedMessage.UserPayMessage\x12%\n\x05\x65mpty\x18\x06 \x01(\x0b\x32\x16.google.protobuf.Empty\x12,\n\x0b\x61\x66ter_refer\x18\x07 \x01(\x0b\x32\x17.user.AfterReferMessage\x1a\\\n\x0eUserPayMessage\x12\x13\n\x0b\x62\x61nk_number\x18\x01 \x01(\t\x12\'\n\x03\x65xp\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x0c\n\x04uuid\x18\x03 \x01(\t\x1aI\n\x10UserListMapEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12$\n\x05value\x18\x02 \x01(\x0b\x32\x15.user.RepeatedMessage:\x02\x38\x01\x1a@\n\x0cUserMapEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\x1f\n\x05value\x18\x02 \x01(\x0b\x32\x10.user.MapMessage:\x02\x38\x01\")\n\x0bIncludeEnum\x12\x08\n\x04zero\x10\x00\x12\x07\n\x03one\x10\x01\x12\x07\n\x03two\x10\x02\"-\n\x11\x41\x66terReferMessage\x12\x0b\n\x03uid\x18\x01 \x01(\t\x12\x0b\n\x03\x61ge\x18\x02 \x01(\x05\"_\n\x0bInvoiceItem\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0e\n\x06\x61mount\x18\x02 \x01(\x05\x12\x10\n\x08quantity\x18\x03 \x01(\x05\x12 \n\x05items\x18\x04 \x03(\x0b\x32\x11.user.InvoiceItem\"\x0e\n\x0c\x45mptyMessage\"\xa9\x02\n\x0fOptionalMessage\x12\x0b\n\x01x\x18\x01 \x01(\tH\x00\x12\x0b\n\x01y\x18\x02 \x01(\x05H\x00\x12\x11\n\x04name\x18\x03 \x01(\tH\x01\x88\x01\x01\x12\x10\n\x03\x61ge\x18\x04 \x01(\x05H\x02\x88\x01\x01\x12$\n\x04item\x18\x05 \x01(\x0b\x32\x11.user.InvoiceItemH\x03\x88\x01\x01\x12\x10\n\x08str_list\x18\x06 \x03(\t\x12\x32\n\x07int_map\x18\x07 \x03(\x0b\x32!.user.OptionalMessage.IntMapEntry\x12\x1d\n\x15\x64\x65\x66\x61ult_template_test\x18\x08 \x01(\x02\x1a-\n\x0bIntMapEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\x05:\x02\x38\x01\x42\x03\n\x01\x61\x42\x07\n\x05_nameB\x06\n\x04_ageB\x07\n\x05_item\"\x82\x01\n\x0cInvoiceItem2\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0e\n\x06\x61mount\x18\x02 \x01(\x05\x12\x10\n\x08quantity\x18\x03 \x01(\x05\x12!\n\x05items\x18\x04 \x03(\x0b\x32\x12.user.InvoiceItem2\x12\x1f\n\x07invoice\x18\x05 \x01(\x0b\x32\x0e.user.Invoice3\"]\n\x08Invoice3\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0e\n\x06\x61mount\x18\x02 \x01(\x05\x12\x10\n\x08quantity\x18\x03 \x01(\x05\x12!\n\x05items\x18\x04 \x03(\x0b\x32\x12.user.InvoiceItem2\"C\n\x0bRootMessage\x12\x0e\n\x06\x66ield1\x18\x01 \x01(\t\x12$\n\x06\x66ield2\x18\x02 \x01(\x0b\x32\x14.user.AnOtherMessage\"m\n\x0e\x41nOtherMessage\x12\x0e\n\x06\x66ield1\x18\x01 \x01(\t\x12/\n\x06\x66ield2\x18\x02 \x01(\x0b\x32\x1f.user.AnOtherMessage.SubMessage\x1a\x1a\n\nSubMessage\x12\x0c\n\x04text\x18\x01 \x01(\t\"\xc4\x01\n\rTestSameName0\x12&\n\x04\x62ody\x18\x01 \x01(\x0b\x32\x18.user.TestSameName0.Body\x1a\x8a\x01\n\x04\x42ody\x12\x13\n\x0binput_model\x18\x01 \x01(\t\x12;\n\ninput_info\x18\x03 \x03(\x0b\x32\'.user.TestSameName0.Body.InputInfoEntry\x1a\x30\n\x0eInputInfoEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01\"\xc8\x01\n\rTestSameName1\x12&\n\x04\x62ody\x18\x01 \x01(\x0b\x32\x18.user.TestSameName1.Body\x1a\x8e\x01\n\x04\x42ody\x12\x14\n\x0coutput_model\x18\x01 \x01(\t\x12=\n\x0boutput_info\x18\x03 \x03(\x0b\x32(.user.TestSameName1.Body.OutputInfoEntry\x1a\x31\n\x0fOutputInfoEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01*\x1d\n\x07SexType\x12\x07\n\x03man\x10\x00\x12\t\n\x05women\x10\x01\x62\x06proto3'
   ,
   dependencies=[google_dot_protobuf_dot_empty__pb2.DESCRIPTOR,google_dot_protobuf_dot_timestamp__pb2.DESCRIPTOR,google_dot_protobuf_dot_struct__pb2.DESCRIPTOR,google_dot_protobuf_dot_field__mask__pb2.DESCRIPTOR,google_dot_protobuf_dot_wrappers__pb2.DESCRIPTOR,example_dot_example__proto_dot_common_dot_single__pb2.DESCRIPTOR,])
 
@@ -50,8 +50,8 @@
   ],
   containing_type=None,
   serialized_options=None,
-  serialized_start=2486,
-  serialized_end=2515,
+  serialized_start=2888,
+  serialized_end=2917,
 )
 _sym_db.RegisterEnumDescriptor(_SEXTYPE)
 
@@ -1057,6 +1057,222 @@
   serialized_end=2484,
 )
 
+
+_TESTSAMENAME0_BODY_INPUTINFOENTRY = _descriptor.Descriptor(
+  name='InputInfoEntry',
+  full_name='user.TestSameName0.Body.InputInfoEntry',
+  filename=None,
+  file=DESCRIPTOR,
+  containing_type=None,
+  create_key=_descriptor._internal_create_key,
+  fields=[
+    _descriptor.FieldDescriptor(
+      name='key', full_name='user.TestSameName0.Body.InputInfoEntry.key', index=0,
+      number=1, type=9, cpp_type=9, label=1,
+      has_default_value=False, default_value=b"".decode('utf-8'),
+      message_type=None, enum_type=None, containing_type=None,
+      is_extension=False, extension_scope=None,
+      serialized_options=None, file=DESCRIPTOR,  create_key=_descriptor._internal_create_key),
+    _descriptor.FieldDescriptor(
+      name='value', full_name='user.TestSameName0.Body.InputInfoEntry.value', index=1,
+      number=2, type=9, cpp_type=9, label=1,
+      has_default_value=False, default_value=b"".decode('utf-8'),
+      message_type=None, enum_type=None, containing_type=None,
+      is_extension=False, extension_scope=None,
+      serialized_options=None, file=DESCRIPTOR,  create_key=_descriptor._internal_create_key),
+  ],
+  extensions=[
+  ],
+  nested_types=[],
+  enum_types=[
+  ],
+  serialized_options=b'8\001',
+  is_extendable=False,
+  syntax='proto3',
+  extension_ranges=[],
+  oneofs=[
+  ],
+  serialized_start=2635,
+  serialized_end=2683,
+)
+
+_TESTSAMENAME0_BODY = _descriptor.Descriptor(
+  name='Body',
+  full_name='user.TestSameName0.Body',
+  filename=None,
+  file=DESCRIPTOR,
+  containing_type=None,
+  create_key=_descriptor._internal_create_key,
+  fields=[
+    _descriptor.FieldDescriptor(
+      name='input_model', full_name='user.TestSameName0.Body.input_model', index=0,
+      number=1, type=9, cpp_type=9, label=1,
+      has_default_value=False, default_value=b"".decode('utf-8'),
+      message_type=None, enum_type=None, containing_type=None,
+      is_extension=False, extension_scope=None,
+      serialized_options=None, file=DESCRIPTOR,  create_key=_descriptor._internal_create_key),
+    _descriptor.FieldDescriptor(
+      name='input_info', full_name='user.TestSameName0.Body.input_info', index=1,
+      number=3, type=11, cpp_type=10, label=3,
+      has_default_value=False, default_value=[],
+      message_type=None, enum_type=None, containing_type=None,
+      is_extension=False, extension_scope=None,
+      serialized_options=None, file=DESCRIPTOR,  create_key=_descriptor._internal_create_key),
+  ],
+  extensions=[
+  ],
+  nested_types=[_TESTSAMENAME0_BODY_INPUTINFOENTRY, ],
+  enum_types=[
+  ],
+  serialized_options=None,
+  is_extendable=False,
+  syntax='proto3',
+  extension_ranges=[],
+  oneofs=[
+  ],
+  serialized_start=2545,
+  serialized_end=2683,
+)
+
+_TESTSAMENAME0 = _descriptor.Descriptor(
+  name='TestSameName0',
+  full_name='user.TestSameName0',
+  filename=None,
+  file=DESCRIPTOR,
+  containing_type=None,
+  create_key=_descriptor._internal_create_key,
+  fields=[
+    _descriptor.FieldDescriptor(
+      name='body', full_name='user.TestSameName0.body', index=0,
+      number=1, type=11, cpp_type=10, label=1,
+      has_default_value=False, default_value=None,
+      message_type=None, enum_type=None, containing_type=None,
+      is_extension=False, extension_scope=None,
+      serialized_options=None, file=DESCRIPTOR,  create_key=_descriptor._internal_create_key),
+  ],
+  extensions=[
+  ],
+  nested_types=[_TESTSAMENAME0_BODY, ],
+  enum_types=[
+  ],
+  serialized_options=None,
+  is_extendable=False,
+  syntax='proto3',
+  extension_ranges=[],
+  oneofs=[
+  ],
+  serialized_start=2487,
+  serialized_end=2683,
+)
+
+
+_TESTSAMENAME1_BODY_OUTPUTINFOENTRY = _descriptor.Descriptor(
+  name='OutputInfoEntry',
+  full_name='user.TestSameName1.Body.OutputInfoEntry',
+  filename=None,
+  file=DESCRIPTOR,
+  containing_type=None,
+  create_key=_descriptor._internal_create_key,
+  fields=[
+    _descriptor.FieldDescriptor(
+      name='key', full_name='user.TestSameName1.Body.OutputInfoEntry.key', index=0,
+      number=1, type=9, cpp_type=9, label=1,
+      has_default_value=False, default_value=b"".decode('utf-8'),
+      message_type=None, enum_type=None, containing_type=None,
+      is_extension=False, extension_scope=None,
+      serialized_options=None, file=DESCRIPTOR,  create_key=_descriptor._internal_create_key),
+    _descriptor.FieldDescriptor(
+      name='value', full_name='user.TestSameName1.Body.OutputInfoEntry.value', index=1,
+      number=2, type=9, cpp_type=9, label=1,
+      has_default_value=False, default_value=b"".decode('utf-8'),
+      message_type=None, enum_type=None, containing_type=None,
+      is_extension=False, extension_scope=None,
+      serialized_options=None, file=DESCRIPTOR,  create_key=_descriptor._internal_create_key),
+  ],
+  extensions=[
+  ],
+  nested_types=[],
+  enum_types=[
+  ],
+  serialized_options=b'8\001',
+  is_extendable=False,
+  syntax='proto3',
+  extension_ranges=[],
+  oneofs=[
+  ],
+  serialized_start=2837,
+  serialized_end=2886,
+)
+
+_TESTSAMENAME1_BODY = _descriptor.Descriptor(
+  name='Body',
+  full_name='user.TestSameName1.Body',
+  filename=None,
+  file=DESCRIPTOR,
+  containing_type=None,
+  create_key=_descriptor._internal_create_key,
+  fields=[
+    _descriptor.FieldDescriptor(
+      name='output_model', full_name='user.TestSameName1.Body.output_model', index=0,
+      number=1, type=9, cpp_type=9, label=1,
+      has_default_value=False, default_value=b"".decode('utf-8'),
+      message_type=None, enum_type=None, containing_type=None,
+      is_extension=False, extension_scope=None,
+      serialized_options=None, file=DESCRIPTOR,  create_key=_descriptor._internal_create_key),
+    _descriptor.FieldDescriptor(
+      name='output_info', full_name='user.TestSameName1.Body.output_info', index=1,
+      number=3, type=11, cpp_type=10, label=3,
+      has_default_value=False, default_value=[],
+      message_type=None, enum_type=None, containing_type=None,
+      is_extension=False, extension_scope=None,
+      serialized_options=None, file=DESCRIPTOR,  create_key=_descriptor._internal_create_key),
+  ],
+  extensions=[
+  ],
+  nested_types=[_TESTSAMENAME1_BODY_OUTPUTINFOENTRY, ],
+  enum_types=[
+  ],
+  serialized_options=None,
+  is_extendable=False,
+  syntax='proto3',
+  extension_ranges=[],
+  oneofs=[
+  ],
+  serialized_start=2744,
+  serialized_end=2886,
+)
+
+_TESTSAMENAME1 = _descriptor.Descriptor(
+  name='TestSameName1',
+  full_name='user.TestSameName1',
+  filename=None,
+  file=DESCRIPTOR,
+  containing_type=None,
+  create_key=_descriptor._internal_create_key,
+  fields=[
+    _descriptor.FieldDescriptor(
+      name='body', full_name='user.TestSameName1.body', index=0,
+      number=1, type=11, cpp_type=10, label=1,
+      has_default_value=False, default_value=None,
+      message_type=None, enum_type=None, containing_type=None,
+      is_extension=False, extension_scope=None,
+      serialized_options=None, file=DESCRIPTOR,  create_key=_descriptor._internal_create_key),
+  ],
+  extensions=[
+  ],
+  nested_types=[_TESTSAMENAME1_BODY, ],
+  enum_types=[
+  ],
+  serialized_options=None,
+  is_extendable=False,
+  syntax='proto3',
+  extension_ranges=[],
+  oneofs=[
+  ],
+  serialized_start=2686,
+  serialized_end=2886,
+)
+
 _USERMESSAGE.fields_by_name['sex'].enum_type = _SEXTYPE
 _USERMESSAGE.fields_by_name['demo'].enum_type = example_dot_example__proto_dot_common_dot_single__pb2._DEMOENUM
 _USERMESSAGE.fields_by_name['demo_message'].message_type = example_dot_example__proto_dot_common_dot_single__pb2._DEMOMESSAGE
@@ -1111,6 +1327,14 @@
 _ROOTMESSAGE.fields_by_name['field2'].message_type = _ANOTHERMESSAGE
 _ANOTHERMESSAGE_SUBMESSAGE.containing_type = _ANOTHERMESSAGE
 _ANOTHERMESSAGE.fields_by_name['field2'].message_type = _ANOTHERMESSAGE_SUBMESSAGE
+_TESTSAMENAME0_BODY_INPUTINFOENTRY.containing_type = _TESTSAMENAME0_BODY
+_TESTSAMENAME0_BODY.fields_by_name['input_info'].message_type = _TESTSAMENAME0_BODY_INPUTINFOENTRY
+_TESTSAMENAME0_BODY.containing_type = _TESTSAMENAME0
+_TESTSAMENAME0.fields_by_name['body'].message_type = _TESTSAMENAME0_BODY
+_TESTSAMENAME1_BODY_OUTPUTINFOENTRY.containing_type = _TESTSAMENAME1_BODY
+_TESTSAMENAME1_BODY.fields_by_name['output_info'].message_type = _TESTSAMENAME1_BODY_OUTPUTINFOENTRY
+_TESTSAMENAME1_BODY.containing_type = _TESTSAMENAME1
+_TESTSAMENAME1.fields_by_name['body'].message_type = _TESTSAMENAME1_BODY
 DESCRIPTOR.message_types_by_name['UserMessage'] = _USERMESSAGE
 DESCRIPTOR.message_types_by_name['OtherMessage'] = _OTHERMESSAGE
 DESCRIPTOR.message_types_by_name['MapMessage'] = _MAPMESSAGE
@@ -1124,6 +1348,8 @@
 DESCRIPTOR.message_types_by_name['Invoice3'] = _INVOICE3
 DESCRIPTOR.message_types_by_name['RootMessage'] = _ROOTMESSAGE
 DESCRIPTOR.message_types_by_name['AnOtherMessage'] = _ANOTHERMESSAGE
+DESCRIPTOR.message_types_by_name['TestSameName0'] = _TESTSAMENAME0
+DESCRIPTOR.message_types_by_name['TestSameName1'] = _TESTSAMENAME1
 DESCRIPTOR.enum_types_by_name['SexType'] = _SEXTYPE
 _sym_db.RegisterFileDescriptor(DESCRIPTOR)
 
@@ -1274,10 +1500,58 @@
 _sym_db.RegisterMessage(AnOtherMessage)
 _sym_db.RegisterMessage(AnOtherMessage.SubMessage)
 
+TestSameName0 = _reflection.GeneratedProtocolMessageType('TestSameName0', (_message.Message,), {
+
+  'Body' : _reflection.GeneratedProtocolMessageType('Body', (_message.Message,), {
+
+    'InputInfoEntry' : _reflection.GeneratedProtocolMessageType('InputInfoEntry', (_message.Message,), {
+      'DESCRIPTOR' : _TESTSAMENAME0_BODY_INPUTINFOENTRY,
+      '__module__' : 'example.example_proto.demo.demo_pb2'
+      # @@protoc_insertion_point(class_scope:user.TestSameName0.Body.InputInfoEntry)
+      })
+    ,
+    'DESCRIPTOR' : _TESTSAMENAME0_BODY,
+    '__module__' : 'example.example_proto.demo.demo_pb2'
+    # @@protoc_insertion_point(class_scope:user.TestSameName0.Body)
+    })
+  ,
+  'DESCRIPTOR' : _TESTSAMENAME0,
+  '__module__' : 'example.example_proto.demo.demo_pb2'
+  # @@protoc_insertion_point(class_scope:user.TestSameName0)
+  })
+_sym_db.RegisterMessage(TestSameName0)
+_sym_db.RegisterMessage(TestSameName0.Body)
+_sym_db.RegisterMessage(TestSameName0.Body.InputInfoEntry)
+
+TestSameName1 = _reflection.GeneratedProtocolMessageType('TestSameName1', (_message.Message,), {
+
+  'Body' : _reflection.GeneratedProtocolMessageType('Body', (_message.Message,), {
+
+    'OutputInfoEntry' : _reflection.GeneratedProtocolMessageType('OutputInfoEntry', (_message.Message,), {
+      'DESCRIPTOR' : _TESTSAMENAME1_BODY_OUTPUTINFOENTRY,
+      '__module__' : 'example.example_proto.demo.demo_pb2'
+      # @@protoc_insertion_point(class_scope:user.TestSameName1.Body.OutputInfoEntry)
+      })
+    ,
+    'DESCRIPTOR' : _TESTSAMENAME1_BODY,
+    '__module__' : 'example.example_proto.demo.demo_pb2'
+    # @@protoc_insertion_point(class_scope:user.TestSameName1.Body)
+    })
+  ,
+  'DESCRIPTOR' : _TESTSAMENAME1,
+  '__module__' : 'example.example_proto.demo.demo_pb2'
+  # @@protoc_insertion_point(class_scope:user.TestSameName1)
+  })
+_sym_db.RegisterMessage(TestSameName1)
+_sym_db.RegisterMessage(TestSameName1.Body)
+_sym_db.RegisterMessage(TestSameName1.Body.OutputInfoEntry)
+
 
 _MAPMESSAGE_USERMAPENTRY._options = None
 _MAPMESSAGE_USERFLAGENTRY._options = None
 _NESTEDMESSAGE_USERLISTMAPENTRY._options = None
 _NESTEDMESSAGE_USERMAPENTRY._options = None
 _OPTIONALMESSAGE_INTMAPENTRY._options = None
+_TESTSAMENAME0_BODY_INPUTINFOENTRY._options = None
+_TESTSAMENAME1_BODY_OUTPUTINFOENTRY._options = None
 # @@protoc_insertion_point(module_scope)
diff --git a/example/proto_3_20_pydanticv1/example/example_proto/demo/demo_pb2.pyi b/example/proto_3_20_pydanticv1/example/example_proto/demo/demo_pb2.pyi
index c5132f7..58bca7c 100644
--- a/example/proto_3_20_pydanticv1/example/example_proto/demo/demo_pb2.pyi
+++ b/example/proto_3_20_pydanticv1/example/example_proto/demo/demo_pb2.pyi
@@ -483,3 +483,86 @@ class AnOtherMessage(google.protobuf.message.Message):
     def HasField(self, field_name: typing_extensions.Literal["field2",b"field2"]) -> builtins.bool: ...
     def ClearField(self, field_name: typing_extensions.Literal["field1",b"field1","field2",b"field2"]) -> None: ...
 global___AnOtherMessage = AnOtherMessage
+
+class TestSameName0(google.protobuf.message.Message):
+    """Test inline structure of the same name
+    from: https://github.com/so1n/protobuf_to_pydantic/issues/76
+    """
+    DESCRIPTOR: google.protobuf.descriptor.Descriptor
+    class Body(google.protobuf.message.Message):
+        DESCRIPTOR: google.protobuf.descriptor.Descriptor
+        class InputInfoEntry(google.protobuf.message.Message):
+            DESCRIPTOR: google.protobuf.descriptor.Descriptor
+            KEY_FIELD_NUMBER: builtins.int
+            VALUE_FIELD_NUMBER: builtins.int
+            key: typing.Text
+            value: typing.Text
+            def __init__(self,
+                *,
+                key: typing.Text = ...,
+                value: typing.Text = ...,
+                ) -> None: ...
+            def ClearField(self, field_name: typing_extensions.Literal["key",b"key","value",b"value"]) -> None: ...
+
+        INPUT_MODEL_FIELD_NUMBER: builtins.int
+        INPUT_INFO_FIELD_NUMBER: builtins.int
+        input_model: typing.Text
+        @property
+        def input_info(self) -> google.protobuf.internal.containers.ScalarMap[typing.Text, typing.Text]: ...
+        def __init__(self,
+            *,
+            input_model: typing.Text = ...,
+            input_info: typing.Optional[typing.Mapping[typing.Text, typing.Text]] = ...,
+            ) -> None: ...
+        def ClearField(self, field_name: typing_extensions.Literal["input_info",b"input_info","input_model",b"input_model"]) -> None: ...
+
+    BODY_FIELD_NUMBER: builtins.int
+    @property
+    def body(self) -> global___TestSameName0.Body: ...
+    def __init__(self,
+        *,
+        body: typing.Optional[global___TestSameName0.Body] = ...,
+        ) -> None: ...
+    def HasField(self, field_name: typing_extensions.Literal["body",b"body"]) -> builtins.bool: ...
+    def ClearField(self, field_name: typing_extensions.Literal["body",b"body"]) -> None: ...
+global___TestSameName0 = TestSameName0
+
+class TestSameName1(google.protobuf.message.Message):
+    DESCRIPTOR: google.protobuf.descriptor.Descriptor
+    class Body(google.protobuf.message.Message):
+        DESCRIPTOR: google.protobuf.descriptor.Descriptor
+        class OutputInfoEntry(google.protobuf.message.Message):
+            DESCRIPTOR: google.protobuf.descriptor.Descriptor
+            KEY_FIELD_NUMBER: builtins.int
+            VALUE_FIELD_NUMBER: builtins.int
+            key: typing.Text
+            value: typing.Text
+            def __init__(self,
+                *,
+                key: typing.Text = ...,
+                value: typing.Text = ...,
+                ) -> None: ...
+            def ClearField(self, field_name: typing_extensions.Literal["key",b"key","value",b"value"]) -> None: ...
+
+        OUTPUT_MODEL_FIELD_NUMBER: builtins.int
+        OUTPUT_INFO_FIELD_NUMBER: builtins.int
+        output_model: typing.Text
+        @property
+        def output_info(self) -> google.protobuf.internal.containers.ScalarMap[typing.Text, typing.Text]: ...
+        def __init__(self,
+            *,
+            output_model: typing.Text = ...,
+            output_info: typing.Optional[typing.Mapping[typing.Text, typing.Text]] = ...,
+            ) -> None: ...
+        def ClearField(self, field_name: typing_extensions.Literal["output_info",b"output_info","output_model",b"output_model"]) -> None: ...
+
+    BODY_FIELD_NUMBER: builtins.int
+    @property
+    def body(self) -> global___TestSameName1.Body: ...
+    def __init__(self,
+        *,
+        body: typing.Optional[global___TestSameName1.Body] = ...,
+        ) -> None: ...
+    def HasField(self, field_name: typing_extensions.Literal["body",b"body"]) -> builtins.bool: ...
+    def ClearField(self, field_name: typing_extensions.Literal["body",b"body"]) -> None: ...
+global___TestSameName1 = TestSameName1
diff --git a/example/proto_3_20_pydanticv1/example/example_proto/demo/single_config_p2p.py b/example/proto_3_20_pydanticv1/example/example_proto/demo/single_config_p2p.py
index c3957a3..6cdbef2 100644
--- a/example/proto_3_20_pydanticv1/example/example_proto/demo/single_config_p2p.py
+++ b/example/proto_3_20_pydanticv1/example/example_proto/demo/single_config_p2p.py
@@ -1,5 +1,5 @@
 # This is an automatically generated file, please do not change
-# gen by protobuf_to_pydantic[v0.3.0](https://github.com/so1n/protobuf_to_pydantic)
+# gen by protobuf_to_pydantic[0.0.0](https://github.com/so1n/protobuf_to_pydantic)
 # Protobuf Version: 3.20.3
 # Pydantic Version: 1.10.7
 from google.protobuf.message import Message  # type: ignore
diff --git a/example/proto_3_20_pydanticv1/example/example_proto/p2p_validate/demo_p2p.py b/example/proto_3_20_pydanticv1/example/example_proto/p2p_validate/demo_p2p.py
index fd1af4a..9f454bd 100644
--- a/example/proto_3_20_pydanticv1/example/example_proto/p2p_validate/demo_p2p.py
+++ b/example/proto_3_20_pydanticv1/example/example_proto/p2p_validate/demo_p2p.py
@@ -1,5 +1,5 @@
 # This is an automatically generated file, please do not change
-# gen by protobuf_to_pydantic[v0.3.0](https://github.com/so1n/protobuf_to_pydantic)
+# gen by protobuf_to_pydantic[0.0.0](https://github.com/so1n/protobuf_to_pydantic)
 # Protobuf Version: 3.20.3
 # Pydantic Version: 1.10.7
 import typing
diff --git a/example/proto_3_20_pydanticv1/example/example_proto/p2p_validate_by_comment/demo_p2p.py b/example/proto_3_20_pydanticv1/example/example_proto/p2p_validate_by_comment/demo_p2p.py
index fa5768f..4815183 100644
--- a/example/proto_3_20_pydanticv1/example/example_proto/p2p_validate_by_comment/demo_p2p.py
+++ b/example/proto_3_20_pydanticv1/example/example_proto/p2p_validate_by_comment/demo_p2p.py
@@ -1,5 +1,5 @@
 # This is an automatically generated file, please do not change
-# gen by protobuf_to_pydantic[v0.3.0](https://github.com/so1n/protobuf_to_pydantic)
+# gen by protobuf_to_pydantic[0.0.0](https://github.com/so1n/protobuf_to_pydantic)
 # Protobuf Version: 3.20.3
 # Pydantic Version: 1.10.7
 import typing
diff --git a/example/proto_3_20_pydanticv1/example/example_proto/p2p_validate_by_comment/demo_pb2_by_protobuf.py b/example/proto_3_20_pydanticv1/example/example_proto/p2p_validate_by_comment/demo_pb2_by_protobuf.py
index d429920..a9079d2 100644
--- a/example/proto_3_20_pydanticv1/example/example_proto/p2p_validate_by_comment/demo_pb2_by_protobuf.py
+++ b/example/proto_3_20_pydanticv1/example/example_proto/p2p_validate_by_comment/demo_pb2_by_protobuf.py
@@ -1,5 +1,5 @@
 # This is an automatically generated file, please do not change
-# gen by protobuf_to_pydantic[v0.3.0](https://github.com/so1n/protobuf_to_pydantic)
+# gen by protobuf_to_pydantic[0.0.0](https://github.com/so1n/protobuf_to_pydantic)
 # Protobuf Version: 3.20.3
 # Pydantic Version: 1.10.7
 import typing
diff --git a/example/proto_3_20_pydanticv1/example/example_proto/p2p_validate_by_comment/demo_pb2_by_pyi.py b/example/proto_3_20_pydanticv1/example/example_proto/p2p_validate_by_comment/demo_pb2_by_pyi.py
index d429920..a9079d2 100644
--- a/example/proto_3_20_pydanticv1/example/example_proto/p2p_validate_by_comment/demo_pb2_by_pyi.py
+++ b/example/proto_3_20_pydanticv1/example/example_proto/p2p_validate_by_comment/demo_pb2_by_pyi.py
@@ -1,5 +1,5 @@
 # This is an automatically generated file, please do not change
-# gen by protobuf_to_pydantic[v0.3.0](https://github.com/so1n/protobuf_to_pydantic)
+# gen by protobuf_to_pydantic[0.0.0](https://github.com/so1n/protobuf_to_pydantic)
 # Protobuf Version: 3.20.3
 # Pydantic Version: 1.10.7
 import typing
diff --git a/example/proto_3_20_pydanticv1/example/example_proto/validate/demo_p2p.py b/example/proto_3_20_pydanticv1/example/example_proto/validate/demo_p2p.py
index 7c4d764..710b425 100644
--- a/example/proto_3_20_pydanticv1/example/example_proto/validate/demo_p2p.py
+++ b/example/proto_3_20_pydanticv1/example/example_proto/validate/demo_p2p.py
@@ -1,5 +1,5 @@
 # This is an automatically generated file, please do not change
-# gen by protobuf_to_pydantic[v0.3.0](https://github.com/so1n/protobuf_to_pydantic)
+# gen by protobuf_to_pydantic[0.0.0](https://github.com/so1n/protobuf_to_pydantic)
 # Protobuf Version: 3.20.3
 # Pydantic Version: 1.10.7
 import typing
diff --git a/example/proto_3_20_pydanticv2/demo_gen_code.py b/example/proto_3_20_pydanticv2/demo_gen_code.py
index d883fef..97539e5 100644
--- a/example/proto_3_20_pydanticv2/demo_gen_code.py
+++ b/example/proto_3_20_pydanticv2/demo_gen_code.py
@@ -1,11 +1,47 @@
 # This is an automatically generated file, please do not change
-# gen by protobuf_to_pydantic[v0.3.0](https://github.com/so1n/protobuf_to_pydantic)
+# gen by protobuf_to_pydantic[0.0.0](https://github.com/so1n/protobuf_to_pydantic)
 # Protobuf Version: 3.20.3
 # Pydantic Version: 2.5.3
 import typing
+from datetime import datetime
+from enum import IntEnum
 
+from google.protobuf.field_mask_pb2 import FieldMask  # type: ignore
+from google.protobuf.wrappers_pb2 import DoubleValue  # type: ignore
 from protobuf_to_pydantic.customer_validator.v2 import check_one_of
-from pydantic import BaseModel, Field, model_validator
+from pydantic import BaseModel, ConfigDict, Field, model_validator
+
+
+class AfterReferMessage(BaseModel):
+    uid: str = Field(default="")
+    age: int = Field(default=0)
+
+
+class AnOtherMessage(BaseModel):
+    class SubMessage(BaseModel):
+        text: str = Field(default="")
+
+    field1: str = Field(default="")
+    field2: SubMessage = Field()
+
+
+class EmptyMessage(BaseModel):
+    pass
+
+
+class InvoiceItem2(BaseModel):
+    name: str = Field(default="")
+    amount: int = Field(default=0)
+    quantity: int = Field(default=0)
+    items: typing.List["InvoiceItem2"] = Field(default_factory=list)
+    invoice: "Invoice3" = Field()
+
+
+class Invoice3(BaseModel):
+    name: str = Field(default="")
+    amount: int = Field(default=0)
+    quantity: int = Field(default=0)
+    items: typing.List[InvoiceItem2] = Field(default_factory=list)
 
 
 class InvoiceItem(BaseModel):
@@ -15,6 +51,71 @@ class InvoiceItem(BaseModel):
     items: typing.List["InvoiceItem"] = Field(default_factory=list)
 
 
+class SexType(IntEnum):
+    man = 0
+    women = 1
+
+
+class ExampleExampleProtoCommonSingleDemoEnum(IntEnum):
+    """Note: The current class does not belong to the package
+    ExampleExampleProtoCommonSingleDemoEnum protobuf path:example/example_proto/common/single.proto"""
+
+    zero = 0
+    one = 1
+    two = 3
+
+
+class ExampleExampleProtoCommonSingleDemoMessage(BaseModel):
+    """Note: The current class does not belong to the package
+    ExampleExampleProtoCommonSingleDemoMessage protobuf path:example/example_proto/common/single.proto"""
+
+    earth: str = Field(default="")
+    mercury: str = Field(default="")
+    mars: str = Field(default="")
+
+
+class UserMessage(BaseModel):
+    uid: str = Field(default="")
+    age: int = Field(default=0)
+    height: float = Field(default=0.0)
+    sex: SexType = Field(default=0)
+    demo: ExampleExampleProtoCommonSingleDemoEnum = Field(default=0)
+    is_adult: bool = Field(default=False)
+    user_name: str = Field(default="")
+    demo_message: ExampleExampleProtoCommonSingleDemoMessage = Field()
+
+
+class MapMessage(BaseModel):
+    user_map: typing.Dict[str, UserMessage] = Field(default_factory=dict)
+    user_flag: typing.Dict[str, bool] = Field(default_factory=dict)
+
+
+class RepeatedMessage(BaseModel):
+    str_list: typing.List[str] = Field(default_factory=list)
+    int_list: typing.List[int] = Field(default_factory=list)
+    user_list: typing.List[UserMessage] = Field(default_factory=list)
+
+
+class NestedMessage(BaseModel):
+    class UserPayMessage(BaseModel):
+        bank_number: str = Field(default="")
+        exp: datetime = Field(default_factory=datetime.now)
+        uuid: str = Field(default="")
+
+    class IncludeEnum(IntEnum):
+        zero = 0
+        one = 1
+        two = 2
+
+    user_list_map: typing.Dict[str, RepeatedMessage] = Field(default_factory=dict)
+    user_map: typing.Dict[str, MapMessage] = Field(default_factory=dict)
+    user_pay: UserPayMessage = Field()
+    include_enum: IncludeEnum = Field(default=0)
+    not_enable_user_pay: UserPayMessage = Field()
+    empty: typing.Any = Field()
+    after_refer: AfterReferMessage = Field()
+
+
 class OptionalMessage(BaseModel):
     _one_of_dict = {"user.OptionalMessage.a": {"fields": {"x", "y"}, "required": False}}
 
@@ -28,3 +129,32 @@ class OptionalMessage(BaseModel):
     default_template_test: float = Field(default=0.0)
 
     one_of_validator = model_validator(mode="before")(check_one_of)
+
+
+class OtherMessage(BaseModel):
+    model_config = ConfigDict(arbitrary_types_allowed=True)
+
+    metadata: typing.Dict[str, typing.Any] = Field(default_factory=dict)
+    double_value: DoubleValue = Field(default_factory=DoubleValue)
+    field_mask: typing.Optional[FieldMask] = Field(default_factory=FieldMask)
+
+
+class RootMessage(BaseModel):
+    field1: str = Field(default="")
+    field2: AnOtherMessage = Field()
+
+
+class TestSameName0(BaseModel):
+    class Body(BaseModel):
+        input_model: str = Field(default="")
+        input_info: typing.Dict[str, str] = Field(default_factory=dict)
+
+    body: Body = Field()
+
+
+class TestSameName1(BaseModel):
+    class Body(BaseModel):
+        output_model: str = Field(default="")
+        output_info: typing.Dict[str, str] = Field(default_factory=dict)
+
+    body: Body = Field()
diff --git a/example/proto_3_20_pydanticv2/demo_gen_code_by_p2p.py b/example/proto_3_20_pydanticv2/demo_gen_code_by_p2p.py
index e76e6d5..8980923 100644
--- a/example/proto_3_20_pydanticv2/demo_gen_code_by_p2p.py
+++ b/example/proto_3_20_pydanticv2/demo_gen_code_by_p2p.py
@@ -1,5 +1,5 @@
 # This is an automatically generated file, please do not change
-# gen by protobuf_to_pydantic[v0.3.0](https://github.com/so1n/protobuf_to_pydantic)
+# gen by protobuf_to_pydantic[0.0.0](https://github.com/so1n/protobuf_to_pydantic)
 # Protobuf Version: 3.20.3
 # Pydantic Version: 2.5.3
 import typing
diff --git a/example/proto_3_20_pydanticv2/demo_gen_code_by_pgv.py b/example/proto_3_20_pydanticv2/demo_gen_code_by_pgv.py
index 4d976e3..829bb01 100644
--- a/example/proto_3_20_pydanticv2/demo_gen_code_by_pgv.py
+++ b/example/proto_3_20_pydanticv2/demo_gen_code_by_pgv.py
@@ -1,5 +1,5 @@
 # This is an automatically generated file, please do not change
-# gen by protobuf_to_pydantic[v0.3.0](https://github.com/so1n/protobuf_to_pydantic)
+# gen by protobuf_to_pydantic[0.0.0](https://github.com/so1n/protobuf_to_pydantic)
 # Protobuf Version: 3.20.3
 # Pydantic Version: 2.5.3
 import typing
diff --git a/example/proto_3_20_pydanticv2/demo_gen_code_by_text_comment_protobuf_field.py b/example/proto_3_20_pydanticv2/demo_gen_code_by_text_comment_protobuf_field.py
index 220b01e..2cf99be 100644
--- a/example/proto_3_20_pydanticv2/demo_gen_code_by_text_comment_protobuf_field.py
+++ b/example/proto_3_20_pydanticv2/demo_gen_code_by_text_comment_protobuf_field.py
@@ -1,5 +1,5 @@
 # This is an automatically generated file, please do not change
-# gen by protobuf_to_pydantic[v0.3.0](https://github.com/so1n/protobuf_to_pydantic)
+# gen by protobuf_to_pydantic[0.0.0](https://github.com/so1n/protobuf_to_pydantic)
 # Protobuf Version: 3.20.3
 # Pydantic Version: 2.5.3
 import typing
@@ -144,3 +144,19 @@ class OtherMessage(BaseModel):
 class RootMessage(BaseModel):
     field1: str = Field(default="")
     field2: AnOtherMessage = Field()
+
+
+class TestSameName0(BaseModel):
+    class Body(BaseModel):
+        input_model: str = Field(default="")
+        input_info: typing.Dict[str, str] = Field(default_factory=dict)
+
+    body: Body = Field()
+
+
+class TestSameName1(BaseModel):
+    class Body(BaseModel):
+        output_model: str = Field(default="")
+        output_info: typing.Dict[str, str] = Field(default_factory=dict)
+
+    body: Body = Field()
diff --git a/example/proto_3_20_pydanticv2/demo_gen_code_by_text_comment_pyi.py b/example/proto_3_20_pydanticv2/demo_gen_code_by_text_comment_pyi.py
index 220b01e..2cf99be 100644
--- a/example/proto_3_20_pydanticv2/demo_gen_code_by_text_comment_pyi.py
+++ b/example/proto_3_20_pydanticv2/demo_gen_code_by_text_comment_pyi.py
@@ -1,5 +1,5 @@
 # This is an automatically generated file, please do not change
-# gen by protobuf_to_pydantic[v0.3.0](https://github.com/so1n/protobuf_to_pydantic)
+# gen by protobuf_to_pydantic[0.0.0](https://github.com/so1n/protobuf_to_pydantic)
 # Protobuf Version: 3.20.3
 # Pydantic Version: 2.5.3
 import typing
@@ -144,3 +144,19 @@ class OtherMessage(BaseModel):
 class RootMessage(BaseModel):
     field1: str = Field(default="")
     field2: AnOtherMessage = Field()
+
+
+class TestSameName0(BaseModel):
+    class Body(BaseModel):
+        input_model: str = Field(default="")
+        input_info: typing.Dict[str, str] = Field(default_factory=dict)
+
+    body: Body = Field()
+
+
+class TestSameName1(BaseModel):
+    class Body(BaseModel):
+        output_model: str = Field(default="")
+        output_info: typing.Dict[str, str] = Field(default_factory=dict)
+
+    body: Body = Field()
diff --git a/example/proto_3_20_pydanticv2/example/example_proto/common/single_p2p.py b/example/proto_3_20_pydanticv2/example/example_proto/common/single_p2p.py
index 9a7adac..45f56cf 100644
--- a/example/proto_3_20_pydanticv2/example/example_proto/common/single_p2p.py
+++ b/example/proto_3_20_pydanticv2/example/example_proto/common/single_p2p.py
@@ -1,5 +1,5 @@
 # This is an automatically generated file, please do not change
-# gen by protobuf_to_pydantic[v0.3.0](https://github.com/so1n/protobuf_to_pydantic)
+# gen by protobuf_to_pydantic[0.0.0](https://github.com/so1n/protobuf_to_pydantic)
 # Protobuf Version: 3.20.3
 # Pydantic Version: 2.5.3
 from enum import IntEnum
diff --git a/example/proto_3_20_pydanticv2/example/example_proto/demo/alias_demo_p2p.py b/example/proto_3_20_pydanticv2/example/example_proto/demo/alias_demo_p2p.py
index 7e77004..bd93f6f 100644
--- a/example/proto_3_20_pydanticv2/example/example_proto/demo/alias_demo_p2p.py
+++ b/example/proto_3_20_pydanticv2/example/example_proto/demo/alias_demo_p2p.py
@@ -1,5 +1,5 @@
 # This is an automatically generated file, please do not change
-# gen by protobuf_to_pydantic[v0.3.0](https://github.com/so1n/protobuf_to_pydantic)
+# gen by protobuf_to_pydantic[0.0.0](https://github.com/so1n/protobuf_to_pydantic)
 # Protobuf Version: 3.20.3
 # Pydantic Version: 2.5.3
 import typing
diff --git a/example/proto_3_20_pydanticv2/example/example_proto/demo/all_feidl_set_optional_demo_p2p.py b/example/proto_3_20_pydanticv2/example/example_proto/demo/all_feidl_set_optional_demo_p2p.py
index d08294b..a5efe1a 100644
--- a/example/proto_3_20_pydanticv2/example/example_proto/demo/all_feidl_set_optional_demo_p2p.py
+++ b/example/proto_3_20_pydanticv2/example/example_proto/demo/all_feidl_set_optional_demo_p2p.py
@@ -1,5 +1,5 @@
 # This is an automatically generated file, please do not change
-# gen by protobuf_to_pydantic[v0.3.0](https://github.com/so1n/protobuf_to_pydantic)
+# gen by protobuf_to_pydantic[0.0.0](https://github.com/so1n/protobuf_to_pydantic)
 # Protobuf Version: 3.20.3
 # Pydantic Version: 2.5.3
 import typing
diff --git a/example/proto_3_20_pydanticv2/example/example_proto/demo/demo_p2p.py b/example/proto_3_20_pydanticv2/example/example_proto/demo/demo_p2p.py
index 5e42a1a..b90d854 100644
--- a/example/proto_3_20_pydanticv2/example/example_proto/demo/demo_p2p.py
+++ b/example/proto_3_20_pydanticv2/example/example_proto/demo/demo_p2p.py
@@ -1,5 +1,5 @@
 # This is an automatically generated file, please do not change
-# gen by protobuf_to_pydantic[v0.3.0](https://github.com/so1n/protobuf_to_pydantic)
+# gen by protobuf_to_pydantic[0.0.0](https://github.com/so1n/protobuf_to_pydantic)
 # Protobuf Version: 3.20.3
 # Pydantic Version: 2.5.3
 import typing
@@ -158,3 +158,24 @@ class RootMessage(BaseModel):
 
     field1: str = Field(default="")
     field2: AnOtherMessage = Field()
+
+
+class TestSameName0(BaseModel):
+    """
+        Test inline structure of the same name
+    from: https://github.com/so1n/protobuf_to_pydantic/issues/76
+    """
+
+    class Body(BaseModel):
+        input_model: str = Field(default="")
+        input_info: typing.Dict[str, str] = Field(default_factory=dict)
+
+    body: "TestSameName0.Body" = Field()
+
+
+class TestSameName1(BaseModel):
+    class Body(BaseModel):
+        output_model: str = Field(default="")
+        output_info: typing.Dict[str, str] = Field(default_factory=dict)
+
+    body: "TestSameName1.Body" = Field()
diff --git a/example/proto_3_20_pydanticv2/example/example_proto/demo/demo_pb2.py b/example/proto_3_20_pydanticv2/example/example_proto/demo/demo_pb2.py
index 53c7240..039b2d8 100644
--- a/example/proto_3_20_pydanticv2/example/example_proto/demo/demo_pb2.py
+++ b/example/proto_3_20_pydanticv2/example/example_proto/demo/demo_pb2.py
@@ -26,7 +26,7 @@
   syntax='proto3',
   serialized_options=None,
   create_key=_descriptor._internal_create_key,
-  serialized_pb=b'\n%example/example_proto/demo/demo.proto\x12\x04user\x1a\x1bgoogle/protobuf/empty.proto\x1a\x1fgoogle/protobuf/timestamp.proto\x1a\x1cgoogle/protobuf/struct.proto\x1a google/protobuf/field_mask.proto\x1a\x1egoogle/protobuf/wrappers.proto\x1a)example/example_proto/common/single.proto\"\xc3\x01\n\x0bUserMessage\x12\x0b\n\x03uid\x18\x01 \x01(\t\x12\x0b\n\x03\x61ge\x18\x02 \x01(\x05\x12\x0e\n\x06height\x18\x03 \x01(\x02\x12\x1a\n\x03sex\x18\x04 \x01(\x0e\x32\r.user.SexType\x12\x1e\n\x04\x64\x65mo\x18\x06 \x01(\x0e\x32\x10.single.DemoEnum\x12\x10\n\x08is_adult\x18\x07 \x01(\x08\x12\x11\n\tuser_name\x18\x08 \x01(\t\x12)\n\x0c\x64\x65mo_message\x18\t \x01(\x0b\x32\x13.single.DemoMessage\"\xb1\x01\n\x0cOtherMessage\x12)\n\x08metadata\x18\x01 \x01(\x0b\x32\x17.google.protobuf.Struct\x12\x32\n\x0c\x64ouble_value\x18\x02 \x01(\x0b\x32\x1c.google.protobuf.DoubleValue\x12\x33\n\nfield_mask\x18\x64 \x01(\x0b\x32\x1a.google.protobuf.FieldMaskH\x00\x88\x01\x01\x42\r\n\x0b_field_mask\"\xe4\x01\n\nMapMessage\x12/\n\x08user_map\x18\x01 \x03(\x0b\x32\x1d.user.MapMessage.UserMapEntry\x12\x31\n\tuser_flag\x18\x02 \x03(\x0b\x32\x1e.user.MapMessage.UserFlagEntry\x1a\x41\n\x0cUserMapEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12 \n\x05value\x18\x02 \x01(\x0b\x32\x11.user.UserMessage:\x02\x38\x01\x1a/\n\rUserFlagEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\x08:\x02\x38\x01\"[\n\x0fRepeatedMessage\x12\x10\n\x08str_list\x18\x01 \x03(\t\x12\x10\n\x08int_list\x18\x02 \x03(\x05\x12$\n\tuser_list\x18\x03 \x03(\x0b\x32\x11.user.UserMessage\"\x99\x05\n\rNestedMessage\x12;\n\ruser_list_map\x18\x01 \x03(\x0b\x32$.user.NestedMessage.UserListMapEntry\x12\x32\n\x08user_map\x18\x02 \x03(\x0b\x32 .user.NestedMessage.UserMapEntry\x12\x34\n\x08user_pay\x18\x03 \x01(\x0b\x32\".user.NestedMessage.UserPayMessage\x12\x35\n\x0cinclude_enum\x18\x04 \x01(\x0e\x32\x1f.user.NestedMessage.IncludeEnum\x12?\n\x13not_enable_user_pay\x18\x05 \x01(\x0b\x32\".user.NestedMessage.UserPayMessage\x12%\n\x05\x65mpty\x18\x06 \x01(\x0b\x32\x16.google.protobuf.Empty\x12,\n\x0b\x61\x66ter_refer\x18\x07 \x01(\x0b\x32\x17.user.AfterReferMessage\x1a\\\n\x0eUserPayMessage\x12\x13\n\x0b\x62\x61nk_number\x18\x01 \x01(\t\x12\'\n\x03\x65xp\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x0c\n\x04uuid\x18\x03 \x01(\t\x1aI\n\x10UserListMapEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12$\n\x05value\x18\x02 \x01(\x0b\x32\x15.user.RepeatedMessage:\x02\x38\x01\x1a@\n\x0cUserMapEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\x1f\n\x05value\x18\x02 \x01(\x0b\x32\x10.user.MapMessage:\x02\x38\x01\")\n\x0bIncludeEnum\x12\x08\n\x04zero\x10\x00\x12\x07\n\x03one\x10\x01\x12\x07\n\x03two\x10\x02\"-\n\x11\x41\x66terReferMessage\x12\x0b\n\x03uid\x18\x01 \x01(\t\x12\x0b\n\x03\x61ge\x18\x02 \x01(\x05\"_\n\x0bInvoiceItem\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0e\n\x06\x61mount\x18\x02 \x01(\x05\x12\x10\n\x08quantity\x18\x03 \x01(\x05\x12 \n\x05items\x18\x04 \x03(\x0b\x32\x11.user.InvoiceItem\"\x0e\n\x0c\x45mptyMessage\"\xa9\x02\n\x0fOptionalMessage\x12\x0b\n\x01x\x18\x01 \x01(\tH\x00\x12\x0b\n\x01y\x18\x02 \x01(\x05H\x00\x12\x11\n\x04name\x18\x03 \x01(\tH\x01\x88\x01\x01\x12\x10\n\x03\x61ge\x18\x04 \x01(\x05H\x02\x88\x01\x01\x12$\n\x04item\x18\x05 \x01(\x0b\x32\x11.user.InvoiceItemH\x03\x88\x01\x01\x12\x10\n\x08str_list\x18\x06 \x03(\t\x12\x32\n\x07int_map\x18\x07 \x03(\x0b\x32!.user.OptionalMessage.IntMapEntry\x12\x1d\n\x15\x64\x65\x66\x61ult_template_test\x18\x08 \x01(\x02\x1a-\n\x0bIntMapEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\x05:\x02\x38\x01\x42\x03\n\x01\x61\x42\x07\n\x05_nameB\x06\n\x04_ageB\x07\n\x05_item\"\x82\x01\n\x0cInvoiceItem2\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0e\n\x06\x61mount\x18\x02 \x01(\x05\x12\x10\n\x08quantity\x18\x03 \x01(\x05\x12!\n\x05items\x18\x04 \x03(\x0b\x32\x12.user.InvoiceItem2\x12\x1f\n\x07invoice\x18\x05 \x01(\x0b\x32\x0e.user.Invoice3\"]\n\x08Invoice3\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0e\n\x06\x61mount\x18\x02 \x01(\x05\x12\x10\n\x08quantity\x18\x03 \x01(\x05\x12!\n\x05items\x18\x04 \x03(\x0b\x32\x12.user.InvoiceItem2\"C\n\x0bRootMessage\x12\x0e\n\x06\x66ield1\x18\x01 \x01(\t\x12$\n\x06\x66ield2\x18\x02 \x01(\x0b\x32\x14.user.AnOtherMessage\"m\n\x0e\x41nOtherMessage\x12\x0e\n\x06\x66ield1\x18\x01 \x01(\t\x12/\n\x06\x66ield2\x18\x02 \x01(\x0b\x32\x1f.user.AnOtherMessage.SubMessage\x1a\x1a\n\nSubMessage\x12\x0c\n\x04text\x18\x01 \x01(\t*\x1d\n\x07SexType\x12\x07\n\x03man\x10\x00\x12\t\n\x05women\x10\x01\x62\x06proto3'
+  serialized_pb=b'\n%example/example_proto/demo/demo.proto\x12\x04user\x1a\x1bgoogle/protobuf/empty.proto\x1a\x1fgoogle/protobuf/timestamp.proto\x1a\x1cgoogle/protobuf/struct.proto\x1a google/protobuf/field_mask.proto\x1a\x1egoogle/protobuf/wrappers.proto\x1a)example/example_proto/common/single.proto\"\xc3\x01\n\x0bUserMessage\x12\x0b\n\x03uid\x18\x01 \x01(\t\x12\x0b\n\x03\x61ge\x18\x02 \x01(\x05\x12\x0e\n\x06height\x18\x03 \x01(\x02\x12\x1a\n\x03sex\x18\x04 \x01(\x0e\x32\r.user.SexType\x12\x1e\n\x04\x64\x65mo\x18\x06 \x01(\x0e\x32\x10.single.DemoEnum\x12\x10\n\x08is_adult\x18\x07 \x01(\x08\x12\x11\n\tuser_name\x18\x08 \x01(\t\x12)\n\x0c\x64\x65mo_message\x18\t \x01(\x0b\x32\x13.single.DemoMessage\"\xb1\x01\n\x0cOtherMessage\x12)\n\x08metadata\x18\x01 \x01(\x0b\x32\x17.google.protobuf.Struct\x12\x32\n\x0c\x64ouble_value\x18\x02 \x01(\x0b\x32\x1c.google.protobuf.DoubleValue\x12\x33\n\nfield_mask\x18\x64 \x01(\x0b\x32\x1a.google.protobuf.FieldMaskH\x00\x88\x01\x01\x42\r\n\x0b_field_mask\"\xe4\x01\n\nMapMessage\x12/\n\x08user_map\x18\x01 \x03(\x0b\x32\x1d.user.MapMessage.UserMapEntry\x12\x31\n\tuser_flag\x18\x02 \x03(\x0b\x32\x1e.user.MapMessage.UserFlagEntry\x1a\x41\n\x0cUserMapEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12 \n\x05value\x18\x02 \x01(\x0b\x32\x11.user.UserMessage:\x02\x38\x01\x1a/\n\rUserFlagEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\x08:\x02\x38\x01\"[\n\x0fRepeatedMessage\x12\x10\n\x08str_list\x18\x01 \x03(\t\x12\x10\n\x08int_list\x18\x02 \x03(\x05\x12$\n\tuser_list\x18\x03 \x03(\x0b\x32\x11.user.UserMessage\"\x99\x05\n\rNestedMessage\x12;\n\ruser_list_map\x18\x01 \x03(\x0b\x32$.user.NestedMessage.UserListMapEntry\x12\x32\n\x08user_map\x18\x02 \x03(\x0b\x32 .user.NestedMessage.UserMapEntry\x12\x34\n\x08user_pay\x18\x03 \x01(\x0b\x32\".user.NestedMessage.UserPayMessage\x12\x35\n\x0cinclude_enum\x18\x04 \x01(\x0e\x32\x1f.user.NestedMessage.IncludeEnum\x12?\n\x13not_enable_user_pay\x18\x05 \x01(\x0b\x32\".user.NestedMessage.UserPayMessage\x12%\n\x05\x65mpty\x18\x06 \x01(\x0b\x32\x16.google.protobuf.Empty\x12,\n\x0b\x61\x66ter_refer\x18\x07 \x01(\x0b\x32\x17.user.AfterReferMessage\x1a\\\n\x0eUserPayMessage\x12\x13\n\x0b\x62\x61nk_number\x18\x01 \x01(\t\x12\'\n\x03\x65xp\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x0c\n\x04uuid\x18\x03 \x01(\t\x1aI\n\x10UserListMapEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12$\n\x05value\x18\x02 \x01(\x0b\x32\x15.user.RepeatedMessage:\x02\x38\x01\x1a@\n\x0cUserMapEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\x1f\n\x05value\x18\x02 \x01(\x0b\x32\x10.user.MapMessage:\x02\x38\x01\")\n\x0bIncludeEnum\x12\x08\n\x04zero\x10\x00\x12\x07\n\x03one\x10\x01\x12\x07\n\x03two\x10\x02\"-\n\x11\x41\x66terReferMessage\x12\x0b\n\x03uid\x18\x01 \x01(\t\x12\x0b\n\x03\x61ge\x18\x02 \x01(\x05\"_\n\x0bInvoiceItem\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0e\n\x06\x61mount\x18\x02 \x01(\x05\x12\x10\n\x08quantity\x18\x03 \x01(\x05\x12 \n\x05items\x18\x04 \x03(\x0b\x32\x11.user.InvoiceItem\"\x0e\n\x0c\x45mptyMessage\"\xa9\x02\n\x0fOptionalMessage\x12\x0b\n\x01x\x18\x01 \x01(\tH\x00\x12\x0b\n\x01y\x18\x02 \x01(\x05H\x00\x12\x11\n\x04name\x18\x03 \x01(\tH\x01\x88\x01\x01\x12\x10\n\x03\x61ge\x18\x04 \x01(\x05H\x02\x88\x01\x01\x12$\n\x04item\x18\x05 \x01(\x0b\x32\x11.user.InvoiceItemH\x03\x88\x01\x01\x12\x10\n\x08str_list\x18\x06 \x03(\t\x12\x32\n\x07int_map\x18\x07 \x03(\x0b\x32!.user.OptionalMessage.IntMapEntry\x12\x1d\n\x15\x64\x65\x66\x61ult_template_test\x18\x08 \x01(\x02\x1a-\n\x0bIntMapEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\x05:\x02\x38\x01\x42\x03\n\x01\x61\x42\x07\n\x05_nameB\x06\n\x04_ageB\x07\n\x05_item\"\x82\x01\n\x0cInvoiceItem2\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0e\n\x06\x61mount\x18\x02 \x01(\x05\x12\x10\n\x08quantity\x18\x03 \x01(\x05\x12!\n\x05items\x18\x04 \x03(\x0b\x32\x12.user.InvoiceItem2\x12\x1f\n\x07invoice\x18\x05 \x01(\x0b\x32\x0e.user.Invoice3\"]\n\x08Invoice3\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0e\n\x06\x61mount\x18\x02 \x01(\x05\x12\x10\n\x08quantity\x18\x03 \x01(\x05\x12!\n\x05items\x18\x04 \x03(\x0b\x32\x12.user.InvoiceItem2\"C\n\x0bRootMessage\x12\x0e\n\x06\x66ield1\x18\x01 \x01(\t\x12$\n\x06\x66ield2\x18\x02 \x01(\x0b\x32\x14.user.AnOtherMessage\"m\n\x0e\x41nOtherMessage\x12\x0e\n\x06\x66ield1\x18\x01 \x01(\t\x12/\n\x06\x66ield2\x18\x02 \x01(\x0b\x32\x1f.user.AnOtherMessage.SubMessage\x1a\x1a\n\nSubMessage\x12\x0c\n\x04text\x18\x01 \x01(\t\"\xc4\x01\n\rTestSameName0\x12&\n\x04\x62ody\x18\x01 \x01(\x0b\x32\x18.user.TestSameName0.Body\x1a\x8a\x01\n\x04\x42ody\x12\x13\n\x0binput_model\x18\x01 \x01(\t\x12;\n\ninput_info\x18\x03 \x03(\x0b\x32\'.user.TestSameName0.Body.InputInfoEntry\x1a\x30\n\x0eInputInfoEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01\"\xc8\x01\n\rTestSameName1\x12&\n\x04\x62ody\x18\x01 \x01(\x0b\x32\x18.user.TestSameName1.Body\x1a\x8e\x01\n\x04\x42ody\x12\x14\n\x0coutput_model\x18\x01 \x01(\t\x12=\n\x0boutput_info\x18\x03 \x03(\x0b\x32(.user.TestSameName1.Body.OutputInfoEntry\x1a\x31\n\x0fOutputInfoEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01*\x1d\n\x07SexType\x12\x07\n\x03man\x10\x00\x12\t\n\x05women\x10\x01\x62\x06proto3'
   ,
   dependencies=[google_dot_protobuf_dot_empty__pb2.DESCRIPTOR,google_dot_protobuf_dot_timestamp__pb2.DESCRIPTOR,google_dot_protobuf_dot_struct__pb2.DESCRIPTOR,google_dot_protobuf_dot_field__mask__pb2.DESCRIPTOR,google_dot_protobuf_dot_wrappers__pb2.DESCRIPTOR,example_dot_example__proto_dot_common_dot_single__pb2.DESCRIPTOR,])
 
@@ -50,8 +50,8 @@
   ],
   containing_type=None,
   serialized_options=None,
-  serialized_start=2486,
-  serialized_end=2515,
+  serialized_start=2888,
+  serialized_end=2917,
 )
 _sym_db.RegisterEnumDescriptor(_SEXTYPE)
 
@@ -1057,6 +1057,222 @@
   serialized_end=2484,
 )
 
+
+_TESTSAMENAME0_BODY_INPUTINFOENTRY = _descriptor.Descriptor(
+  name='InputInfoEntry',
+  full_name='user.TestSameName0.Body.InputInfoEntry',
+  filename=None,
+  file=DESCRIPTOR,
+  containing_type=None,
+  create_key=_descriptor._internal_create_key,
+  fields=[
+    _descriptor.FieldDescriptor(
+      name='key', full_name='user.TestSameName0.Body.InputInfoEntry.key', index=0,
+      number=1, type=9, cpp_type=9, label=1,
+      has_default_value=False, default_value=b"".decode('utf-8'),
+      message_type=None, enum_type=None, containing_type=None,
+      is_extension=False, extension_scope=None,
+      serialized_options=None, file=DESCRIPTOR,  create_key=_descriptor._internal_create_key),
+    _descriptor.FieldDescriptor(
+      name='value', full_name='user.TestSameName0.Body.InputInfoEntry.value', index=1,
+      number=2, type=9, cpp_type=9, label=1,
+      has_default_value=False, default_value=b"".decode('utf-8'),
+      message_type=None, enum_type=None, containing_type=None,
+      is_extension=False, extension_scope=None,
+      serialized_options=None, file=DESCRIPTOR,  create_key=_descriptor._internal_create_key),
+  ],
+  extensions=[
+  ],
+  nested_types=[],
+  enum_types=[
+  ],
+  serialized_options=b'8\001',
+  is_extendable=False,
+  syntax='proto3',
+  extension_ranges=[],
+  oneofs=[
+  ],
+  serialized_start=2635,
+  serialized_end=2683,
+)
+
+_TESTSAMENAME0_BODY = _descriptor.Descriptor(
+  name='Body',
+  full_name='user.TestSameName0.Body',
+  filename=None,
+  file=DESCRIPTOR,
+  containing_type=None,
+  create_key=_descriptor._internal_create_key,
+  fields=[
+    _descriptor.FieldDescriptor(
+      name='input_model', full_name='user.TestSameName0.Body.input_model', index=0,
+      number=1, type=9, cpp_type=9, label=1,
+      has_default_value=False, default_value=b"".decode('utf-8'),
+      message_type=None, enum_type=None, containing_type=None,
+      is_extension=False, extension_scope=None,
+      serialized_options=None, file=DESCRIPTOR,  create_key=_descriptor._internal_create_key),
+    _descriptor.FieldDescriptor(
+      name='input_info', full_name='user.TestSameName0.Body.input_info', index=1,
+      number=3, type=11, cpp_type=10, label=3,
+      has_default_value=False, default_value=[],
+      message_type=None, enum_type=None, containing_type=None,
+      is_extension=False, extension_scope=None,
+      serialized_options=None, file=DESCRIPTOR,  create_key=_descriptor._internal_create_key),
+  ],
+  extensions=[
+  ],
+  nested_types=[_TESTSAMENAME0_BODY_INPUTINFOENTRY, ],
+  enum_types=[
+  ],
+  serialized_options=None,
+  is_extendable=False,
+  syntax='proto3',
+  extension_ranges=[],
+  oneofs=[
+  ],
+  serialized_start=2545,
+  serialized_end=2683,
+)
+
+_TESTSAMENAME0 = _descriptor.Descriptor(
+  name='TestSameName0',
+  full_name='user.TestSameName0',
+  filename=None,
+  file=DESCRIPTOR,
+  containing_type=None,
+  create_key=_descriptor._internal_create_key,
+  fields=[
+    _descriptor.FieldDescriptor(
+      name='body', full_name='user.TestSameName0.body', index=0,
+      number=1, type=11, cpp_type=10, label=1,
+      has_default_value=False, default_value=None,
+      message_type=None, enum_type=None, containing_type=None,
+      is_extension=False, extension_scope=None,
+      serialized_options=None, file=DESCRIPTOR,  create_key=_descriptor._internal_create_key),
+  ],
+  extensions=[
+  ],
+  nested_types=[_TESTSAMENAME0_BODY, ],
+  enum_types=[
+  ],
+  serialized_options=None,
+  is_extendable=False,
+  syntax='proto3',
+  extension_ranges=[],
+  oneofs=[
+  ],
+  serialized_start=2487,
+  serialized_end=2683,
+)
+
+
+_TESTSAMENAME1_BODY_OUTPUTINFOENTRY = _descriptor.Descriptor(
+  name='OutputInfoEntry',
+  full_name='user.TestSameName1.Body.OutputInfoEntry',
+  filename=None,
+  file=DESCRIPTOR,
+  containing_type=None,
+  create_key=_descriptor._internal_create_key,
+  fields=[
+    _descriptor.FieldDescriptor(
+      name='key', full_name='user.TestSameName1.Body.OutputInfoEntry.key', index=0,
+      number=1, type=9, cpp_type=9, label=1,
+      has_default_value=False, default_value=b"".decode('utf-8'),
+      message_type=None, enum_type=None, containing_type=None,
+      is_extension=False, extension_scope=None,
+      serialized_options=None, file=DESCRIPTOR,  create_key=_descriptor._internal_create_key),
+    _descriptor.FieldDescriptor(
+      name='value', full_name='user.TestSameName1.Body.OutputInfoEntry.value', index=1,
+      number=2, type=9, cpp_type=9, label=1,
+      has_default_value=False, default_value=b"".decode('utf-8'),
+      message_type=None, enum_type=None, containing_type=None,
+      is_extension=False, extension_scope=None,
+      serialized_options=None, file=DESCRIPTOR,  create_key=_descriptor._internal_create_key),
+  ],
+  extensions=[
+  ],
+  nested_types=[],
+  enum_types=[
+  ],
+  serialized_options=b'8\001',
+  is_extendable=False,
+  syntax='proto3',
+  extension_ranges=[],
+  oneofs=[
+  ],
+  serialized_start=2837,
+  serialized_end=2886,
+)
+
+_TESTSAMENAME1_BODY = _descriptor.Descriptor(
+  name='Body',
+  full_name='user.TestSameName1.Body',
+  filename=None,
+  file=DESCRIPTOR,
+  containing_type=None,
+  create_key=_descriptor._internal_create_key,
+  fields=[
+    _descriptor.FieldDescriptor(
+      name='output_model', full_name='user.TestSameName1.Body.output_model', index=0,
+      number=1, type=9, cpp_type=9, label=1,
+      has_default_value=False, default_value=b"".decode('utf-8'),
+      message_type=None, enum_type=None, containing_type=None,
+      is_extension=False, extension_scope=None,
+      serialized_options=None, file=DESCRIPTOR,  create_key=_descriptor._internal_create_key),
+    _descriptor.FieldDescriptor(
+      name='output_info', full_name='user.TestSameName1.Body.output_info', index=1,
+      number=3, type=11, cpp_type=10, label=3,
+      has_default_value=False, default_value=[],
+      message_type=None, enum_type=None, containing_type=None,
+      is_extension=False, extension_scope=None,
+      serialized_options=None, file=DESCRIPTOR,  create_key=_descriptor._internal_create_key),
+  ],
+  extensions=[
+  ],
+  nested_types=[_TESTSAMENAME1_BODY_OUTPUTINFOENTRY, ],
+  enum_types=[
+  ],
+  serialized_options=None,
+  is_extendable=False,
+  syntax='proto3',
+  extension_ranges=[],
+  oneofs=[
+  ],
+  serialized_start=2744,
+  serialized_end=2886,
+)
+
+_TESTSAMENAME1 = _descriptor.Descriptor(
+  name='TestSameName1',
+  full_name='user.TestSameName1',
+  filename=None,
+  file=DESCRIPTOR,
+  containing_type=None,
+  create_key=_descriptor._internal_create_key,
+  fields=[
+    _descriptor.FieldDescriptor(
+      name='body', full_name='user.TestSameName1.body', index=0,
+      number=1, type=11, cpp_type=10, label=1,
+      has_default_value=False, default_value=None,
+      message_type=None, enum_type=None, containing_type=None,
+      is_extension=False, extension_scope=None,
+      serialized_options=None, file=DESCRIPTOR,  create_key=_descriptor._internal_create_key),
+  ],
+  extensions=[
+  ],
+  nested_types=[_TESTSAMENAME1_BODY, ],
+  enum_types=[
+  ],
+  serialized_options=None,
+  is_extendable=False,
+  syntax='proto3',
+  extension_ranges=[],
+  oneofs=[
+  ],
+  serialized_start=2686,
+  serialized_end=2886,
+)
+
 _USERMESSAGE.fields_by_name['sex'].enum_type = _SEXTYPE
 _USERMESSAGE.fields_by_name['demo'].enum_type = example_dot_example__proto_dot_common_dot_single__pb2._DEMOENUM
 _USERMESSAGE.fields_by_name['demo_message'].message_type = example_dot_example__proto_dot_common_dot_single__pb2._DEMOMESSAGE
@@ -1111,6 +1327,14 @@
 _ROOTMESSAGE.fields_by_name['field2'].message_type = _ANOTHERMESSAGE
 _ANOTHERMESSAGE_SUBMESSAGE.containing_type = _ANOTHERMESSAGE
 _ANOTHERMESSAGE.fields_by_name['field2'].message_type = _ANOTHERMESSAGE_SUBMESSAGE
+_TESTSAMENAME0_BODY_INPUTINFOENTRY.containing_type = _TESTSAMENAME0_BODY
+_TESTSAMENAME0_BODY.fields_by_name['input_info'].message_type = _TESTSAMENAME0_BODY_INPUTINFOENTRY
+_TESTSAMENAME0_BODY.containing_type = _TESTSAMENAME0
+_TESTSAMENAME0.fields_by_name['body'].message_type = _TESTSAMENAME0_BODY
+_TESTSAMENAME1_BODY_OUTPUTINFOENTRY.containing_type = _TESTSAMENAME1_BODY
+_TESTSAMENAME1_BODY.fields_by_name['output_info'].message_type = _TESTSAMENAME1_BODY_OUTPUTINFOENTRY
+_TESTSAMENAME1_BODY.containing_type = _TESTSAMENAME1
+_TESTSAMENAME1.fields_by_name['body'].message_type = _TESTSAMENAME1_BODY
 DESCRIPTOR.message_types_by_name['UserMessage'] = _USERMESSAGE
 DESCRIPTOR.message_types_by_name['OtherMessage'] = _OTHERMESSAGE
 DESCRIPTOR.message_types_by_name['MapMessage'] = _MAPMESSAGE
@@ -1124,6 +1348,8 @@
 DESCRIPTOR.message_types_by_name['Invoice3'] = _INVOICE3
 DESCRIPTOR.message_types_by_name['RootMessage'] = _ROOTMESSAGE
 DESCRIPTOR.message_types_by_name['AnOtherMessage'] = _ANOTHERMESSAGE
+DESCRIPTOR.message_types_by_name['TestSameName0'] = _TESTSAMENAME0
+DESCRIPTOR.message_types_by_name['TestSameName1'] = _TESTSAMENAME1
 DESCRIPTOR.enum_types_by_name['SexType'] = _SEXTYPE
 _sym_db.RegisterFileDescriptor(DESCRIPTOR)
 
@@ -1274,10 +1500,58 @@
 _sym_db.RegisterMessage(AnOtherMessage)
 _sym_db.RegisterMessage(AnOtherMessage.SubMessage)
 
+TestSameName0 = _reflection.GeneratedProtocolMessageType('TestSameName0', (_message.Message,), {
+
+  'Body' : _reflection.GeneratedProtocolMessageType('Body', (_message.Message,), {
+
+    'InputInfoEntry' : _reflection.GeneratedProtocolMessageType('InputInfoEntry', (_message.Message,), {
+      'DESCRIPTOR' : _TESTSAMENAME0_BODY_INPUTINFOENTRY,
+      '__module__' : 'example.example_proto.demo.demo_pb2'
+      # @@protoc_insertion_point(class_scope:user.TestSameName0.Body.InputInfoEntry)
+      })
+    ,
+    'DESCRIPTOR' : _TESTSAMENAME0_BODY,
+    '__module__' : 'example.example_proto.demo.demo_pb2'
+    # @@protoc_insertion_point(class_scope:user.TestSameName0.Body)
+    })
+  ,
+  'DESCRIPTOR' : _TESTSAMENAME0,
+  '__module__' : 'example.example_proto.demo.demo_pb2'
+  # @@protoc_insertion_point(class_scope:user.TestSameName0)
+  })
+_sym_db.RegisterMessage(TestSameName0)
+_sym_db.RegisterMessage(TestSameName0.Body)
+_sym_db.RegisterMessage(TestSameName0.Body.InputInfoEntry)
+
+TestSameName1 = _reflection.GeneratedProtocolMessageType('TestSameName1', (_message.Message,), {
+
+  'Body' : _reflection.GeneratedProtocolMessageType('Body', (_message.Message,), {
+
+    'OutputInfoEntry' : _reflection.GeneratedProtocolMessageType('OutputInfoEntry', (_message.Message,), {
+      'DESCRIPTOR' : _TESTSAMENAME1_BODY_OUTPUTINFOENTRY,
+      '__module__' : 'example.example_proto.demo.demo_pb2'
+      # @@protoc_insertion_point(class_scope:user.TestSameName1.Body.OutputInfoEntry)
+      })
+    ,
+    'DESCRIPTOR' : _TESTSAMENAME1_BODY,
+    '__module__' : 'example.example_proto.demo.demo_pb2'
+    # @@protoc_insertion_point(class_scope:user.TestSameName1.Body)
+    })
+  ,
+  'DESCRIPTOR' : _TESTSAMENAME1,
+  '__module__' : 'example.example_proto.demo.demo_pb2'
+  # @@protoc_insertion_point(class_scope:user.TestSameName1)
+  })
+_sym_db.RegisterMessage(TestSameName1)
+_sym_db.RegisterMessage(TestSameName1.Body)
+_sym_db.RegisterMessage(TestSameName1.Body.OutputInfoEntry)
+
 
 _MAPMESSAGE_USERMAPENTRY._options = None
 _MAPMESSAGE_USERFLAGENTRY._options = None
 _NESTEDMESSAGE_USERLISTMAPENTRY._options = None
 _NESTEDMESSAGE_USERMAPENTRY._options = None
 _OPTIONALMESSAGE_INTMAPENTRY._options = None
+_TESTSAMENAME0_BODY_INPUTINFOENTRY._options = None
+_TESTSAMENAME1_BODY_OUTPUTINFOENTRY._options = None
 # @@protoc_insertion_point(module_scope)
diff --git a/example/proto_3_20_pydanticv2/example/example_proto/demo/demo_pb2.pyi b/example/proto_3_20_pydanticv2/example/example_proto/demo/demo_pb2.pyi
index c5132f7..58bca7c 100644
--- a/example/proto_3_20_pydanticv2/example/example_proto/demo/demo_pb2.pyi
+++ b/example/proto_3_20_pydanticv2/example/example_proto/demo/demo_pb2.pyi
@@ -483,3 +483,86 @@ class AnOtherMessage(google.protobuf.message.Message):
     def HasField(self, field_name: typing_extensions.Literal["field2",b"field2"]) -> builtins.bool: ...
     def ClearField(self, field_name: typing_extensions.Literal["field1",b"field1","field2",b"field2"]) -> None: ...
 global___AnOtherMessage = AnOtherMessage
+
+class TestSameName0(google.protobuf.message.Message):
+    """Test inline structure of the same name
+    from: https://github.com/so1n/protobuf_to_pydantic/issues/76
+    """
+    DESCRIPTOR: google.protobuf.descriptor.Descriptor
+    class Body(google.protobuf.message.Message):
+        DESCRIPTOR: google.protobuf.descriptor.Descriptor
+        class InputInfoEntry(google.protobuf.message.Message):
+            DESCRIPTOR: google.protobuf.descriptor.Descriptor
+            KEY_FIELD_NUMBER: builtins.int
+            VALUE_FIELD_NUMBER: builtins.int
+            key: typing.Text
+            value: typing.Text
+            def __init__(self,
+                *,
+                key: typing.Text = ...,
+                value: typing.Text = ...,
+                ) -> None: ...
+            def ClearField(self, field_name: typing_extensions.Literal["key",b"key","value",b"value"]) -> None: ...
+
+        INPUT_MODEL_FIELD_NUMBER: builtins.int
+        INPUT_INFO_FIELD_NUMBER: builtins.int
+        input_model: typing.Text
+        @property
+        def input_info(self) -> google.protobuf.internal.containers.ScalarMap[typing.Text, typing.Text]: ...
+        def __init__(self,
+            *,
+            input_model: typing.Text = ...,
+            input_info: typing.Optional[typing.Mapping[typing.Text, typing.Text]] = ...,
+            ) -> None: ...
+        def ClearField(self, field_name: typing_extensions.Literal["input_info",b"input_info","input_model",b"input_model"]) -> None: ...
+
+    BODY_FIELD_NUMBER: builtins.int
+    @property
+    def body(self) -> global___TestSameName0.Body: ...
+    def __init__(self,
+        *,
+        body: typing.Optional[global___TestSameName0.Body] = ...,
+        ) -> None: ...
+    def HasField(self, field_name: typing_extensions.Literal["body",b"body"]) -> builtins.bool: ...
+    def ClearField(self, field_name: typing_extensions.Literal["body",b"body"]) -> None: ...
+global___TestSameName0 = TestSameName0
+
+class TestSameName1(google.protobuf.message.Message):
+    DESCRIPTOR: google.protobuf.descriptor.Descriptor
+    class Body(google.protobuf.message.Message):
+        DESCRIPTOR: google.protobuf.descriptor.Descriptor
+        class OutputInfoEntry(google.protobuf.message.Message):
+            DESCRIPTOR: google.protobuf.descriptor.Descriptor
+            KEY_FIELD_NUMBER: builtins.int
+            VALUE_FIELD_NUMBER: builtins.int
+            key: typing.Text
+            value: typing.Text
+            def __init__(self,
+                *,
+                key: typing.Text = ...,
+                value: typing.Text = ...,
+                ) -> None: ...
+            def ClearField(self, field_name: typing_extensions.Literal["key",b"key","value",b"value"]) -> None: ...
+
+        OUTPUT_MODEL_FIELD_NUMBER: builtins.int
+        OUTPUT_INFO_FIELD_NUMBER: builtins.int
+        output_model: typing.Text
+        @property
+        def output_info(self) -> google.protobuf.internal.containers.ScalarMap[typing.Text, typing.Text]: ...
+        def __init__(self,
+            *,
+            output_model: typing.Text = ...,
+            output_info: typing.Optional[typing.Mapping[typing.Text, typing.Text]] = ...,
+            ) -> None: ...
+        def ClearField(self, field_name: typing_extensions.Literal["output_info",b"output_info","output_model",b"output_model"]) -> None: ...
+
+    BODY_FIELD_NUMBER: builtins.int
+    @property
+    def body(self) -> global___TestSameName1.Body: ...
+    def __init__(self,
+        *,
+        body: typing.Optional[global___TestSameName1.Body] = ...,
+        ) -> None: ...
+    def HasField(self, field_name: typing_extensions.Literal["body",b"body"]) -> builtins.bool: ...
+    def ClearField(self, field_name: typing_extensions.Literal["body",b"body"]) -> None: ...
+global___TestSameName1 = TestSameName1
diff --git a/example/proto_3_20_pydanticv2/example/example_proto/demo/single_config_p2p.py b/example/proto_3_20_pydanticv2/example/example_proto/demo/single_config_p2p.py
index 9318075..abec230 100644
--- a/example/proto_3_20_pydanticv2/example/example_proto/demo/single_config_p2p.py
+++ b/example/proto_3_20_pydanticv2/example/example_proto/demo/single_config_p2p.py
@@ -1,5 +1,5 @@
 # This is an automatically generated file, please do not change
-# gen by protobuf_to_pydantic[v0.3.0](https://github.com/so1n/protobuf_to_pydantic)
+# gen by protobuf_to_pydantic[0.0.0](https://github.com/so1n/protobuf_to_pydantic)
 # Protobuf Version: 3.20.3
 # Pydantic Version: 2.5.3
 from google.protobuf.message import Message  # type: ignore
diff --git a/example/proto_3_20_pydanticv2/example/example_proto/p2p_validate/demo_p2p.py b/example/proto_3_20_pydanticv2/example/example_proto/p2p_validate/demo_p2p.py
index 30d7a57..e9c0cb5 100644
--- a/example/proto_3_20_pydanticv2/example/example_proto/p2p_validate/demo_p2p.py
+++ b/example/proto_3_20_pydanticv2/example/example_proto/p2p_validate/demo_p2p.py
@@ -1,5 +1,5 @@
 # This is an automatically generated file, please do not change
-# gen by protobuf_to_pydantic[v0.3.0](https://github.com/so1n/protobuf_to_pydantic)
+# gen by protobuf_to_pydantic[0.0.0](https://github.com/so1n/protobuf_to_pydantic)
 # Protobuf Version: 3.20.3
 # Pydantic Version: 2.5.3
 import typing
diff --git a/example/proto_3_20_pydanticv2/example/example_proto/p2p_validate_by_comment/demo_p2p.py b/example/proto_3_20_pydanticv2/example/example_proto/p2p_validate_by_comment/demo_p2p.py
index 4a178c5..8d811b7 100644
--- a/example/proto_3_20_pydanticv2/example/example_proto/p2p_validate_by_comment/demo_p2p.py
+++ b/example/proto_3_20_pydanticv2/example/example_proto/p2p_validate_by_comment/demo_p2p.py
@@ -1,5 +1,5 @@
 # This is an automatically generated file, please do not change
-# gen by protobuf_to_pydantic[v0.3.0](https://github.com/so1n/protobuf_to_pydantic)
+# gen by protobuf_to_pydantic[0.0.0](https://github.com/so1n/protobuf_to_pydantic)
 # Protobuf Version: 3.20.3
 # Pydantic Version: 2.5.3
 import typing
diff --git a/example/proto_3_20_pydanticv2/example/example_proto/p2p_validate_by_comment/demo_pb2_by_protobuf.py b/example/proto_3_20_pydanticv2/example/example_proto/p2p_validate_by_comment/demo_pb2_by_protobuf.py
index 6b3cd5b..1fe009e 100644
--- a/example/proto_3_20_pydanticv2/example/example_proto/p2p_validate_by_comment/demo_pb2_by_protobuf.py
+++ b/example/proto_3_20_pydanticv2/example/example_proto/p2p_validate_by_comment/demo_pb2_by_protobuf.py
@@ -1,5 +1,5 @@
 # This is an automatically generated file, please do not change
-# gen by protobuf_to_pydantic[v0.3.0](https://github.com/so1n/protobuf_to_pydantic)
+# gen by protobuf_to_pydantic[0.0.0](https://github.com/so1n/protobuf_to_pydantic)
 # Protobuf Version: 3.20.3
 # Pydantic Version: 2.5.3
 import typing
diff --git a/example/proto_3_20_pydanticv2/example/example_proto/p2p_validate_by_comment/demo_pb2_by_pyi.py b/example/proto_3_20_pydanticv2/example/example_proto/p2p_validate_by_comment/demo_pb2_by_pyi.py
index 6b3cd5b..1fe009e 100644
--- a/example/proto_3_20_pydanticv2/example/example_proto/p2p_validate_by_comment/demo_pb2_by_pyi.py
+++ b/example/proto_3_20_pydanticv2/example/example_proto/p2p_validate_by_comment/demo_pb2_by_pyi.py
@@ -1,5 +1,5 @@
 # This is an automatically generated file, please do not change
-# gen by protobuf_to_pydantic[v0.3.0](https://github.com/so1n/protobuf_to_pydantic)
+# gen by protobuf_to_pydantic[0.0.0](https://github.com/so1n/protobuf_to_pydantic)
 # Protobuf Version: 3.20.3
 # Pydantic Version: 2.5.3
 import typing
diff --git a/example/proto_3_20_pydanticv2/example/example_proto/validate/demo_p2p.py b/example/proto_3_20_pydanticv2/example/example_proto/validate/demo_p2p.py
index a3c0069..7d41d44 100644
--- a/example/proto_3_20_pydanticv2/example/example_proto/validate/demo_p2p.py
+++ b/example/proto_3_20_pydanticv2/example/example_proto/validate/demo_p2p.py
@@ -1,5 +1,5 @@
 # This is an automatically generated file, please do not change
-# gen by protobuf_to_pydantic[v0.3.0](https://github.com/so1n/protobuf_to_pydantic)
+# gen by protobuf_to_pydantic[0.0.0](https://github.com/so1n/protobuf_to_pydantic)
 # Protobuf Version: 3.20.3
 # Pydantic Version: 2.5.3
 import typing
diff --git a/example/proto_pydanticv1/demo_gen_code.py b/example/proto_pydanticv1/demo_gen_code.py
index f68f2ca..0e7e964 100644
--- a/example/proto_pydanticv1/demo_gen_code.py
+++ b/example/proto_pydanticv1/demo_gen_code.py
@@ -1,13 +1,49 @@
 # This is an automatically generated file, please do not change
-# gen by protobuf_to_pydantic[v0.3.0](https://github.com/so1n/protobuf_to_pydantic)
+# gen by protobuf_to_pydantic[0.0.0](https://github.com/so1n/protobuf_to_pydantic)
 # Protobuf Version: 4.24.4
 # Pydantic Version: 1.10.7
 import typing
+from datetime import datetime
+from enum import IntEnum
 
+from google.protobuf.field_mask_pb2 import FieldMask  # type: ignore
+from google.protobuf.wrappers_pb2 import DoubleValue  # type: ignore
 from protobuf_to_pydantic.customer_validator.v1 import check_one_of
 from pydantic import BaseModel, Field, root_validator
 
 
+class AfterReferMessage(BaseModel):
+    uid: str = Field(default="")
+    age: int = Field(default=0)
+
+
+class AnOtherMessage(BaseModel):
+    class SubMessage(BaseModel):
+        text: str = Field(default="")
+
+    field1: str = Field(default="")
+    field2: SubMessage = Field()
+
+
+class EmptyMessage(BaseModel):
+    pass
+
+
+class InvoiceItem2(BaseModel):
+    name: str = Field(default="")
+    amount: int = Field(default=0)
+    quantity: int = Field(default=0)
+    items: typing.List["InvoiceItem2"] = Field(default_factory=list)
+    invoice: "Invoice3" = Field()
+
+
+class Invoice3(BaseModel):
+    name: str = Field(default="")
+    amount: int = Field(default=0)
+    quantity: int = Field(default=0)
+    items: typing.List[InvoiceItem2] = Field(default_factory=list)
+
+
 class InvoiceItem(BaseModel):
     name: str = Field(default="")
     amount: int = Field(default=0)
@@ -15,6 +51,71 @@ class InvoiceItem(BaseModel):
     items: typing.List["InvoiceItem"] = Field(default_factory=list)
 
 
+class SexType(IntEnum):
+    man = 0
+    women = 1
+
+
+class ExampleExampleProtoCommonSingleDemoEnum(IntEnum):
+    """Note: The current class does not belong to the package
+    ExampleExampleProtoCommonSingleDemoEnum protobuf path:example/example_proto/common/single.proto"""
+
+    zero = 0
+    one = 1
+    two = 3
+
+
+class ExampleExampleProtoCommonSingleDemoMessage(BaseModel):
+    """Note: The current class does not belong to the package
+    ExampleExampleProtoCommonSingleDemoMessage protobuf path:example/example_proto/common/single.proto"""
+
+    earth: str = Field(default="")
+    mercury: str = Field(default="")
+    mars: str = Field(default="")
+
+
+class UserMessage(BaseModel):
+    uid: str = Field(default="")
+    age: int = Field(default=0)
+    height: float = Field(default=0.0)
+    sex: SexType = Field(default=0)
+    demo: ExampleExampleProtoCommonSingleDemoEnum = Field(default=0)
+    is_adult: bool = Field(default=False)
+    user_name: str = Field(default="")
+    demo_message: ExampleExampleProtoCommonSingleDemoMessage = Field()
+
+
+class MapMessage(BaseModel):
+    user_map: typing.Dict[str, UserMessage] = Field(default_factory=dict)
+    user_flag: typing.Dict[str, bool] = Field(default_factory=dict)
+
+
+class RepeatedMessage(BaseModel):
+    str_list: typing.List[str] = Field(default_factory=list)
+    int_list: typing.List[int] = Field(default_factory=list)
+    user_list: typing.List[UserMessage] = Field(default_factory=list)
+
+
+class NestedMessage(BaseModel):
+    class UserPayMessage(BaseModel):
+        bank_number: str = Field(default="")
+        exp: datetime = Field(default_factory=datetime.now)
+        uuid: str = Field(default="")
+
+    class IncludeEnum(IntEnum):
+        zero = 0
+        one = 1
+        two = 2
+
+    user_list_map: typing.Dict[str, RepeatedMessage] = Field(default_factory=dict)
+    user_map: typing.Dict[str, MapMessage] = Field(default_factory=dict)
+    user_pay: UserPayMessage = Field()
+    include_enum: IncludeEnum = Field(default=0)
+    not_enable_user_pay: UserPayMessage = Field()
+    empty: typing.Any = Field()
+    after_refer: AfterReferMessage = Field()
+
+
 class OptionalMessage(BaseModel):
     _one_of_dict = {"user.OptionalMessage.a": {"fields": {"x", "y"}, "required": False}}
 
@@ -28,3 +129,33 @@ class OptionalMessage(BaseModel):
     default_template_test: float = Field(default=0.0)
 
     one_of_validator = root_validator(pre=True, allow_reuse=True)(check_one_of)
+
+
+class OtherMessage(BaseModel):
+    class Config:
+        arbitrary_types_allowed = True
+
+    metadata: typing.Dict[str, typing.Any] = Field(default_factory=dict)
+    double_value: DoubleValue = Field(default_factory=DoubleValue)
+    field_mask: typing.Optional[FieldMask] = Field(default_factory=FieldMask)
+
+
+class RootMessage(BaseModel):
+    field1: str = Field(default="")
+    field2: AnOtherMessage = Field()
+
+
+class TestSameName0(BaseModel):
+    class Body(BaseModel):
+        input_model: str = Field(default="")
+        input_info: typing.Dict[str, str] = Field(default_factory=dict)
+
+    body: Body = Field()
+
+
+class TestSameName1(BaseModel):
+    class Body(BaseModel):
+        output_model: str = Field(default="")
+        output_info: typing.Dict[str, str] = Field(default_factory=dict)
+
+    body: Body = Field()
diff --git a/example/proto_pydanticv1/demo_gen_code_by_p2p.py b/example/proto_pydanticv1/demo_gen_code_by_p2p.py
index 7e1f024..62df84a 100644
--- a/example/proto_pydanticv1/demo_gen_code_by_p2p.py
+++ b/example/proto_pydanticv1/demo_gen_code_by_p2p.py
@@ -1,5 +1,5 @@
 # This is an automatically generated file, please do not change
-# gen by protobuf_to_pydantic[v0.3.0](https://github.com/so1n/protobuf_to_pydantic)
+# gen by protobuf_to_pydantic[0.0.0](https://github.com/so1n/protobuf_to_pydantic)
 # Protobuf Version: 4.24.4
 # Pydantic Version: 1.10.7
 import typing
diff --git a/example/proto_pydanticv1/demo_gen_code_by_pgv.py b/example/proto_pydanticv1/demo_gen_code_by_pgv.py
index ada4944..3cd9a09 100644
--- a/example/proto_pydanticv1/demo_gen_code_by_pgv.py
+++ b/example/proto_pydanticv1/demo_gen_code_by_pgv.py
@@ -1,5 +1,5 @@
 # This is an automatically generated file, please do not change
-# gen by protobuf_to_pydantic[v0.3.0](https://github.com/so1n/protobuf_to_pydantic)
+# gen by protobuf_to_pydantic[0.0.0](https://github.com/so1n/protobuf_to_pydantic)
 # Protobuf Version: 4.24.4
 # Pydantic Version: 1.10.7
 import typing
diff --git a/example/proto_pydanticv1/demo_gen_code_by_text_comment_protobuf_field.py b/example/proto_pydanticv1/demo_gen_code_by_text_comment_protobuf_field.py
index 07d4252..7cb5e5f 100644
--- a/example/proto_pydanticv1/demo_gen_code_by_text_comment_protobuf_field.py
+++ b/example/proto_pydanticv1/demo_gen_code_by_text_comment_protobuf_field.py
@@ -1,5 +1,5 @@
 # This is an automatically generated file, please do not change
-# gen by protobuf_to_pydantic[v0.3.0](https://github.com/so1n/protobuf_to_pydantic)
+# gen by protobuf_to_pydantic[0.0.0](https://github.com/so1n/protobuf_to_pydantic)
 # Protobuf Version: 4.24.4
 # Pydantic Version: 1.10.7
 import typing
@@ -145,3 +145,19 @@ class Config:
 class RootMessage(BaseModel):
     field1: str = Field(default="")
     field2: AnOtherMessage = Field()
+
+
+class TestSameName0(BaseModel):
+    class Body(BaseModel):
+        input_model: str = Field(default="")
+        input_info: typing.Dict[str, str] = Field(default_factory=dict)
+
+    body: Body = Field()
+
+
+class TestSameName1(BaseModel):
+    class Body(BaseModel):
+        output_model: str = Field(default="")
+        output_info: typing.Dict[str, str] = Field(default_factory=dict)
+
+    body: Body = Field()
diff --git a/example/proto_pydanticv1/demo_gen_code_by_text_comment_pyi.py b/example/proto_pydanticv1/demo_gen_code_by_text_comment_pyi.py
index 07d4252..7cb5e5f 100644
--- a/example/proto_pydanticv1/demo_gen_code_by_text_comment_pyi.py
+++ b/example/proto_pydanticv1/demo_gen_code_by_text_comment_pyi.py
@@ -1,5 +1,5 @@
 # This is an automatically generated file, please do not change
-# gen by protobuf_to_pydantic[v0.3.0](https://github.com/so1n/protobuf_to_pydantic)
+# gen by protobuf_to_pydantic[0.0.0](https://github.com/so1n/protobuf_to_pydantic)
 # Protobuf Version: 4.24.4
 # Pydantic Version: 1.10.7
 import typing
@@ -145,3 +145,19 @@ class Config:
 class RootMessage(BaseModel):
     field1: str = Field(default="")
     field2: AnOtherMessage = Field()
+
+
+class TestSameName0(BaseModel):
+    class Body(BaseModel):
+        input_model: str = Field(default="")
+        input_info: typing.Dict[str, str] = Field(default_factory=dict)
+
+    body: Body = Field()
+
+
+class TestSameName1(BaseModel):
+    class Body(BaseModel):
+        output_model: str = Field(default="")
+        output_info: typing.Dict[str, str] = Field(default_factory=dict)
+
+    body: Body = Field()
diff --git a/example/proto_pydanticv1/example/example_proto/common/single_p2p.py b/example/proto_pydanticv1/example/example_proto/common/single_p2p.py
index 6a92476..9b9eeea 100644
--- a/example/proto_pydanticv1/example/example_proto/common/single_p2p.py
+++ b/example/proto_pydanticv1/example/example_proto/common/single_p2p.py
@@ -1,5 +1,5 @@
 # This is an automatically generated file, please do not change
-# gen by protobuf_to_pydantic[v0.3.0](https://github.com/so1n/protobuf_to_pydantic)
+# gen by protobuf_to_pydantic[0.0.0](https://github.com/so1n/protobuf_to_pydantic)
 # Protobuf Version: 4.24.4
 # Pydantic Version: 1.10.7
 from enum import IntEnum
diff --git a/example/proto_pydanticv1/example/example_proto/demo/alias_demo_p2p.py b/example/proto_pydanticv1/example/example_proto/demo/alias_demo_p2p.py
index 32cbba3..e3437e6 100644
--- a/example/proto_pydanticv1/example/example_proto/demo/alias_demo_p2p.py
+++ b/example/proto_pydanticv1/example/example_proto/demo/alias_demo_p2p.py
@@ -1,5 +1,5 @@
 # This is an automatically generated file, please do not change
-# gen by protobuf_to_pydantic[v0.3.0](https://github.com/so1n/protobuf_to_pydantic)
+# gen by protobuf_to_pydantic[0.0.0](https://github.com/so1n/protobuf_to_pydantic)
 # Protobuf Version: 4.24.4
 # Pydantic Version: 1.10.7
 import typing
diff --git a/example/proto_pydanticv1/example/example_proto/demo/all_feidl_set_optional_demo_p2p.py b/example/proto_pydanticv1/example/example_proto/demo/all_feidl_set_optional_demo_p2p.py
index f03b2ae..c60e0af 100644
--- a/example/proto_pydanticv1/example/example_proto/demo/all_feidl_set_optional_demo_p2p.py
+++ b/example/proto_pydanticv1/example/example_proto/demo/all_feidl_set_optional_demo_p2p.py
@@ -1,5 +1,5 @@
 # This is an automatically generated file, please do not change
-# gen by protobuf_to_pydantic[v0.3.0](https://github.com/so1n/protobuf_to_pydantic)
+# gen by protobuf_to_pydantic[0.0.0](https://github.com/so1n/protobuf_to_pydantic)
 # Protobuf Version: 4.24.4
 # Pydantic Version: 1.10.7
 import typing
diff --git a/example/proto_pydanticv1/example/example_proto/demo/demo_p2p.py b/example/proto_pydanticv1/example/example_proto/demo/demo_p2p.py
index 5fe1ca8..5f3c71d 100644
--- a/example/proto_pydanticv1/example/example_proto/demo/demo_p2p.py
+++ b/example/proto_pydanticv1/example/example_proto/demo/demo_p2p.py
@@ -1,5 +1,5 @@
 # This is an automatically generated file, please do not change
-# gen by protobuf_to_pydantic[v0.3.0](https://github.com/so1n/protobuf_to_pydantic)
+# gen by protobuf_to_pydantic[0.0.0](https://github.com/so1n/protobuf_to_pydantic)
 # Protobuf Version: 4.24.4
 # Pydantic Version: 1.10.7
 import typing
@@ -160,3 +160,24 @@ class RootMessage(BaseModel):
 
     field1: str = Field(default="")
     field2: AnOtherMessage = Field()
+
+
+class TestSameName0(BaseModel):
+    """
+        Test inline structure of the same name
+    from: https://github.com/so1n/protobuf_to_pydantic/issues/76
+    """
+
+    class Body(BaseModel):
+        input_model: str = Field(default="")
+        input_info: typing.Dict[str, str] = Field(default_factory=dict)
+
+    body: "TestSameName0.Body" = Field()
+
+
+class TestSameName1(BaseModel):
+    class Body(BaseModel):
+        output_model: str = Field(default="")
+        output_info: typing.Dict[str, str] = Field(default_factory=dict)
+
+    body: "TestSameName1.Body" = Field()
diff --git a/example/proto_pydanticv1/example/example_proto/demo/demo_pb2.py b/example/proto_pydanticv1/example/example_proto/demo/demo_pb2.py
index 76fda0e..6782e66 100644
--- a/example/proto_pydanticv1/example/example_proto/demo/demo_pb2.py
+++ b/example/proto_pydanticv1/example/example_proto/demo/demo_pb2.py
@@ -19,7 +19,7 @@
 from example.proto_pydanticv1.example.example_proto.common import single_pb2 as example_dot_example__proto_dot_common_dot_single__pb2
 
 
-DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n%example/example_proto/demo/demo.proto\x12\x04user\x1a\x1bgoogle/protobuf/empty.proto\x1a\x1fgoogle/protobuf/timestamp.proto\x1a\x1cgoogle/protobuf/struct.proto\x1a google/protobuf/field_mask.proto\x1a\x1egoogle/protobuf/wrappers.proto\x1a)example/example_proto/common/single.proto\"\xc3\x01\n\x0bUserMessage\x12\x0b\n\x03uid\x18\x01 \x01(\t\x12\x0b\n\x03\x61ge\x18\x02 \x01(\x05\x12\x0e\n\x06height\x18\x03 \x01(\x02\x12\x1a\n\x03sex\x18\x04 \x01(\x0e\x32\r.user.SexType\x12\x1e\n\x04\x64\x65mo\x18\x06 \x01(\x0e\x32\x10.single.DemoEnum\x12\x10\n\x08is_adult\x18\x07 \x01(\x08\x12\x11\n\tuser_name\x18\x08 \x01(\t\x12)\n\x0c\x64\x65mo_message\x18\t \x01(\x0b\x32\x13.single.DemoMessage\"\xb1\x01\n\x0cOtherMessage\x12)\n\x08metadata\x18\x01 \x01(\x0b\x32\x17.google.protobuf.Struct\x12\x32\n\x0c\x64ouble_value\x18\x02 \x01(\x0b\x32\x1c.google.protobuf.DoubleValue\x12\x33\n\nfield_mask\x18\x64 \x01(\x0b\x32\x1a.google.protobuf.FieldMaskH\x00\x88\x01\x01\x42\r\n\x0b_field_mask\"\xe4\x01\n\nMapMessage\x12/\n\x08user_map\x18\x01 \x03(\x0b\x32\x1d.user.MapMessage.UserMapEntry\x12\x31\n\tuser_flag\x18\x02 \x03(\x0b\x32\x1e.user.MapMessage.UserFlagEntry\x1a\x41\n\x0cUserMapEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12 \n\x05value\x18\x02 \x01(\x0b\x32\x11.user.UserMessage:\x02\x38\x01\x1a/\n\rUserFlagEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\x08:\x02\x38\x01\"[\n\x0fRepeatedMessage\x12\x10\n\x08str_list\x18\x01 \x03(\t\x12\x10\n\x08int_list\x18\x02 \x03(\x05\x12$\n\tuser_list\x18\x03 \x03(\x0b\x32\x11.user.UserMessage\"\x99\x05\n\rNestedMessage\x12;\n\ruser_list_map\x18\x01 \x03(\x0b\x32$.user.NestedMessage.UserListMapEntry\x12\x32\n\x08user_map\x18\x02 \x03(\x0b\x32 .user.NestedMessage.UserMapEntry\x12\x34\n\x08user_pay\x18\x03 \x01(\x0b\x32\".user.NestedMessage.UserPayMessage\x12\x35\n\x0cinclude_enum\x18\x04 \x01(\x0e\x32\x1f.user.NestedMessage.IncludeEnum\x12?\n\x13not_enable_user_pay\x18\x05 \x01(\x0b\x32\".user.NestedMessage.UserPayMessage\x12%\n\x05\x65mpty\x18\x06 \x01(\x0b\x32\x16.google.protobuf.Empty\x12,\n\x0b\x61\x66ter_refer\x18\x07 \x01(\x0b\x32\x17.user.AfterReferMessage\x1a\\\n\x0eUserPayMessage\x12\x13\n\x0b\x62\x61nk_number\x18\x01 \x01(\t\x12\'\n\x03\x65xp\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x0c\n\x04uuid\x18\x03 \x01(\t\x1aI\n\x10UserListMapEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12$\n\x05value\x18\x02 \x01(\x0b\x32\x15.user.RepeatedMessage:\x02\x38\x01\x1a@\n\x0cUserMapEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\x1f\n\x05value\x18\x02 \x01(\x0b\x32\x10.user.MapMessage:\x02\x38\x01\")\n\x0bIncludeEnum\x12\x08\n\x04zero\x10\x00\x12\x07\n\x03one\x10\x01\x12\x07\n\x03two\x10\x02\"-\n\x11\x41\x66terReferMessage\x12\x0b\n\x03uid\x18\x01 \x01(\t\x12\x0b\n\x03\x61ge\x18\x02 \x01(\x05\"_\n\x0bInvoiceItem\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0e\n\x06\x61mount\x18\x02 \x01(\x05\x12\x10\n\x08quantity\x18\x03 \x01(\x05\x12 \n\x05items\x18\x04 \x03(\x0b\x32\x11.user.InvoiceItem\"\x0e\n\x0c\x45mptyMessage\"\xa9\x02\n\x0fOptionalMessage\x12\x0b\n\x01x\x18\x01 \x01(\tH\x00\x12\x0b\n\x01y\x18\x02 \x01(\x05H\x00\x12\x11\n\x04name\x18\x03 \x01(\tH\x01\x88\x01\x01\x12\x10\n\x03\x61ge\x18\x04 \x01(\x05H\x02\x88\x01\x01\x12$\n\x04item\x18\x05 \x01(\x0b\x32\x11.user.InvoiceItemH\x03\x88\x01\x01\x12\x10\n\x08str_list\x18\x06 \x03(\t\x12\x32\n\x07int_map\x18\x07 \x03(\x0b\x32!.user.OptionalMessage.IntMapEntry\x12\x1d\n\x15\x64\x65\x66\x61ult_template_test\x18\x08 \x01(\x02\x1a-\n\x0bIntMapEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\x05:\x02\x38\x01\x42\x03\n\x01\x61\x42\x07\n\x05_nameB\x06\n\x04_ageB\x07\n\x05_item\"\x82\x01\n\x0cInvoiceItem2\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0e\n\x06\x61mount\x18\x02 \x01(\x05\x12\x10\n\x08quantity\x18\x03 \x01(\x05\x12!\n\x05items\x18\x04 \x03(\x0b\x32\x12.user.InvoiceItem2\x12\x1f\n\x07invoice\x18\x05 \x01(\x0b\x32\x0e.user.Invoice3\"]\n\x08Invoice3\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0e\n\x06\x61mount\x18\x02 \x01(\x05\x12\x10\n\x08quantity\x18\x03 \x01(\x05\x12!\n\x05items\x18\x04 \x03(\x0b\x32\x12.user.InvoiceItem2\"C\n\x0bRootMessage\x12\x0e\n\x06\x66ield1\x18\x01 \x01(\t\x12$\n\x06\x66ield2\x18\x02 \x01(\x0b\x32\x14.user.AnOtherMessage\"m\n\x0e\x41nOtherMessage\x12\x0e\n\x06\x66ield1\x18\x01 \x01(\t\x12/\n\x06\x66ield2\x18\x02 \x01(\x0b\x32\x1f.user.AnOtherMessage.SubMessage\x1a\x1a\n\nSubMessage\x12\x0c\n\x04text\x18\x01 \x01(\t*\x1d\n\x07SexType\x12\x07\n\x03man\x10\x00\x12\t\n\x05women\x10\x01\x62\x06proto3')
+DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n%example/example_proto/demo/demo.proto\x12\x04user\x1a\x1bgoogle/protobuf/empty.proto\x1a\x1fgoogle/protobuf/timestamp.proto\x1a\x1cgoogle/protobuf/struct.proto\x1a google/protobuf/field_mask.proto\x1a\x1egoogle/protobuf/wrappers.proto\x1a)example/example_proto/common/single.proto\"\xc3\x01\n\x0bUserMessage\x12\x0b\n\x03uid\x18\x01 \x01(\t\x12\x0b\n\x03\x61ge\x18\x02 \x01(\x05\x12\x0e\n\x06height\x18\x03 \x01(\x02\x12\x1a\n\x03sex\x18\x04 \x01(\x0e\x32\r.user.SexType\x12\x1e\n\x04\x64\x65mo\x18\x06 \x01(\x0e\x32\x10.single.DemoEnum\x12\x10\n\x08is_adult\x18\x07 \x01(\x08\x12\x11\n\tuser_name\x18\x08 \x01(\t\x12)\n\x0c\x64\x65mo_message\x18\t \x01(\x0b\x32\x13.single.DemoMessage\"\xb1\x01\n\x0cOtherMessage\x12)\n\x08metadata\x18\x01 \x01(\x0b\x32\x17.google.protobuf.Struct\x12\x32\n\x0c\x64ouble_value\x18\x02 \x01(\x0b\x32\x1c.google.protobuf.DoubleValue\x12\x33\n\nfield_mask\x18\x64 \x01(\x0b\x32\x1a.google.protobuf.FieldMaskH\x00\x88\x01\x01\x42\r\n\x0b_field_mask\"\xe4\x01\n\nMapMessage\x12/\n\x08user_map\x18\x01 \x03(\x0b\x32\x1d.user.MapMessage.UserMapEntry\x12\x31\n\tuser_flag\x18\x02 \x03(\x0b\x32\x1e.user.MapMessage.UserFlagEntry\x1a\x41\n\x0cUserMapEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12 \n\x05value\x18\x02 \x01(\x0b\x32\x11.user.UserMessage:\x02\x38\x01\x1a/\n\rUserFlagEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\x08:\x02\x38\x01\"[\n\x0fRepeatedMessage\x12\x10\n\x08str_list\x18\x01 \x03(\t\x12\x10\n\x08int_list\x18\x02 \x03(\x05\x12$\n\tuser_list\x18\x03 \x03(\x0b\x32\x11.user.UserMessage\"\x99\x05\n\rNestedMessage\x12;\n\ruser_list_map\x18\x01 \x03(\x0b\x32$.user.NestedMessage.UserListMapEntry\x12\x32\n\x08user_map\x18\x02 \x03(\x0b\x32 .user.NestedMessage.UserMapEntry\x12\x34\n\x08user_pay\x18\x03 \x01(\x0b\x32\".user.NestedMessage.UserPayMessage\x12\x35\n\x0cinclude_enum\x18\x04 \x01(\x0e\x32\x1f.user.NestedMessage.IncludeEnum\x12?\n\x13not_enable_user_pay\x18\x05 \x01(\x0b\x32\".user.NestedMessage.UserPayMessage\x12%\n\x05\x65mpty\x18\x06 \x01(\x0b\x32\x16.google.protobuf.Empty\x12,\n\x0b\x61\x66ter_refer\x18\x07 \x01(\x0b\x32\x17.user.AfterReferMessage\x1a\\\n\x0eUserPayMessage\x12\x13\n\x0b\x62\x61nk_number\x18\x01 \x01(\t\x12\'\n\x03\x65xp\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x0c\n\x04uuid\x18\x03 \x01(\t\x1aI\n\x10UserListMapEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12$\n\x05value\x18\x02 \x01(\x0b\x32\x15.user.RepeatedMessage:\x02\x38\x01\x1a@\n\x0cUserMapEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\x1f\n\x05value\x18\x02 \x01(\x0b\x32\x10.user.MapMessage:\x02\x38\x01\")\n\x0bIncludeEnum\x12\x08\n\x04zero\x10\x00\x12\x07\n\x03one\x10\x01\x12\x07\n\x03two\x10\x02\"-\n\x11\x41\x66terReferMessage\x12\x0b\n\x03uid\x18\x01 \x01(\t\x12\x0b\n\x03\x61ge\x18\x02 \x01(\x05\"_\n\x0bInvoiceItem\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0e\n\x06\x61mount\x18\x02 \x01(\x05\x12\x10\n\x08quantity\x18\x03 \x01(\x05\x12 \n\x05items\x18\x04 \x03(\x0b\x32\x11.user.InvoiceItem\"\x0e\n\x0c\x45mptyMessage\"\xa9\x02\n\x0fOptionalMessage\x12\x0b\n\x01x\x18\x01 \x01(\tH\x00\x12\x0b\n\x01y\x18\x02 \x01(\x05H\x00\x12\x11\n\x04name\x18\x03 \x01(\tH\x01\x88\x01\x01\x12\x10\n\x03\x61ge\x18\x04 \x01(\x05H\x02\x88\x01\x01\x12$\n\x04item\x18\x05 \x01(\x0b\x32\x11.user.InvoiceItemH\x03\x88\x01\x01\x12\x10\n\x08str_list\x18\x06 \x03(\t\x12\x32\n\x07int_map\x18\x07 \x03(\x0b\x32!.user.OptionalMessage.IntMapEntry\x12\x1d\n\x15\x64\x65\x66\x61ult_template_test\x18\x08 \x01(\x02\x1a-\n\x0bIntMapEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\x05:\x02\x38\x01\x42\x03\n\x01\x61\x42\x07\n\x05_nameB\x06\n\x04_ageB\x07\n\x05_item\"\x82\x01\n\x0cInvoiceItem2\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0e\n\x06\x61mount\x18\x02 \x01(\x05\x12\x10\n\x08quantity\x18\x03 \x01(\x05\x12!\n\x05items\x18\x04 \x03(\x0b\x32\x12.user.InvoiceItem2\x12\x1f\n\x07invoice\x18\x05 \x01(\x0b\x32\x0e.user.Invoice3\"]\n\x08Invoice3\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0e\n\x06\x61mount\x18\x02 \x01(\x05\x12\x10\n\x08quantity\x18\x03 \x01(\x05\x12!\n\x05items\x18\x04 \x03(\x0b\x32\x12.user.InvoiceItem2\"C\n\x0bRootMessage\x12\x0e\n\x06\x66ield1\x18\x01 \x01(\t\x12$\n\x06\x66ield2\x18\x02 \x01(\x0b\x32\x14.user.AnOtherMessage\"m\n\x0e\x41nOtherMessage\x12\x0e\n\x06\x66ield1\x18\x01 \x01(\t\x12/\n\x06\x66ield2\x18\x02 \x01(\x0b\x32\x1f.user.AnOtherMessage.SubMessage\x1a\x1a\n\nSubMessage\x12\x0c\n\x04text\x18\x01 \x01(\t\"\xc4\x01\n\rTestSameName0\x12&\n\x04\x62ody\x18\x01 \x01(\x0b\x32\x18.user.TestSameName0.Body\x1a\x8a\x01\n\x04\x42ody\x12\x13\n\x0binput_model\x18\x01 \x01(\t\x12;\n\ninput_info\x18\x03 \x03(\x0b\x32\'.user.TestSameName0.Body.InputInfoEntry\x1a\x30\n\x0eInputInfoEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01\"\xc8\x01\n\rTestSameName1\x12&\n\x04\x62ody\x18\x01 \x01(\x0b\x32\x18.user.TestSameName1.Body\x1a\x8e\x01\n\x04\x42ody\x12\x14\n\x0coutput_model\x18\x01 \x01(\t\x12=\n\x0boutput_info\x18\x03 \x03(\x0b\x32(.user.TestSameName1.Body.OutputInfoEntry\x1a\x31\n\x0fOutputInfoEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01*\x1d\n\x07SexType\x12\x07\n\x03man\x10\x00\x12\t\n\x05women\x10\x01\x62\x06proto3')
 
 _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals())
 _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'example.example_proto.demo.demo_pb2', globals())
@@ -36,8 +36,12 @@
   _NESTEDMESSAGE_USERMAPENTRY._serialized_options = b'8\001'
   _OPTIONALMESSAGE_INTMAPENTRY._options = None
   _OPTIONALMESSAGE_INTMAPENTRY._serialized_options = b'8\001'
-  _SEXTYPE._serialized_start=2486
-  _SEXTYPE._serialized_end=2515
+  _TESTSAMENAME0_BODY_INPUTINFOENTRY._options = None
+  _TESTSAMENAME0_BODY_INPUTINFOENTRY._serialized_options = b'8\001'
+  _TESTSAMENAME1_BODY_OUTPUTINFOENTRY._options = None
+  _TESTSAMENAME1_BODY_OUTPUTINFOENTRY._serialized_options = b'8\001'
+  _SEXTYPE._serialized_start=2888
+  _SEXTYPE._serialized_end=2917
   _USERMESSAGE._serialized_start=249
   _USERMESSAGE._serialized_end=444
   _OTHERMESSAGE._serialized_start=447
@@ -80,4 +84,16 @@
   _ANOTHERMESSAGE._serialized_end=2484
   _ANOTHERMESSAGE_SUBMESSAGE._serialized_start=2458
   _ANOTHERMESSAGE_SUBMESSAGE._serialized_end=2484
+  _TESTSAMENAME0._serialized_start=2487
+  _TESTSAMENAME0._serialized_end=2683
+  _TESTSAMENAME0_BODY._serialized_start=2545
+  _TESTSAMENAME0_BODY._serialized_end=2683
+  _TESTSAMENAME0_BODY_INPUTINFOENTRY._serialized_start=2635
+  _TESTSAMENAME0_BODY_INPUTINFOENTRY._serialized_end=2683
+  _TESTSAMENAME1._serialized_start=2686
+  _TESTSAMENAME1._serialized_end=2886
+  _TESTSAMENAME1_BODY._serialized_start=2744
+  _TESTSAMENAME1_BODY._serialized_end=2886
+  _TESTSAMENAME1_BODY_OUTPUTINFOENTRY._serialized_start=2837
+  _TESTSAMENAME1_BODY_OUTPUTINFOENTRY._serialized_end=2886
 # @@protoc_insertion_point(module_scope)
diff --git a/example/proto_pydanticv1/example/example_proto/demo/demo_pb2.pyi b/example/proto_pydanticv1/example/example_proto/demo/demo_pb2.pyi
index c5132f7..58bca7c 100644
--- a/example/proto_pydanticv1/example/example_proto/demo/demo_pb2.pyi
+++ b/example/proto_pydanticv1/example/example_proto/demo/demo_pb2.pyi
@@ -483,3 +483,86 @@ class AnOtherMessage(google.protobuf.message.Message):
     def HasField(self, field_name: typing_extensions.Literal["field2",b"field2"]) -> builtins.bool: ...
     def ClearField(self, field_name: typing_extensions.Literal["field1",b"field1","field2",b"field2"]) -> None: ...
 global___AnOtherMessage = AnOtherMessage
+
+class TestSameName0(google.protobuf.message.Message):
+    """Test inline structure of the same name
+    from: https://github.com/so1n/protobuf_to_pydantic/issues/76
+    """
+    DESCRIPTOR: google.protobuf.descriptor.Descriptor
+    class Body(google.protobuf.message.Message):
+        DESCRIPTOR: google.protobuf.descriptor.Descriptor
+        class InputInfoEntry(google.protobuf.message.Message):
+            DESCRIPTOR: google.protobuf.descriptor.Descriptor
+            KEY_FIELD_NUMBER: builtins.int
+            VALUE_FIELD_NUMBER: builtins.int
+            key: typing.Text
+            value: typing.Text
+            def __init__(self,
+                *,
+                key: typing.Text = ...,
+                value: typing.Text = ...,
+                ) -> None: ...
+            def ClearField(self, field_name: typing_extensions.Literal["key",b"key","value",b"value"]) -> None: ...
+
+        INPUT_MODEL_FIELD_NUMBER: builtins.int
+        INPUT_INFO_FIELD_NUMBER: builtins.int
+        input_model: typing.Text
+        @property
+        def input_info(self) -> google.protobuf.internal.containers.ScalarMap[typing.Text, typing.Text]: ...
+        def __init__(self,
+            *,
+            input_model: typing.Text = ...,
+            input_info: typing.Optional[typing.Mapping[typing.Text, typing.Text]] = ...,
+            ) -> None: ...
+        def ClearField(self, field_name: typing_extensions.Literal["input_info",b"input_info","input_model",b"input_model"]) -> None: ...
+
+    BODY_FIELD_NUMBER: builtins.int
+    @property
+    def body(self) -> global___TestSameName0.Body: ...
+    def __init__(self,
+        *,
+        body: typing.Optional[global___TestSameName0.Body] = ...,
+        ) -> None: ...
+    def HasField(self, field_name: typing_extensions.Literal["body",b"body"]) -> builtins.bool: ...
+    def ClearField(self, field_name: typing_extensions.Literal["body",b"body"]) -> None: ...
+global___TestSameName0 = TestSameName0
+
+class TestSameName1(google.protobuf.message.Message):
+    DESCRIPTOR: google.protobuf.descriptor.Descriptor
+    class Body(google.protobuf.message.Message):
+        DESCRIPTOR: google.protobuf.descriptor.Descriptor
+        class OutputInfoEntry(google.protobuf.message.Message):
+            DESCRIPTOR: google.protobuf.descriptor.Descriptor
+            KEY_FIELD_NUMBER: builtins.int
+            VALUE_FIELD_NUMBER: builtins.int
+            key: typing.Text
+            value: typing.Text
+            def __init__(self,
+                *,
+                key: typing.Text = ...,
+                value: typing.Text = ...,
+                ) -> None: ...
+            def ClearField(self, field_name: typing_extensions.Literal["key",b"key","value",b"value"]) -> None: ...
+
+        OUTPUT_MODEL_FIELD_NUMBER: builtins.int
+        OUTPUT_INFO_FIELD_NUMBER: builtins.int
+        output_model: typing.Text
+        @property
+        def output_info(self) -> google.protobuf.internal.containers.ScalarMap[typing.Text, typing.Text]: ...
+        def __init__(self,
+            *,
+            output_model: typing.Text = ...,
+            output_info: typing.Optional[typing.Mapping[typing.Text, typing.Text]] = ...,
+            ) -> None: ...
+        def ClearField(self, field_name: typing_extensions.Literal["output_info",b"output_info","output_model",b"output_model"]) -> None: ...
+
+    BODY_FIELD_NUMBER: builtins.int
+    @property
+    def body(self) -> global___TestSameName1.Body: ...
+    def __init__(self,
+        *,
+        body: typing.Optional[global___TestSameName1.Body] = ...,
+        ) -> None: ...
+    def HasField(self, field_name: typing_extensions.Literal["body",b"body"]) -> builtins.bool: ...
+    def ClearField(self, field_name: typing_extensions.Literal["body",b"body"]) -> None: ...
+global___TestSameName1 = TestSameName1
diff --git a/example/proto_pydanticv1/example/example_proto/demo/single_config_p2p.py b/example/proto_pydanticv1/example/example_proto/demo/single_config_p2p.py
index ad2b209..ff21dfc 100644
--- a/example/proto_pydanticv1/example/example_proto/demo/single_config_p2p.py
+++ b/example/proto_pydanticv1/example/example_proto/demo/single_config_p2p.py
@@ -1,5 +1,5 @@
 # This is an automatically generated file, please do not change
-# gen by protobuf_to_pydantic[v0.3.0](https://github.com/so1n/protobuf_to_pydantic)
+# gen by protobuf_to_pydantic[0.0.0](https://github.com/so1n/protobuf_to_pydantic)
 # Protobuf Version: 4.24.4
 # Pydantic Version: 1.10.7
 from google.protobuf.message import Message  # type: ignore
diff --git a/example/proto_pydanticv1/example/example_proto/p2p_validate/demo_p2p.py b/example/proto_pydanticv1/example/example_proto/p2p_validate/demo_p2p.py
index 36a7791..977bf34 100644
--- a/example/proto_pydanticv1/example/example_proto/p2p_validate/demo_p2p.py
+++ b/example/proto_pydanticv1/example/example_proto/p2p_validate/demo_p2p.py
@@ -1,5 +1,5 @@
 # This is an automatically generated file, please do not change
-# gen by protobuf_to_pydantic[v0.3.0](https://github.com/so1n/protobuf_to_pydantic)
+# gen by protobuf_to_pydantic[0.0.0](https://github.com/so1n/protobuf_to_pydantic)
 # Protobuf Version: 4.24.4
 # Pydantic Version: 1.10.7
 import typing
diff --git a/example/proto_pydanticv1/example/example_proto/p2p_validate_by_comment/demo_p2p.py b/example/proto_pydanticv1/example/example_proto/p2p_validate_by_comment/demo_p2p.py
index e97d0e3..0f34c27 100644
--- a/example/proto_pydanticv1/example/example_proto/p2p_validate_by_comment/demo_p2p.py
+++ b/example/proto_pydanticv1/example/example_proto/p2p_validate_by_comment/demo_p2p.py
@@ -1,5 +1,5 @@
 # This is an automatically generated file, please do not change
-# gen by protobuf_to_pydantic[v0.3.0](https://github.com/so1n/protobuf_to_pydantic)
+# gen by protobuf_to_pydantic[0.0.0](https://github.com/so1n/protobuf_to_pydantic)
 # Protobuf Version: 4.24.4
 # Pydantic Version: 1.10.7
 import typing
diff --git a/example/proto_pydanticv1/example/example_proto/p2p_validate_by_comment/demo_pb2_by_protobuf.py b/example/proto_pydanticv1/example/example_proto/p2p_validate_by_comment/demo_pb2_by_protobuf.py
index 7337c2f..0ee8281 100644
--- a/example/proto_pydanticv1/example/example_proto/p2p_validate_by_comment/demo_pb2_by_protobuf.py
+++ b/example/proto_pydanticv1/example/example_proto/p2p_validate_by_comment/demo_pb2_by_protobuf.py
@@ -1,5 +1,5 @@
 # This is an automatically generated file, please do not change
-# gen by protobuf_to_pydantic[v0.3.0](https://github.com/so1n/protobuf_to_pydantic)
+# gen by protobuf_to_pydantic[0.0.0](https://github.com/so1n/protobuf_to_pydantic)
 # Protobuf Version: 4.24.4
 # Pydantic Version: 1.10.7
 import typing
diff --git a/example/proto_pydanticv1/example/example_proto/p2p_validate_by_comment/demo_pb2_by_pyi.py b/example/proto_pydanticv1/example/example_proto/p2p_validate_by_comment/demo_pb2_by_pyi.py
index 7337c2f..0ee8281 100644
--- a/example/proto_pydanticv1/example/example_proto/p2p_validate_by_comment/demo_pb2_by_pyi.py
+++ b/example/proto_pydanticv1/example/example_proto/p2p_validate_by_comment/demo_pb2_by_pyi.py
@@ -1,5 +1,5 @@
 # This is an automatically generated file, please do not change
-# gen by protobuf_to_pydantic[v0.3.0](https://github.com/so1n/protobuf_to_pydantic)
+# gen by protobuf_to_pydantic[0.0.0](https://github.com/so1n/protobuf_to_pydantic)
 # Protobuf Version: 4.24.4
 # Pydantic Version: 1.10.7
 import typing
diff --git a/example/proto_pydanticv1/example/example_proto/validate/demo_p2p.py b/example/proto_pydanticv1/example/example_proto/validate/demo_p2p.py
index 8a1844c..2b307b7 100644
--- a/example/proto_pydanticv1/example/example_proto/validate/demo_p2p.py
+++ b/example/proto_pydanticv1/example/example_proto/validate/demo_p2p.py
@@ -1,5 +1,5 @@
 # This is an automatically generated file, please do not change
-# gen by protobuf_to_pydantic[v0.3.0](https://github.com/so1n/protobuf_to_pydantic)
+# gen by protobuf_to_pydantic[0.0.0](https://github.com/so1n/protobuf_to_pydantic)
 # Protobuf Version: 4.24.4
 # Pydantic Version: 1.10.7
 import typing
diff --git a/example/proto_pydanticv2/demo_gen_code.py b/example/proto_pydanticv2/demo_gen_code.py
index 1d4ce53..712357b 100644
--- a/example/proto_pydanticv2/demo_gen_code.py
+++ b/example/proto_pydanticv2/demo_gen_code.py
@@ -1,11 +1,47 @@
 # This is an automatically generated file, please do not change
-# gen by protobuf_to_pydantic[v0.3.0](https://github.com/so1n/protobuf_to_pydantic)
+# gen by protobuf_to_pydantic[0.0.0](https://github.com/so1n/protobuf_to_pydantic)
 # Protobuf Version: 4.24.4
 # Pydantic Version: 2.5.3
 import typing
+from datetime import datetime
+from enum import IntEnum
 
+from google.protobuf.field_mask_pb2 import FieldMask  # type: ignore
+from google.protobuf.wrappers_pb2 import DoubleValue  # type: ignore
 from protobuf_to_pydantic.customer_validator.v2 import check_one_of
-from pydantic import BaseModel, Field, model_validator
+from pydantic import BaseModel, ConfigDict, Field, model_validator
+
+
+class AfterReferMessage(BaseModel):
+    uid: str = Field(default="")
+    age: int = Field(default=0)
+
+
+class AnOtherMessage(BaseModel):
+    class SubMessage(BaseModel):
+        text: str = Field(default="")
+
+    field1: str = Field(default="")
+    field2: SubMessage = Field()
+
+
+class EmptyMessage(BaseModel):
+    pass
+
+
+class InvoiceItem2(BaseModel):
+    name: str = Field(default="")
+    amount: int = Field(default=0)
+    quantity: int = Field(default=0)
+    items: typing.List["InvoiceItem2"] = Field(default_factory=list)
+    invoice: "Invoice3" = Field()
+
+
+class Invoice3(BaseModel):
+    name: str = Field(default="")
+    amount: int = Field(default=0)
+    quantity: int = Field(default=0)
+    items: typing.List[InvoiceItem2] = Field(default_factory=list)
 
 
 class InvoiceItem(BaseModel):
@@ -15,6 +51,71 @@ class InvoiceItem(BaseModel):
     items: typing.List["InvoiceItem"] = Field(default_factory=list)
 
 
+class SexType(IntEnum):
+    man = 0
+    women = 1
+
+
+class ExampleExampleProtoCommonSingleDemoEnum(IntEnum):
+    """Note: The current class does not belong to the package
+    ExampleExampleProtoCommonSingleDemoEnum protobuf path:example/example_proto/common/single.proto"""
+
+    zero = 0
+    one = 1
+    two = 3
+
+
+class ExampleExampleProtoCommonSingleDemoMessage(BaseModel):
+    """Note: The current class does not belong to the package
+    ExampleExampleProtoCommonSingleDemoMessage protobuf path:example/example_proto/common/single.proto"""
+
+    earth: str = Field(default="")
+    mercury: str = Field(default="")
+    mars: str = Field(default="")
+
+
+class UserMessage(BaseModel):
+    uid: str = Field(default="")
+    age: int = Field(default=0)
+    height: float = Field(default=0.0)
+    sex: SexType = Field(default=0)
+    demo: ExampleExampleProtoCommonSingleDemoEnum = Field(default=0)
+    is_adult: bool = Field(default=False)
+    user_name: str = Field(default="")
+    demo_message: ExampleExampleProtoCommonSingleDemoMessage = Field()
+
+
+class MapMessage(BaseModel):
+    user_map: typing.Dict[str, UserMessage] = Field(default_factory=dict)
+    user_flag: typing.Dict[str, bool] = Field(default_factory=dict)
+
+
+class RepeatedMessage(BaseModel):
+    str_list: typing.List[str] = Field(default_factory=list)
+    int_list: typing.List[int] = Field(default_factory=list)
+    user_list: typing.List[UserMessage] = Field(default_factory=list)
+
+
+class NestedMessage(BaseModel):
+    class UserPayMessage(BaseModel):
+        bank_number: str = Field(default="")
+        exp: datetime = Field(default_factory=datetime.now)
+        uuid: str = Field(default="")
+
+    class IncludeEnum(IntEnum):
+        zero = 0
+        one = 1
+        two = 2
+
+    user_list_map: typing.Dict[str, RepeatedMessage] = Field(default_factory=dict)
+    user_map: typing.Dict[str, MapMessage] = Field(default_factory=dict)
+    user_pay: UserPayMessage = Field()
+    include_enum: IncludeEnum = Field(default=0)
+    not_enable_user_pay: UserPayMessage = Field()
+    empty: typing.Any = Field()
+    after_refer: AfterReferMessage = Field()
+
+
 class OptionalMessage(BaseModel):
     _one_of_dict = {"user.OptionalMessage.a": {"fields": {"x", "y"}, "required": False}}
 
@@ -28,3 +129,32 @@ class OptionalMessage(BaseModel):
     default_template_test: float = Field(default=0.0)
 
     one_of_validator = model_validator(mode="before")(check_one_of)
+
+
+class OtherMessage(BaseModel):
+    model_config = ConfigDict(arbitrary_types_allowed=True)
+
+    metadata: typing.Dict[str, typing.Any] = Field(default_factory=dict)
+    double_value: DoubleValue = Field(default_factory=DoubleValue)
+    field_mask: typing.Optional[FieldMask] = Field(default_factory=FieldMask)
+
+
+class RootMessage(BaseModel):
+    field1: str = Field(default="")
+    field2: AnOtherMessage = Field()
+
+
+class TestSameName0(BaseModel):
+    class Body(BaseModel):
+        input_model: str = Field(default="")
+        input_info: typing.Dict[str, str] = Field(default_factory=dict)
+
+    body: Body = Field()
+
+
+class TestSameName1(BaseModel):
+    class Body(BaseModel):
+        output_model: str = Field(default="")
+        output_info: typing.Dict[str, str] = Field(default_factory=dict)
+
+    body: Body = Field()
diff --git a/example/proto_pydanticv2/demo_gen_code_by_p2p.py b/example/proto_pydanticv2/demo_gen_code_by_p2p.py
index 7767166..5318f13 100644
--- a/example/proto_pydanticv2/demo_gen_code_by_p2p.py
+++ b/example/proto_pydanticv2/demo_gen_code_by_p2p.py
@@ -1,5 +1,5 @@
 # This is an automatically generated file, please do not change
-# gen by protobuf_to_pydantic[v0.3.0](https://github.com/so1n/protobuf_to_pydantic)
+# gen by protobuf_to_pydantic[0.0.0](https://github.com/so1n/protobuf_to_pydantic)
 # Protobuf Version: 4.24.4
 # Pydantic Version: 2.5.3
 import typing
diff --git a/example/proto_pydanticv2/demo_gen_code_by_pgv.py b/example/proto_pydanticv2/demo_gen_code_by_pgv.py
index c151691..5a33c27 100644
--- a/example/proto_pydanticv2/demo_gen_code_by_pgv.py
+++ b/example/proto_pydanticv2/demo_gen_code_by_pgv.py
@@ -1,5 +1,5 @@
 # This is an automatically generated file, please do not change
-# gen by protobuf_to_pydantic[v0.3.0](https://github.com/so1n/protobuf_to_pydantic)
+# gen by protobuf_to_pydantic[0.0.0](https://github.com/so1n/protobuf_to_pydantic)
 # Protobuf Version: 4.24.4
 # Pydantic Version: 2.5.3
 import typing
diff --git a/example/proto_pydanticv2/demo_gen_code_by_text_comment_protobuf_field.py b/example/proto_pydanticv2/demo_gen_code_by_text_comment_protobuf_field.py
index ae640c2..fef050f 100644
--- a/example/proto_pydanticv2/demo_gen_code_by_text_comment_protobuf_field.py
+++ b/example/proto_pydanticv2/demo_gen_code_by_text_comment_protobuf_field.py
@@ -1,5 +1,5 @@
 # This is an automatically generated file, please do not change
-# gen by protobuf_to_pydantic[v0.3.0](https://github.com/so1n/protobuf_to_pydantic)
+# gen by protobuf_to_pydantic[0.0.0](https://github.com/so1n/protobuf_to_pydantic)
 # Protobuf Version: 4.24.4
 # Pydantic Version: 2.5.3
 import typing
@@ -144,3 +144,19 @@ class OtherMessage(BaseModel):
 class RootMessage(BaseModel):
     field1: str = Field(default="")
     field2: AnOtherMessage = Field()
+
+
+class TestSameName0(BaseModel):
+    class Body(BaseModel):
+        input_model: str = Field(default="")
+        input_info: typing.Dict[str, str] = Field(default_factory=dict)
+
+    body: Body = Field()
+
+
+class TestSameName1(BaseModel):
+    class Body(BaseModel):
+        output_model: str = Field(default="")
+        output_info: typing.Dict[str, str] = Field(default_factory=dict)
+
+    body: Body = Field()
diff --git a/example/proto_pydanticv2/demo_gen_code_by_text_comment_pyi.py b/example/proto_pydanticv2/demo_gen_code_by_text_comment_pyi.py
index ae640c2..fef050f 100644
--- a/example/proto_pydanticv2/demo_gen_code_by_text_comment_pyi.py
+++ b/example/proto_pydanticv2/demo_gen_code_by_text_comment_pyi.py
@@ -1,5 +1,5 @@
 # This is an automatically generated file, please do not change
-# gen by protobuf_to_pydantic[v0.3.0](https://github.com/so1n/protobuf_to_pydantic)
+# gen by protobuf_to_pydantic[0.0.0](https://github.com/so1n/protobuf_to_pydantic)
 # Protobuf Version: 4.24.4
 # Pydantic Version: 2.5.3
 import typing
@@ -144,3 +144,19 @@ class OtherMessage(BaseModel):
 class RootMessage(BaseModel):
     field1: str = Field(default="")
     field2: AnOtherMessage = Field()
+
+
+class TestSameName0(BaseModel):
+    class Body(BaseModel):
+        input_model: str = Field(default="")
+        input_info: typing.Dict[str, str] = Field(default_factory=dict)
+
+    body: Body = Field()
+
+
+class TestSameName1(BaseModel):
+    class Body(BaseModel):
+        output_model: str = Field(default="")
+        output_info: typing.Dict[str, str] = Field(default_factory=dict)
+
+    body: Body = Field()
diff --git a/example/proto_pydanticv2/example/example_proto/common/single_p2p.py b/example/proto_pydanticv2/example/example_proto/common/single_p2p.py
index 9d65fd5..048017b 100644
--- a/example/proto_pydanticv2/example/example_proto/common/single_p2p.py
+++ b/example/proto_pydanticv2/example/example_proto/common/single_p2p.py
@@ -1,5 +1,5 @@
 # This is an automatically generated file, please do not change
-# gen by protobuf_to_pydantic[v0.3.0](https://github.com/so1n/protobuf_to_pydantic)
+# gen by protobuf_to_pydantic[0.0.0](https://github.com/so1n/protobuf_to_pydantic)
 # Protobuf Version: 4.24.4
 # Pydantic Version: 2.5.3
 from enum import IntEnum
diff --git a/example/proto_pydanticv2/example/example_proto/demo/alias_demo_p2p.py b/example/proto_pydanticv2/example/example_proto/demo/alias_demo_p2p.py
index cf0d147..e5780ac 100644
--- a/example/proto_pydanticv2/example/example_proto/demo/alias_demo_p2p.py
+++ b/example/proto_pydanticv2/example/example_proto/demo/alias_demo_p2p.py
@@ -1,5 +1,5 @@
 # This is an automatically generated file, please do not change
-# gen by protobuf_to_pydantic[v0.3.0](https://github.com/so1n/protobuf_to_pydantic)
+# gen by protobuf_to_pydantic[0.0.0](https://github.com/so1n/protobuf_to_pydantic)
 # Protobuf Version: 4.24.4
 # Pydantic Version: 2.5.3
 import typing
diff --git a/example/proto_pydanticv2/example/example_proto/demo/all_feidl_set_optional_demo_p2p.py b/example/proto_pydanticv2/example/example_proto/demo/all_feidl_set_optional_demo_p2p.py
index 851b670..37eb667 100644
--- a/example/proto_pydanticv2/example/example_proto/demo/all_feidl_set_optional_demo_p2p.py
+++ b/example/proto_pydanticv2/example/example_proto/demo/all_feidl_set_optional_demo_p2p.py
@@ -1,5 +1,5 @@
 # This is an automatically generated file, please do not change
-# gen by protobuf_to_pydantic[v0.3.0](https://github.com/so1n/protobuf_to_pydantic)
+# gen by protobuf_to_pydantic[0.0.0](https://github.com/so1n/protobuf_to_pydantic)
 # Protobuf Version: 4.24.4
 # Pydantic Version: 2.5.3
 import typing
diff --git a/example/proto_pydanticv2/example/example_proto/demo/demo_p2p.py b/example/proto_pydanticv2/example/example_proto/demo/demo_p2p.py
index 9375bb3..4d3b8a8 100644
--- a/example/proto_pydanticv2/example/example_proto/demo/demo_p2p.py
+++ b/example/proto_pydanticv2/example/example_proto/demo/demo_p2p.py
@@ -1,5 +1,5 @@
 # This is an automatically generated file, please do not change
-# gen by protobuf_to_pydantic[v0.3.0](https://github.com/so1n/protobuf_to_pydantic)
+# gen by protobuf_to_pydantic[0.0.0](https://github.com/so1n/protobuf_to_pydantic)
 # Protobuf Version: 4.24.4
 # Pydantic Version: 2.5.3
 import typing
@@ -158,3 +158,24 @@ class RootMessage(BaseModel):
 
     field1: str = Field(default="")
     field2: AnOtherMessage = Field()
+
+
+class TestSameName0(BaseModel):
+    """
+        Test inline structure of the same name
+    from: https://github.com/so1n/protobuf_to_pydantic/issues/76
+    """
+
+    class Body(BaseModel):
+        input_model: str = Field(default="")
+        input_info: typing.Dict[str, str] = Field(default_factory=dict)
+
+    body: "TestSameName0.Body" = Field()
+
+
+class TestSameName1(BaseModel):
+    class Body(BaseModel):
+        output_model: str = Field(default="")
+        output_info: typing.Dict[str, str] = Field(default_factory=dict)
+
+    body: "TestSameName1.Body" = Field()
diff --git a/example/proto_pydanticv2/example/example_proto/demo/demo_pb2.py b/example/proto_pydanticv2/example/example_proto/demo/demo_pb2.py
index 364406c..b2a2275 100644
--- a/example/proto_pydanticv2/example/example_proto/demo/demo_pb2.py
+++ b/example/proto_pydanticv2/example/example_proto/demo/demo_pb2.py
@@ -19,7 +19,7 @@
 from example.proto_pydanticv2.example.example_proto.common import single_pb2 as example_dot_example__proto_dot_common_dot_single__pb2
 
 
-DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n%example/example_proto/demo/demo.proto\x12\x04user\x1a\x1bgoogle/protobuf/empty.proto\x1a\x1fgoogle/protobuf/timestamp.proto\x1a\x1cgoogle/protobuf/struct.proto\x1a google/protobuf/field_mask.proto\x1a\x1egoogle/protobuf/wrappers.proto\x1a)example/example_proto/common/single.proto\"\xc3\x01\n\x0bUserMessage\x12\x0b\n\x03uid\x18\x01 \x01(\t\x12\x0b\n\x03\x61ge\x18\x02 \x01(\x05\x12\x0e\n\x06height\x18\x03 \x01(\x02\x12\x1a\n\x03sex\x18\x04 \x01(\x0e\x32\r.user.SexType\x12\x1e\n\x04\x64\x65mo\x18\x06 \x01(\x0e\x32\x10.single.DemoEnum\x12\x10\n\x08is_adult\x18\x07 \x01(\x08\x12\x11\n\tuser_name\x18\x08 \x01(\t\x12)\n\x0c\x64\x65mo_message\x18\t \x01(\x0b\x32\x13.single.DemoMessage\"\xb1\x01\n\x0cOtherMessage\x12)\n\x08metadata\x18\x01 \x01(\x0b\x32\x17.google.protobuf.Struct\x12\x32\n\x0c\x64ouble_value\x18\x02 \x01(\x0b\x32\x1c.google.protobuf.DoubleValue\x12\x33\n\nfield_mask\x18\x64 \x01(\x0b\x32\x1a.google.protobuf.FieldMaskH\x00\x88\x01\x01\x42\r\n\x0b_field_mask\"\xe4\x01\n\nMapMessage\x12/\n\x08user_map\x18\x01 \x03(\x0b\x32\x1d.user.MapMessage.UserMapEntry\x12\x31\n\tuser_flag\x18\x02 \x03(\x0b\x32\x1e.user.MapMessage.UserFlagEntry\x1a\x41\n\x0cUserMapEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12 \n\x05value\x18\x02 \x01(\x0b\x32\x11.user.UserMessage:\x02\x38\x01\x1a/\n\rUserFlagEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\x08:\x02\x38\x01\"[\n\x0fRepeatedMessage\x12\x10\n\x08str_list\x18\x01 \x03(\t\x12\x10\n\x08int_list\x18\x02 \x03(\x05\x12$\n\tuser_list\x18\x03 \x03(\x0b\x32\x11.user.UserMessage\"\x99\x05\n\rNestedMessage\x12;\n\ruser_list_map\x18\x01 \x03(\x0b\x32$.user.NestedMessage.UserListMapEntry\x12\x32\n\x08user_map\x18\x02 \x03(\x0b\x32 .user.NestedMessage.UserMapEntry\x12\x34\n\x08user_pay\x18\x03 \x01(\x0b\x32\".user.NestedMessage.UserPayMessage\x12\x35\n\x0cinclude_enum\x18\x04 \x01(\x0e\x32\x1f.user.NestedMessage.IncludeEnum\x12?\n\x13not_enable_user_pay\x18\x05 \x01(\x0b\x32\".user.NestedMessage.UserPayMessage\x12%\n\x05\x65mpty\x18\x06 \x01(\x0b\x32\x16.google.protobuf.Empty\x12,\n\x0b\x61\x66ter_refer\x18\x07 \x01(\x0b\x32\x17.user.AfterReferMessage\x1a\\\n\x0eUserPayMessage\x12\x13\n\x0b\x62\x61nk_number\x18\x01 \x01(\t\x12\'\n\x03\x65xp\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x0c\n\x04uuid\x18\x03 \x01(\t\x1aI\n\x10UserListMapEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12$\n\x05value\x18\x02 \x01(\x0b\x32\x15.user.RepeatedMessage:\x02\x38\x01\x1a@\n\x0cUserMapEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\x1f\n\x05value\x18\x02 \x01(\x0b\x32\x10.user.MapMessage:\x02\x38\x01\")\n\x0bIncludeEnum\x12\x08\n\x04zero\x10\x00\x12\x07\n\x03one\x10\x01\x12\x07\n\x03two\x10\x02\"-\n\x11\x41\x66terReferMessage\x12\x0b\n\x03uid\x18\x01 \x01(\t\x12\x0b\n\x03\x61ge\x18\x02 \x01(\x05\"_\n\x0bInvoiceItem\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0e\n\x06\x61mount\x18\x02 \x01(\x05\x12\x10\n\x08quantity\x18\x03 \x01(\x05\x12 \n\x05items\x18\x04 \x03(\x0b\x32\x11.user.InvoiceItem\"\x0e\n\x0c\x45mptyMessage\"\xa9\x02\n\x0fOptionalMessage\x12\x0b\n\x01x\x18\x01 \x01(\tH\x00\x12\x0b\n\x01y\x18\x02 \x01(\x05H\x00\x12\x11\n\x04name\x18\x03 \x01(\tH\x01\x88\x01\x01\x12\x10\n\x03\x61ge\x18\x04 \x01(\x05H\x02\x88\x01\x01\x12$\n\x04item\x18\x05 \x01(\x0b\x32\x11.user.InvoiceItemH\x03\x88\x01\x01\x12\x10\n\x08str_list\x18\x06 \x03(\t\x12\x32\n\x07int_map\x18\x07 \x03(\x0b\x32!.user.OptionalMessage.IntMapEntry\x12\x1d\n\x15\x64\x65\x66\x61ult_template_test\x18\x08 \x01(\x02\x1a-\n\x0bIntMapEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\x05:\x02\x38\x01\x42\x03\n\x01\x61\x42\x07\n\x05_nameB\x06\n\x04_ageB\x07\n\x05_item\"\x82\x01\n\x0cInvoiceItem2\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0e\n\x06\x61mount\x18\x02 \x01(\x05\x12\x10\n\x08quantity\x18\x03 \x01(\x05\x12!\n\x05items\x18\x04 \x03(\x0b\x32\x12.user.InvoiceItem2\x12\x1f\n\x07invoice\x18\x05 \x01(\x0b\x32\x0e.user.Invoice3\"]\n\x08Invoice3\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0e\n\x06\x61mount\x18\x02 \x01(\x05\x12\x10\n\x08quantity\x18\x03 \x01(\x05\x12!\n\x05items\x18\x04 \x03(\x0b\x32\x12.user.InvoiceItem2\"C\n\x0bRootMessage\x12\x0e\n\x06\x66ield1\x18\x01 \x01(\t\x12$\n\x06\x66ield2\x18\x02 \x01(\x0b\x32\x14.user.AnOtherMessage\"m\n\x0e\x41nOtherMessage\x12\x0e\n\x06\x66ield1\x18\x01 \x01(\t\x12/\n\x06\x66ield2\x18\x02 \x01(\x0b\x32\x1f.user.AnOtherMessage.SubMessage\x1a\x1a\n\nSubMessage\x12\x0c\n\x04text\x18\x01 \x01(\t*\x1d\n\x07SexType\x12\x07\n\x03man\x10\x00\x12\t\n\x05women\x10\x01\x62\x06proto3')
+DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n%example/example_proto/demo/demo.proto\x12\x04user\x1a\x1bgoogle/protobuf/empty.proto\x1a\x1fgoogle/protobuf/timestamp.proto\x1a\x1cgoogle/protobuf/struct.proto\x1a google/protobuf/field_mask.proto\x1a\x1egoogle/protobuf/wrappers.proto\x1a)example/example_proto/common/single.proto\"\xc3\x01\n\x0bUserMessage\x12\x0b\n\x03uid\x18\x01 \x01(\t\x12\x0b\n\x03\x61ge\x18\x02 \x01(\x05\x12\x0e\n\x06height\x18\x03 \x01(\x02\x12\x1a\n\x03sex\x18\x04 \x01(\x0e\x32\r.user.SexType\x12\x1e\n\x04\x64\x65mo\x18\x06 \x01(\x0e\x32\x10.single.DemoEnum\x12\x10\n\x08is_adult\x18\x07 \x01(\x08\x12\x11\n\tuser_name\x18\x08 \x01(\t\x12)\n\x0c\x64\x65mo_message\x18\t \x01(\x0b\x32\x13.single.DemoMessage\"\xb1\x01\n\x0cOtherMessage\x12)\n\x08metadata\x18\x01 \x01(\x0b\x32\x17.google.protobuf.Struct\x12\x32\n\x0c\x64ouble_value\x18\x02 \x01(\x0b\x32\x1c.google.protobuf.DoubleValue\x12\x33\n\nfield_mask\x18\x64 \x01(\x0b\x32\x1a.google.protobuf.FieldMaskH\x00\x88\x01\x01\x42\r\n\x0b_field_mask\"\xe4\x01\n\nMapMessage\x12/\n\x08user_map\x18\x01 \x03(\x0b\x32\x1d.user.MapMessage.UserMapEntry\x12\x31\n\tuser_flag\x18\x02 \x03(\x0b\x32\x1e.user.MapMessage.UserFlagEntry\x1a\x41\n\x0cUserMapEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12 \n\x05value\x18\x02 \x01(\x0b\x32\x11.user.UserMessage:\x02\x38\x01\x1a/\n\rUserFlagEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\x08:\x02\x38\x01\"[\n\x0fRepeatedMessage\x12\x10\n\x08str_list\x18\x01 \x03(\t\x12\x10\n\x08int_list\x18\x02 \x03(\x05\x12$\n\tuser_list\x18\x03 \x03(\x0b\x32\x11.user.UserMessage\"\x99\x05\n\rNestedMessage\x12;\n\ruser_list_map\x18\x01 \x03(\x0b\x32$.user.NestedMessage.UserListMapEntry\x12\x32\n\x08user_map\x18\x02 \x03(\x0b\x32 .user.NestedMessage.UserMapEntry\x12\x34\n\x08user_pay\x18\x03 \x01(\x0b\x32\".user.NestedMessage.UserPayMessage\x12\x35\n\x0cinclude_enum\x18\x04 \x01(\x0e\x32\x1f.user.NestedMessage.IncludeEnum\x12?\n\x13not_enable_user_pay\x18\x05 \x01(\x0b\x32\".user.NestedMessage.UserPayMessage\x12%\n\x05\x65mpty\x18\x06 \x01(\x0b\x32\x16.google.protobuf.Empty\x12,\n\x0b\x61\x66ter_refer\x18\x07 \x01(\x0b\x32\x17.user.AfterReferMessage\x1a\\\n\x0eUserPayMessage\x12\x13\n\x0b\x62\x61nk_number\x18\x01 \x01(\t\x12\'\n\x03\x65xp\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x0c\n\x04uuid\x18\x03 \x01(\t\x1aI\n\x10UserListMapEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12$\n\x05value\x18\x02 \x01(\x0b\x32\x15.user.RepeatedMessage:\x02\x38\x01\x1a@\n\x0cUserMapEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\x1f\n\x05value\x18\x02 \x01(\x0b\x32\x10.user.MapMessage:\x02\x38\x01\")\n\x0bIncludeEnum\x12\x08\n\x04zero\x10\x00\x12\x07\n\x03one\x10\x01\x12\x07\n\x03two\x10\x02\"-\n\x11\x41\x66terReferMessage\x12\x0b\n\x03uid\x18\x01 \x01(\t\x12\x0b\n\x03\x61ge\x18\x02 \x01(\x05\"_\n\x0bInvoiceItem\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0e\n\x06\x61mount\x18\x02 \x01(\x05\x12\x10\n\x08quantity\x18\x03 \x01(\x05\x12 \n\x05items\x18\x04 \x03(\x0b\x32\x11.user.InvoiceItem\"\x0e\n\x0c\x45mptyMessage\"\xa9\x02\n\x0fOptionalMessage\x12\x0b\n\x01x\x18\x01 \x01(\tH\x00\x12\x0b\n\x01y\x18\x02 \x01(\x05H\x00\x12\x11\n\x04name\x18\x03 \x01(\tH\x01\x88\x01\x01\x12\x10\n\x03\x61ge\x18\x04 \x01(\x05H\x02\x88\x01\x01\x12$\n\x04item\x18\x05 \x01(\x0b\x32\x11.user.InvoiceItemH\x03\x88\x01\x01\x12\x10\n\x08str_list\x18\x06 \x03(\t\x12\x32\n\x07int_map\x18\x07 \x03(\x0b\x32!.user.OptionalMessage.IntMapEntry\x12\x1d\n\x15\x64\x65\x66\x61ult_template_test\x18\x08 \x01(\x02\x1a-\n\x0bIntMapEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\x05:\x02\x38\x01\x42\x03\n\x01\x61\x42\x07\n\x05_nameB\x06\n\x04_ageB\x07\n\x05_item\"\x82\x01\n\x0cInvoiceItem2\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0e\n\x06\x61mount\x18\x02 \x01(\x05\x12\x10\n\x08quantity\x18\x03 \x01(\x05\x12!\n\x05items\x18\x04 \x03(\x0b\x32\x12.user.InvoiceItem2\x12\x1f\n\x07invoice\x18\x05 \x01(\x0b\x32\x0e.user.Invoice3\"]\n\x08Invoice3\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0e\n\x06\x61mount\x18\x02 \x01(\x05\x12\x10\n\x08quantity\x18\x03 \x01(\x05\x12!\n\x05items\x18\x04 \x03(\x0b\x32\x12.user.InvoiceItem2\"C\n\x0bRootMessage\x12\x0e\n\x06\x66ield1\x18\x01 \x01(\t\x12$\n\x06\x66ield2\x18\x02 \x01(\x0b\x32\x14.user.AnOtherMessage\"m\n\x0e\x41nOtherMessage\x12\x0e\n\x06\x66ield1\x18\x01 \x01(\t\x12/\n\x06\x66ield2\x18\x02 \x01(\x0b\x32\x1f.user.AnOtherMessage.SubMessage\x1a\x1a\n\nSubMessage\x12\x0c\n\x04text\x18\x01 \x01(\t\"\xc4\x01\n\rTestSameName0\x12&\n\x04\x62ody\x18\x01 \x01(\x0b\x32\x18.user.TestSameName0.Body\x1a\x8a\x01\n\x04\x42ody\x12\x13\n\x0binput_model\x18\x01 \x01(\t\x12;\n\ninput_info\x18\x03 \x03(\x0b\x32\'.user.TestSameName0.Body.InputInfoEntry\x1a\x30\n\x0eInputInfoEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01\"\xc8\x01\n\rTestSameName1\x12&\n\x04\x62ody\x18\x01 \x01(\x0b\x32\x18.user.TestSameName1.Body\x1a\x8e\x01\n\x04\x42ody\x12\x14\n\x0coutput_model\x18\x01 \x01(\t\x12=\n\x0boutput_info\x18\x03 \x03(\x0b\x32(.user.TestSameName1.Body.OutputInfoEntry\x1a\x31\n\x0fOutputInfoEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01*\x1d\n\x07SexType\x12\x07\n\x03man\x10\x00\x12\t\n\x05women\x10\x01\x62\x06proto3')
 
 _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals())
 _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'example.example_proto.demo.demo_pb2', globals())
@@ -36,8 +36,12 @@
   _NESTEDMESSAGE_USERMAPENTRY._serialized_options = b'8\001'
   _OPTIONALMESSAGE_INTMAPENTRY._options = None
   _OPTIONALMESSAGE_INTMAPENTRY._serialized_options = b'8\001'
-  _SEXTYPE._serialized_start=2486
-  _SEXTYPE._serialized_end=2515
+  _TESTSAMENAME0_BODY_INPUTINFOENTRY._options = None
+  _TESTSAMENAME0_BODY_INPUTINFOENTRY._serialized_options = b'8\001'
+  _TESTSAMENAME1_BODY_OUTPUTINFOENTRY._options = None
+  _TESTSAMENAME1_BODY_OUTPUTINFOENTRY._serialized_options = b'8\001'
+  _SEXTYPE._serialized_start=2888
+  _SEXTYPE._serialized_end=2917
   _USERMESSAGE._serialized_start=249
   _USERMESSAGE._serialized_end=444
   _OTHERMESSAGE._serialized_start=447
@@ -80,4 +84,16 @@
   _ANOTHERMESSAGE._serialized_end=2484
   _ANOTHERMESSAGE_SUBMESSAGE._serialized_start=2458
   _ANOTHERMESSAGE_SUBMESSAGE._serialized_end=2484
+  _TESTSAMENAME0._serialized_start=2487
+  _TESTSAMENAME0._serialized_end=2683
+  _TESTSAMENAME0_BODY._serialized_start=2545
+  _TESTSAMENAME0_BODY._serialized_end=2683
+  _TESTSAMENAME0_BODY_INPUTINFOENTRY._serialized_start=2635
+  _TESTSAMENAME0_BODY_INPUTINFOENTRY._serialized_end=2683
+  _TESTSAMENAME1._serialized_start=2686
+  _TESTSAMENAME1._serialized_end=2886
+  _TESTSAMENAME1_BODY._serialized_start=2744
+  _TESTSAMENAME1_BODY._serialized_end=2886
+  _TESTSAMENAME1_BODY_OUTPUTINFOENTRY._serialized_start=2837
+  _TESTSAMENAME1_BODY_OUTPUTINFOENTRY._serialized_end=2886
 # @@protoc_insertion_point(module_scope)
diff --git a/example/proto_pydanticv2/example/example_proto/demo/demo_pb2.pyi b/example/proto_pydanticv2/example/example_proto/demo/demo_pb2.pyi
index c5132f7..58bca7c 100644
--- a/example/proto_pydanticv2/example/example_proto/demo/demo_pb2.pyi
+++ b/example/proto_pydanticv2/example/example_proto/demo/demo_pb2.pyi
@@ -483,3 +483,86 @@ class AnOtherMessage(google.protobuf.message.Message):
     def HasField(self, field_name: typing_extensions.Literal["field2",b"field2"]) -> builtins.bool: ...
     def ClearField(self, field_name: typing_extensions.Literal["field1",b"field1","field2",b"field2"]) -> None: ...
 global___AnOtherMessage = AnOtherMessage
+
+class TestSameName0(google.protobuf.message.Message):
+    """Test inline structure of the same name
+    from: https://github.com/so1n/protobuf_to_pydantic/issues/76
+    """
+    DESCRIPTOR: google.protobuf.descriptor.Descriptor
+    class Body(google.protobuf.message.Message):
+        DESCRIPTOR: google.protobuf.descriptor.Descriptor
+        class InputInfoEntry(google.protobuf.message.Message):
+            DESCRIPTOR: google.protobuf.descriptor.Descriptor
+            KEY_FIELD_NUMBER: builtins.int
+            VALUE_FIELD_NUMBER: builtins.int
+            key: typing.Text
+            value: typing.Text
+            def __init__(self,
+                *,
+                key: typing.Text = ...,
+                value: typing.Text = ...,
+                ) -> None: ...
+            def ClearField(self, field_name: typing_extensions.Literal["key",b"key","value",b"value"]) -> None: ...
+
+        INPUT_MODEL_FIELD_NUMBER: builtins.int
+        INPUT_INFO_FIELD_NUMBER: builtins.int
+        input_model: typing.Text
+        @property
+        def input_info(self) -> google.protobuf.internal.containers.ScalarMap[typing.Text, typing.Text]: ...
+        def __init__(self,
+            *,
+            input_model: typing.Text = ...,
+            input_info: typing.Optional[typing.Mapping[typing.Text, typing.Text]] = ...,
+            ) -> None: ...
+        def ClearField(self, field_name: typing_extensions.Literal["input_info",b"input_info","input_model",b"input_model"]) -> None: ...
+
+    BODY_FIELD_NUMBER: builtins.int
+    @property
+    def body(self) -> global___TestSameName0.Body: ...
+    def __init__(self,
+        *,
+        body: typing.Optional[global___TestSameName0.Body] = ...,
+        ) -> None: ...
+    def HasField(self, field_name: typing_extensions.Literal["body",b"body"]) -> builtins.bool: ...
+    def ClearField(self, field_name: typing_extensions.Literal["body",b"body"]) -> None: ...
+global___TestSameName0 = TestSameName0
+
+class TestSameName1(google.protobuf.message.Message):
+    DESCRIPTOR: google.protobuf.descriptor.Descriptor
+    class Body(google.protobuf.message.Message):
+        DESCRIPTOR: google.protobuf.descriptor.Descriptor
+        class OutputInfoEntry(google.protobuf.message.Message):
+            DESCRIPTOR: google.protobuf.descriptor.Descriptor
+            KEY_FIELD_NUMBER: builtins.int
+            VALUE_FIELD_NUMBER: builtins.int
+            key: typing.Text
+            value: typing.Text
+            def __init__(self,
+                *,
+                key: typing.Text = ...,
+                value: typing.Text = ...,
+                ) -> None: ...
+            def ClearField(self, field_name: typing_extensions.Literal["key",b"key","value",b"value"]) -> None: ...
+
+        OUTPUT_MODEL_FIELD_NUMBER: builtins.int
+        OUTPUT_INFO_FIELD_NUMBER: builtins.int
+        output_model: typing.Text
+        @property
+        def output_info(self) -> google.protobuf.internal.containers.ScalarMap[typing.Text, typing.Text]: ...
+        def __init__(self,
+            *,
+            output_model: typing.Text = ...,
+            output_info: typing.Optional[typing.Mapping[typing.Text, typing.Text]] = ...,
+            ) -> None: ...
+        def ClearField(self, field_name: typing_extensions.Literal["output_info",b"output_info","output_model",b"output_model"]) -> None: ...
+
+    BODY_FIELD_NUMBER: builtins.int
+    @property
+    def body(self) -> global___TestSameName1.Body: ...
+    def __init__(self,
+        *,
+        body: typing.Optional[global___TestSameName1.Body] = ...,
+        ) -> None: ...
+    def HasField(self, field_name: typing_extensions.Literal["body",b"body"]) -> builtins.bool: ...
+    def ClearField(self, field_name: typing_extensions.Literal["body",b"body"]) -> None: ...
+global___TestSameName1 = TestSameName1
diff --git a/example/proto_pydanticv2/example/example_proto/demo/single_config_p2p.py b/example/proto_pydanticv2/example/example_proto/demo/single_config_p2p.py
index 7d63638..206bd9f 100644
--- a/example/proto_pydanticv2/example/example_proto/demo/single_config_p2p.py
+++ b/example/proto_pydanticv2/example/example_proto/demo/single_config_p2p.py
@@ -1,5 +1,5 @@
 # This is an automatically generated file, please do not change
-# gen by protobuf_to_pydantic[v0.3.0](https://github.com/so1n/protobuf_to_pydantic)
+# gen by protobuf_to_pydantic[0.0.0](https://github.com/so1n/protobuf_to_pydantic)
 # Protobuf Version: 4.24.4
 # Pydantic Version: 2.5.3
 from google.protobuf.message import Message  # type: ignore
diff --git a/example/proto_pydanticv2/example/example_proto/p2p_validate/demo_p2p.py b/example/proto_pydanticv2/example/example_proto/p2p_validate/demo_p2p.py
index c3fc2b4..e726c56 100644
--- a/example/proto_pydanticv2/example/example_proto/p2p_validate/demo_p2p.py
+++ b/example/proto_pydanticv2/example/example_proto/p2p_validate/demo_p2p.py
@@ -1,5 +1,5 @@
 # This is an automatically generated file, please do not change
-# gen by protobuf_to_pydantic[v0.3.0](https://github.com/so1n/protobuf_to_pydantic)
+# gen by protobuf_to_pydantic[0.0.0](https://github.com/so1n/protobuf_to_pydantic)
 # Protobuf Version: 4.24.4
 # Pydantic Version: 2.5.3
 import typing
diff --git a/example/proto_pydanticv2/example/example_proto/p2p_validate_by_comment/demo_p2p.py b/example/proto_pydanticv2/example/example_proto/p2p_validate_by_comment/demo_p2p.py
index d47b97b..bd185d6 100644
--- a/example/proto_pydanticv2/example/example_proto/p2p_validate_by_comment/demo_p2p.py
+++ b/example/proto_pydanticv2/example/example_proto/p2p_validate_by_comment/demo_p2p.py
@@ -1,5 +1,5 @@
 # This is an automatically generated file, please do not change
-# gen by protobuf_to_pydantic[v0.3.0](https://github.com/so1n/protobuf_to_pydantic)
+# gen by protobuf_to_pydantic[0.0.0](https://github.com/so1n/protobuf_to_pydantic)
 # Protobuf Version: 4.24.4
 # Pydantic Version: 2.5.3
 import typing
diff --git a/example/proto_pydanticv2/example/example_proto/p2p_validate_by_comment/demo_pb2_by_protobuf.py b/example/proto_pydanticv2/example/example_proto/p2p_validate_by_comment/demo_pb2_by_protobuf.py
index 9069134..a768e44 100644
--- a/example/proto_pydanticv2/example/example_proto/p2p_validate_by_comment/demo_pb2_by_protobuf.py
+++ b/example/proto_pydanticv2/example/example_proto/p2p_validate_by_comment/demo_pb2_by_protobuf.py
@@ -1,5 +1,5 @@
 # This is an automatically generated file, please do not change
-# gen by protobuf_to_pydantic[v0.3.0](https://github.com/so1n/protobuf_to_pydantic)
+# gen by protobuf_to_pydantic[0.0.0](https://github.com/so1n/protobuf_to_pydantic)
 # Protobuf Version: 4.24.4
 # Pydantic Version: 2.5.3
 import typing
diff --git a/example/proto_pydanticv2/example/example_proto/p2p_validate_by_comment/demo_pb2_by_pyi.py b/example/proto_pydanticv2/example/example_proto/p2p_validate_by_comment/demo_pb2_by_pyi.py
index 9069134..a768e44 100644
--- a/example/proto_pydanticv2/example/example_proto/p2p_validate_by_comment/demo_pb2_by_pyi.py
+++ b/example/proto_pydanticv2/example/example_proto/p2p_validate_by_comment/demo_pb2_by_pyi.py
@@ -1,5 +1,5 @@
 # This is an automatically generated file, please do not change
-# gen by protobuf_to_pydantic[v0.3.0](https://github.com/so1n/protobuf_to_pydantic)
+# gen by protobuf_to_pydantic[0.0.0](https://github.com/so1n/protobuf_to_pydantic)
 # Protobuf Version: 4.24.4
 # Pydantic Version: 2.5.3
 import typing
diff --git a/example/proto_pydanticv2/example/example_proto/validate/demo_p2p.py b/example/proto_pydanticv2/example/example_proto/validate/demo_p2p.py
index cfd3521..67c0d7a 100644
--- a/example/proto_pydanticv2/example/example_proto/validate/demo_p2p.py
+++ b/example/proto_pydanticv2/example/example_proto/validate/demo_p2p.py
@@ -1,5 +1,5 @@
 # This is an automatically generated file, please do not change
-# gen by protobuf_to_pydantic[v0.3.0](https://github.com/so1n/protobuf_to_pydantic)
+# gen by protobuf_to_pydantic[0.0.0](https://github.com/so1n/protobuf_to_pydantic)
 # Protobuf Version: 4.24.4
 # Pydantic Version: 2.5.3
 import typing
diff --git a/protobuf_to_pydantic/plugin/field_desc_proto_to_code.py b/protobuf_to_pydantic/plugin/field_desc_proto_to_code.py
index c8e4d20..c55d174 100644
--- a/protobuf_to_pydantic/plugin/field_desc_proto_to_code.py
+++ b/protobuf_to_pydantic/plugin/field_desc_proto_to_code.py
@@ -78,6 +78,7 @@ def __init__(self, fd: FileDescriptorProto, descriptors: Descriptors, config: "C
         self._fd = fd
         self._descriptors = descriptors
         self._desc_template = config.template_instance
+        self._fd_root_desc_dict = {m.name: m for m in self._fd.message_type}
         self.source_code_info_by_scl = {tuple(location.path): location for location in fd.source_code_info.location}
 
         if config.base_model_class is BaseModel:
@@ -196,6 +197,7 @@ def _message_nested_type_handle(
         scl_prefix: SourceCodeLocation,
         indent: int,
         nested_message_config_dict: dict,
+        this_level_model_cache: Dict[str, str],
         skip_validate_rule: bool,
     ) -> List[str]:
         """Parse the nested information of Message"""
@@ -209,10 +211,11 @@ def _message_nested_type_handle(
             )
             content_list.append(
                 self._message(
-                    nested_message,
-                    desc,
-                    scl_prefix + [index],
-                    indent + self.code_indent,
+                    desc=nested_message,
+                    root_desc=desc,
+                    scl_prefix=scl_prefix + [index],
+                    sub_model_cache=this_level_model_cache,
+                    indent=indent + self.code_indent,
                     skip_validate_rule=skip_validate_rule,
                 )
             )
@@ -221,6 +224,7 @@ def _message_nested_type_handle(
     # flake8: noqa: C901
     def _message_field_handle(
         self,
+        *,
         desc: DescriptorProto,
         root_desc: DescriptorProto,
         field: FieldDescriptorProto,
@@ -229,6 +233,7 @@ def _message_field_handle(
         optional_dict: dict,
         one_of_dict: Dict[str, OneOfTypedDict],
         scl_prefix: SourceCodeLocation,
+        this_level_model_cache: Dict[str, str],
         skip_validate_rule: bool = False,
     ) -> Optional[Tuple[str, str, bool]]:
         """generate message's field to Pydantic.FieldInfo code
@@ -308,7 +313,14 @@ def _message_field_handle(
                         if desc is message:
                             scl_prefix = [FileDescriptorProto.MESSAGE_TYPE_FIELD_NUMBER, index]
                     try:
-                        self._content_deque.append(self._message(message, root_desc, scl_prefix))
+                        self._content_deque.append(
+                            self._message(
+                                desc=message,
+                                root_desc=root_desc,
+                                scl_prefix=scl_prefix,
+                                sub_model_cache=this_level_model_cache,
+                            )
+                        )
                     except WaitingToCompleteException:
                         type_str = f'"{type_str}"'
                 elif type_str in root_desc_nested_type_name:
@@ -624,20 +636,28 @@ def _gen_one_of_dict(
 
     def _message(
         self,
+        *,
         desc: DescriptorProto,
         root_desc: DescriptorProto,
         scl_prefix: SourceCodeLocation,
+        sub_model_cache: Dict[str, str],
         indent: int = 0,
         skip_validate_rule: bool = False,
     ) -> str:
         class_name = desc.name if desc.name not in PYTHON_RESERVED else "_r_" + desc.name
-        if class_name in self._model_cache:
-            if not self._model_cache[class_name]:
+        if class_name in self._fd_root_desc_dict:
+            use_model_cache = self._model_cache
+        else:
+            use_model_cache = sub_model_cache
+
+        if class_name in use_model_cache:
+            if not use_model_cache[class_name]:
                 raise WaitingToCompleteException(f"The model:{class_name} is being generated")
-            return self._model_cache[class_name]
+            return use_model_cache[class_name]
         else:
-            self._model_cache[class_name] = ""
+            use_model_cache[class_name] = ""
 
+        this_level_model_cache: Dict[str, str] = {}
         self._add_import_code("google.protobuf.message", "Message")
         comment_info_dict, desc_content, comment_content = self.add_class_desc(scl_prefix, indent)
         class_name_content = " " * indent + f"class {class_name}({self.config.base_model_class.__name__}):"
@@ -670,14 +690,15 @@ def _message(
                 continue
 
             _content_tuple = self._message_field_handle(
-                desc,
-                root_desc,
-                field,
-                indent,
-                nested_message_config_dict,
-                optional_dict,
-                one_of_dict,
-                scl_prefix + [DescriptorProto.FIELD_FIELD_NUMBER, idx],
+                desc=desc,
+                root_desc=root_desc,
+                field=field,
+                indent=indent,
+                nested_message_config_dict=nested_message_config_dict,
+                optional_dict=optional_dict,
+                one_of_dict=one_of_dict,
+                scl_prefix=scl_prefix + [DescriptorProto.FIELD_FIELD_NUMBER, idx],
+                this_level_model_cache=this_level_model_cache,
                 skip_validate_rule=skip_validate_rule,
             )
             if _content_tuple:
@@ -692,6 +713,7 @@ def _message(
                     scl_prefix + [DescriptorProto.NESTED_TYPE_FIELD_NUMBER],
                     indent,
                     nested_message_config_dict,
+                    this_level_model_cache,
                     skip_validate_rule,
                 )
             )
@@ -750,7 +772,7 @@ def _message(
         )
         if not any([class_head_content, class_field_content]):
             content += " " * (indent + self.code_indent) + "pass\n"
-        self._model_cache[class_name] = content
+        use_model_cache[class_name] = content
         return content
 
     def _get_protobuf_type_model(self, field: FieldDescriptorProto) -> ProtobufTypeModel:
@@ -883,5 +905,10 @@ def _parse_field_descriptor(self) -> None:
         )
         for index, desc in enumerate(self._fd.message_type):
             self._content_deque.append(
-                self._message(desc, desc, [FileDescriptorProto.MESSAGE_TYPE_FIELD_NUMBER, index])
+                self._message(
+                    desc=desc,
+                    root_desc=desc,
+                    scl_prefix=[FileDescriptorProto.MESSAGE_TYPE_FIELD_NUMBER, index],
+                    sub_model_cache=self._model_cache,
+                )
             )
diff --git a/pyproject.toml b/pyproject.toml
index e374d73..c6483ff 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,6 +1,6 @@
 [tool.poetry]
 name = "protobuf_to_pydantic"
-version = "0.0.0"
+version = "v0.3.0.1"
 description = "Generate the `pydantic.BaseModel` class (and the corresponding source code) with parameter verification function through the Protobuf file"
 authors = ["So1n <so1n897046026@gmail.com>"]
 license = "Apache Software License"
@@ -129,7 +129,7 @@ exclude_lines = [
 
 
 [tool.poetry-dynamic-versioning]
-enable = true
+enable = false
 metadata=false
 vcs = "git"
 # format = "v{base}-{stage}.{revision}"


Test patch:
diff --git a/tests/test_gen_code/test_demo_proto/test_plugin.py b/tests/test_gen_code/test_demo_proto/test_plugin.py
index 42096a4..7f267dd 100644
--- a/tests/test_gen_code/test_demo_proto/test_plugin.py
+++ b/tests/test_gen_code/test_demo_proto/test_plugin.py
@@ -143,7 +143,7 @@ class IncludeEnum(IntEnum):
 """
         assert content.strip("\n") in getsource(demo_p2p.NestedMessage).strip("\n")
 
-    def test_invoice_item(self) -> None:
+    def test_self_referencing(self) -> None:
         content = """
 class InvoiceItem(BaseModel):
     \"\"\"
@@ -187,3 +187,73 @@ class OptionalMessage(BaseModel):
     default_template_test: float = Field(default=1600000000.0)
 """
         assert content.strip("\n") in getsource(demo_p2p.OptionalMessage).strip("\n")
+
+    def test_after_refer_message(self)->None:
+        pass
+
+    def test_circular_references(self) -> None:
+        content = """
+class Invoice3(BaseModel):
+    name: str = Field(default="")
+    amount: int = Field(default=0)
+    quantity: int = Field(default=0)
+    items: typing.List["InvoiceItem2"] = Field(default_factory=list)"""
+        assert content.strip("\n") in getsource(demo_p2p.Invoice3).strip("\n")
+        content = """
+class InvoiceItem2(BaseModel):
+    \"\"\"
+        Test Circular references
+    from: https://github.com/so1n/protobuf_to_pydantic/issues/57
+    \"\"\"
+
+    name: str = Field(default="")
+    amount: int = Field(default=0)
+    quantity: int = Field(default=0)
+    items: typing.List["InvoiceItem2"] = Field(default_factory=list)
+    invoice: Invoice3 = Field()"""
+        assert content.strip("\n") in getsource(demo_p2p.InvoiceItem2).strip("\n")
+
+    def test_message_reference(self) -> None:
+        content = """
+class AnOtherMessage(BaseModel):
+    class SubMessage(BaseModel):
+        text: str = Field(default="")
+
+    field1: str = Field(default="")
+    field2: SubMessage = Field()"""
+        assert content.strip("\n") in getsource(demo_p2p.AnOtherMessage).strip("\n")
+
+        content = """
+class RootMessage(BaseModel):
+    \"\"\"
+        Test Message references
+    from: https://github.com/so1n/protobuf_to_pydantic/issues/64
+    \"\"\"
+
+    field1: str = Field(default="")
+    field2: AnOtherMessage = Field()"""
+        assert content.strip("\n") in getsource(demo_p2p.RootMessage).strip("\n")
+
+
+    def test_same_bane_inline_structure(self) -> None:
+        content = """
+class TestSameName0(BaseModel):
+    \"\"\"
+        Test inline structure of the same name
+    from: https://github.com/so1n/protobuf_to_pydantic/issues/76
+    \"\"\"
+
+    class Body(BaseModel):
+        input_model: str = Field(default="")
+        input_info: typing.Dict[str, str] = Field(default_factory=dict)
+
+    body: "TestSameName0.Body" = Field()"""
+        assert content.strip("\n") in getsource(demo_p2p.TestSameName0).strip("\n")
+        content = """
+class TestSameName1(BaseModel):
+    class Body(BaseModel):
+        output_model: str = Field(default="")
+        output_info: typing.Dict[str, str] = Field(default_factory=dict)
+
+    body: "TestSameName1.Body" = Field()"""
+        assert content.strip("\n") in getsource(demo_p2p.TestSameName1).strip("\n")
diff --git a/tests/test_gen_code/test_demo_proto/test_simple.py b/tests/test_gen_code/test_demo_proto/test_simple.py
index 4db8d01..6bb4146 100644
--- a/tests/test_gen_code/test_demo_proto/test_simple.py
+++ b/tests/test_gen_code/test_demo_proto/test_simple.py
@@ -267,7 +267,7 @@ class InvoiceItem(BaseModel):
             """
         ) in self._model_output(demo_pb2.InvoiceItem)
 
-    def test_field_optional(self) -> None:
+    def test_self_referencing(self) -> None:
         if is_v1:
             content = """
 class InvoiceItem(BaseModel):
@@ -315,3 +315,54 @@ class OptionalMessage(BaseModel):
     one_of_validator = model_validator(mode="before")(check_one_of)
 """
         assert format_content(content) in self._model_output(demo_pb2.OptionalMessage)
+
+    def test_circular_references(self) -> None:
+        content = """
+class Invoice3(BaseModel):
+    name: str = Field(default="")
+    amount: int = Field(default=0)
+    quantity: int = Field(default=0)
+    items: typing.List["InvoiceItem2"] = Field(default_factory=list)
+
+class InvoiceItem2(BaseModel):
+
+    name: str = Field(default="")
+    amount: int = Field(default=0)
+    quantity: int = Field(default=0)
+    items: typing.List["InvoiceItem2"] = Field(default_factory=list)
+    invoice: Invoice3 = Field()"""
+        assert format_content(content) in self._model_output(demo_pb2.InvoiceItem2)
+
+    def test_message_reference(self) -> None:
+        content = """
+class AnOtherMessage(BaseModel):
+    class SubMessage(BaseModel):
+        text: str = Field(default="")
+
+    field1: str = Field(default="")
+    field2: SubMessage = Field()
+
+class RootMessage(BaseModel):
+
+    field1: str = Field(default="")
+    field2: AnOtherMessage = Field()"""
+        assert format_content(content) in self._model_output(demo_pb2.RootMessage)
+
+    def test_same_bane_inline_structure(self) -> None:
+        content = """
+class TestSameName0(BaseModel):
+
+    class Body(BaseModel):
+        input_model: str = Field(default="")
+        input_info: typing.Dict[str, str] = Field(default_factory=dict)
+
+    body: Body = Field()"""
+        assert format_content(content) in self._model_output(demo_pb2.TestSameName0)
+        content = """
+class TestSameName1(BaseModel):
+    class Body(BaseModel):
+        output_model: str = Field(default="")
+        output_info: typing.Dict[str, str] = Field(default_factory=dict)
+
+    body: Body = Field()"""
+        assert format_content(content) in self._model_output(demo_pb2.TestSameName1)
diff --git a/tests/test_gen_code/test_demo_proto/test_text_comment.py b/tests/test_gen_code/test_demo_proto/test_text_comment.py
index 0299758..06985c0 100644
--- a/tests/test_gen_code/test_demo_proto/test_text_comment.py
+++ b/tests/test_gen_code/test_demo_proto/test_text_comment.py
@@ -440,7 +440,7 @@ class IncludeEnum(IntEnum):
 """
         assert format_content(content) in self._model_output(demo_pb2.NestedMessage)
 
-    def test_invoice_item(self) -> None:
+    def test_self_referencing(self) -> None:
         assert format_content(
             """
 class InvoiceItem(BaseModel):
@@ -451,6 +451,67 @@ class InvoiceItem(BaseModel):
             """
         ) in self._model_output(demo_pb2.InvoiceItem)
 
+    def test_circular_references(self) -> None:
+        assert format_content(
+            """
+class Invoice3(BaseModel):
+    name: str = Field(default="")
+    amount: int = Field(default=0)
+    quantity: int = Field(default=0)
+    items: typing.List["InvoiceItem2"] = Field(default_factory=list)
+
+
+class InvoiceItem2(BaseModel):
+
+    name: str = Field(default="")
+    amount: int = Field(default=0)
+    quantity: int = Field(default=0)
+    items: typing.List["InvoiceItem2"] = Field(default_factory=list)
+    invoice: Invoice3 = Field()
+            """
+        ) in self._model_output(demo_pb2.InvoiceItem2)
+
+    def test_message_reference(self) -> None:
+        assert format_content(
+            """
+class AnOtherMessage(BaseModel):
+    class SubMessage(BaseModel):
+        text: str = Field(default="")
+
+    field1: str = Field(default="")
+    field2: SubMessage = Field()
+
+
+class RootMessage(BaseModel):
+
+    field1: str = Field(default="")
+    field2: AnOtherMessage = Field()
+            """
+        ) in self._model_output(demo_pb2.RootMessage)
+
+    def test_same_bane_inline_structure(self) -> None:
+        assert format_content(
+            """
+class TestSameName0(BaseModel):
+
+    class Body(BaseModel):
+        input_model: str = Field(default="")
+        input_info: typing.Dict[str, str] = Field(default_factory=dict)
+
+    body: Body = Field()
+            """
+        ) in self._model_output(demo_pb2.TestSameName0)
+
+        assert format_content(
+            """
+class TestSameName1(BaseModel):
+    class Body(BaseModel):
+        output_model: str = Field(default="")
+        output_info: typing.Dict[str, str] = Field(default_factory=dict)
+
+    body: Body = Field()
+            """
+        ) in self._model_output(demo_pb2.TestSameName1)
 
 class TestTextCommentByPyi(BaseTestTextComment):
     @staticmethod