You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[protobuf-schema] Use snake_case for protobuf fields, UPPER_SNAKE_CASE for enums. (#20696)
* protobuf enum prefix use upper underscore
Add json name parameters and change parameter field name to snake case
* rerun generate-samples.sh
* Add CI test
* rebase master
---------
Co-authored-by: xil <[email protected]>
Copy file name to clipboardExpand all lines: docs/generators/protobuf-schema.md
+1
Original file line number
Diff line number
Diff line change
@@ -18,6 +18,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
18
18
19
19
| Option | Description | Values | Default |
20
20
| ------ | ----------- | ------ | ------- |
21
+
|addJsonNameAnnotation|Append "json_name" annotation to message field when the specification name differs from the protobuf field name||false|
21
22
|numberedFieldNumberList|Field numbers in order.||false|
22
23
|startEnumsWithUnspecified|Introduces "UNSPECIFIED" as the first element of enumerations.||false|
@@ -60,11 +63,18 @@ public class ProtobufSchemaCodegen extends DefaultCodegen implements CodegenConf
60
63
61
64
privatebooleanstartEnumsWithUnspecified = false;
62
65
66
+
privatebooleanaddJsonNameAnnotation = false;
67
+
63
68
@Override
64
69
publicCodegenTypegetTag() {
65
70
returnCodegenType.SCHEMA;
66
71
}
67
72
73
+
@Override
74
+
publicStringtoEnumName(CodegenPropertyproperty) {
75
+
returnStringUtils.capitalize(property.name);
76
+
}
77
+
68
78
@Override
69
79
publicStringgetName() {
70
80
return"protobuf-schema";
@@ -163,6 +173,7 @@ public ProtobufSchemaCodegen() {
163
173
164
174
addSwitch(NUMBERED_FIELD_NUMBER_LIST, "Field numbers in order.", numberedFieldNumberList);
165
175
addSwitch(START_ENUMS_WITH_UNSPECIFIED, "Introduces \"UNSPECIFIED\" as the first element of enumerations.", startEnumsWithUnspecified);
176
+
addSwitch(ADD_JSON_NAME_ANNOTATION, "Append \"json_name\" annotation to message field when the specification name differs from the protobuf field name", addJsonNameAnnotation);
0 commit comments