This repository was archived by the owner on Jun 9, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed
src/betterproto2_compiler Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -153,7 +153,6 @@ def comment(self) -> str:
153
153
"""
154
154
return get_comment (proto_file = self .source_file , path = self .path )
155
155
156
-
157
156
@dataclass (kw_only = True )
158
157
class PluginRequestCompiler :
159
158
plugin_request_obj : CodeGeneratorRequest
@@ -261,6 +260,10 @@ def custom_methods(self) -> list[str]:
261
260
methods_source .append (source .strip ())
262
261
263
262
return methods_source
263
+
264
+ @property
265
+ def descriptor (self ):
266
+ return self .proto_obj .SerializeToString ()
264
267
265
268
266
269
def is_map (proto_field_obj : FieldDescriptorProto , parent_message : DescriptorProto ) -> bool :
@@ -523,7 +526,10 @@ def py_name(self) -> str:
523
526
@property
524
527
def deprecated (self ) -> bool :
525
528
return bool (self .proto_obj .options and self .proto_obj .options .deprecated )
526
-
529
+
530
+ @property
531
+ def descriptor (self ):
532
+ return self .proto_obj .SerializeToString ()
527
533
528
534
@dataclass (kw_only = True )
529
535
class ServiceCompiler (ProtoContentBase ):
Original file line number Diff line number Diff line change @@ -6,6 +6,10 @@ class {{ enum.py_name }}(betterproto2.Enum):
6
6
"""
7
7
{% endif %}
8
8
9
+ @staticmethod
10
+ def _serialized_pb():
11
+ return {{ enum.descriptor }}
12
+
9
13
{% for entry in enum .entries %}
10
14
{{ entry.name }} = {{ entry.value }}
11
15
{% if entry .comment %}
@@ -45,6 +49,10 @@ class {{ message.py_name }}(betterproto2.Message):
45
49
"""
46
50
{% endif %}
47
51
52
+ @staticmethod
53
+ def _serialized_pb():
54
+ return {{ message.descriptor }}
55
+
48
56
{% for field in message .fields %}
49
57
{{ field.get_field_string() }}
50
58
{% if field .comment %}
You can’t perform that action at this time.
0 commit comments