Skip to content

Commit 8cca68a

Browse files
committed
Fix, fix not support default value is none
1 parent 1aa0072 commit 8cca68a

File tree

106 files changed

+306
-156
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

106 files changed

+306
-156
lines changed

example/example_proto/common/p2p_validate.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1221,7 +1221,7 @@ message MessageRules {
12211221
oneof default_config {
12221222
// The default value corresponding to the field, if not set,
12231223
// the default value is the default value of the corresponding type of the field
1224-
float default = 9;
1224+
string default = 9;
12251225
// The default value factory function corresponding to the field, supports template variables,
12261226
// such as `p2p@import|uuid|uuid4`
12271227
string default_factory = 10;

example/example_proto/p2p_validate/demo.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,4 +608,5 @@ message OptionalMessage{
608608
optional MessageIgnoredTest my_message2 = 2;
609609
MessageIgnoredTest my_message3 = 3[(p2p_validate.rules).message.required=true];
610610
MessageIgnoredTest my_message4 = 4;
611+
optional MessageIgnoredTest my_message_5 = 5[(p2p_validate.rules).message.default_template="p2p@builtin|None"];
611612
}

example/example_proto/p2p_validate_by_comment/demo.proto

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -679,4 +679,6 @@ message OptionalMessage{
679679
// p2p: {"required": true}
680680
MessageIgnoredTest my_message3 = 3;
681681
MessageIgnoredTest my_message4 = 4;
682+
// p2p: {"default_template": "p2p@builtin|None"}
683+
optional MessageIgnoredTest my_message_5 = 5;
682684
}

example/proto_3_20_pydanticv1/demo_gen_code.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# This is an automatically generated file, please do not change
2-
# gen by protobuf_to_pydantic[v0.3.0.4](https://github.com/so1n/protobuf_to_pydantic)
2+
# gen by protobuf_to_pydantic[v0.3.1.0](https://github.com/so1n/protobuf_to_pydantic)
33
# Protobuf Version: 3.20.3
44
# Pydantic Version: 1.10.7
55
import typing

example/proto_3_20_pydanticv1/demo_gen_code_by_p2p.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# This is an automatically generated file, please do not change
2-
# gen by protobuf_to_pydantic[v0.3.0.4](https://github.com/so1n/protobuf_to_pydantic)
2+
# gen by protobuf_to_pydantic[v0.3.1.0](https://github.com/so1n/protobuf_to_pydantic)
33
# Protobuf Version: 3.20.3
44
# Pydantic Version: 1.10.7
55
import typing
@@ -481,6 +481,7 @@ class OptionalMessage(BaseModel):
481481
my_message2: typing.Optional[MessageIgnoredTest] = Field(default_factory=MessageIgnoredTest)
482482
my_message3: MessageIgnoredTest = Field()
483483
my_message4: MessageIgnoredTest = Field(default_factory=MessageIgnoredTest)
484+
my_message_5: typing.Optional[MessageIgnoredTest] = Field(default=None)
484485

485486

486487
class RepeatedTest(BaseModel):

example/proto_3_20_pydanticv1/demo_gen_code_by_pgv.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# This is an automatically generated file, please do not change
2-
# gen by protobuf_to_pydantic[v0.3.0.4](https://github.com/so1n/protobuf_to_pydantic)
2+
# gen by protobuf_to_pydantic[v0.3.1.0](https://github.com/so1n/protobuf_to_pydantic)
33
# Protobuf Version: 3.20.3
44
# Pydantic Version: 1.10.7
55
import typing

example/proto_3_20_pydanticv1/demo_gen_code_by_text_comment_protobuf_field.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# This is an automatically generated file, please do not change
2-
# gen by protobuf_to_pydantic[v0.3.0.4](https://github.com/so1n/protobuf_to_pydantic)
2+
# gen by protobuf_to_pydantic[v0.3.1.0](https://github.com/so1n/protobuf_to_pydantic)
33
# Protobuf Version: 3.20.3
44
# Pydantic Version: 1.10.7
55
import typing

example/proto_3_20_pydanticv1/demo_gen_code_by_text_comment_pyi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# This is an automatically generated file, please do not change
2-
# gen by protobuf_to_pydantic[v0.3.0.4](https://github.com/so1n/protobuf_to_pydantic)
2+
# gen by protobuf_to_pydantic[v0.3.1.0](https://github.com/so1n/protobuf_to_pydantic)
33
# Protobuf Version: 3.20.3
44
# Pydantic Version: 1.10.7
55
import typing

example/proto_3_20_pydanticv1/example/example_proto/common/p2p_validate_pb2.py

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/proto_3_20_pydanticv1/example/example_proto/common/p2p_validate_pb2.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2791,7 +2791,7 @@ class MessageRules(google.protobuf.message.Message):
27912791
enable: builtins.bool
27922792
"""Whether to enable this field, if not, the generated Model will not carry this field"""
27932793

2794-
default: builtins.float
2794+
default: typing.Text
27952795
"""The default value corresponding to the field, if not set,
27962796
the default value is the default value of the corresponding type of the field
27972797
"""
@@ -2838,7 +2838,7 @@ class MessageRules(google.protobuf.message.Message):
28382838
*,
28392839
skip: typing.Optional[builtins.bool] = ...,
28402840
enable: typing.Optional[builtins.bool] = ...,
2841-
default: builtins.float = ...,
2841+
default: typing.Text = ...,
28422842
default_factory: typing.Text = ...,
28432843
miss_default: builtins.bool = ...,
28442844
required: builtins.bool = ...,

0 commit comments

Comments
 (0)