@@ -123,8 +123,15 @@ service {{.TName}} {
123123 rpc ListByLastID(List{{.TableName}}ByLastIDRequest) returns (List{{.TableName}}ByLastIDReply) {}
124124}
125125
126- // Some notes on defining fields under message:
127- // Fill in the validate rules https://github.com/envoyproxy/protoc-gen-validate#constraint-rules
126+
127+ /*
128+ Notes for defining message fields:
129+ 1. Suggest using camel case style naming for message field names, such as firstName, lastName, etc.
130+ 2. If the message field name ending in 'id', it is recommended to use xxxID naming format, such as userID, orderID, etc.
131+ 3. Add validate rules https://github.com/envoyproxy/protoc-gen-validate#constraint-rules, such as:
132+ uint64 id = 1 [(validate.rules).uint64.gte = 1];
133+ */
134+
128135
129136// protoMessageCreateCode
130137
@@ -227,8 +234,15 @@ service {{.TName}} {
227234 rpc List(List{{.TableName}}Request) returns (List{{.TableName}}Reply) {}
228235}
229236
230- // Some notes on defining fields under message:
231- // Fill in the validate rules https://github.com/envoyproxy/protoc-gen-validate#constraint-rules
237+
238+ /*
239+ Notes for defining message fields:
240+ 1. Suggest using camel case style naming for message field names, such as firstName, lastName, etc.
241+ 2. If the message field name ending in 'id', it is recommended to use xxxID naming format, such as userID, orderID, etc.
242+ 3. Add validate rules https://github.com/envoyproxy/protoc-gen-validate#constraint-rules, such as:
243+ uint64 id = 1 [(validate.rules).uint64.gte = 1];
244+ */
245+
232246
233247// protoMessageCreateCode
234248
@@ -472,19 +486,26 @@ service {{.TName}} {
472486}
473487
474488
475- // Some notes on defining fields under message:
476- // (1) Fill in the validate rules https://github.com/envoyproxy/protoc-gen-validate#constraint-rules
477- // (2) Suggest using camel hump naming for message field names, and for names ending in 'id',
478- // use xxxID naming format, such as userID, orderID, etc.
479- // (3) When using the protoc-gen-openapiv2 plugin, if the defined fields are snake case,
480- // you must add annotations for snake case names, such as string fieldName = 1 [json_name = "field_name"],
481- // to ensure that the front end and back end JSON naming is consistent.
482- // (4) If the route contains the path parameter, such as /api/v1/userExample/{id}, the defined
483- // message must contain the name of the path parameter and the name should be
484- // added with a new tag, such as int64 id = 1 [(tagger.tags) = "uri:\"id\""];
485- // (5) If the request url is followed by a query parameter, such as /api/v1/getUserExample?name=Tom,
486- // a form tag must be added when defining the query parameter in the message,
487- // such as string name = 1 [(tagger.tags) = "form:\"name\""].
489+ /*
490+ Notes for defining message fields:
491+ 1. Suggest using camel case style naming for message field names, such as firstName, lastName, etc.
492+ 2. If the message field name ending in 'id', it is recommended to use xxxID naming format, such as userID, orderID, etc.
493+ 3. Add validate rules https://github.com/envoyproxy/protoc-gen-validate#constraint-rules, such as:
494+ uint64 id = 1 [(validate.rules).uint64.gte = 1];
495+
496+ If used to generate code that supports the HTTP protocol, notes for defining message fields:
497+ 1. If the route contains the path parameter, such as /api/v1/userExample/{id}, the defined
498+ message must contain the name of the path parameter and the name should be added
499+ with a new tag, such as int64 id = 1 [(tagger.tags) = "uri:\"id\""];
500+ 2. If the request url is followed by a query parameter, such as /api/v1/getUserExample?name=Tom,
501+ a form tag must be added when defining the query parameter in the message, such as:
502+ string name = 1 [(tagger.tags) = "form:\"name\""].
503+ 3. If the message field name contain underscores(such as 'field_name'), it will cause a problem
504+ where the JSON field names of the Swagger request parameters are different from those of the
505+ GRPC JSON tag names. There are two solutions: Solution 1, remove the underline from the
506+ message field name. Option 2, use the tool 'protoc-go-inject-tag' to modify the JSON tag name,
507+ such as: string first_name = 1 ; // @gotags: json:"firstName"
508+ */
488509
489510
490511// protoMessageCreateCode
@@ -692,19 +713,26 @@ service {{.TName}} {
692713}
693714
694715
695- // Some notes on defining fields under message:
696- // (1) Fill in the validate rules https://github.com/envoyproxy/protoc-gen-validate#constraint-rules
697- // (2) Suggest using camel hump naming for message field names, and for names ending in 'id',
698- // use xxxID naming format, such as userID, orderID, etc.
699- // (3) When using the protoc-gen-openapiv2 plugin, if the defined fields are snake case,
700- // you must add annotations for snake case names, such as string fieldName = 1 [json_name = "field_name"],
701- // to ensure that the front end and back end JSON naming is consistent.
702- // (4) If the route contains the path parameter, such as /api/v1/userExample/{id}, the defined
703- // message must contain the name of the path parameter and the name should be
704- // added with a new tag, such as int64 id = 1 [(tagger.tags) = "uri:\"id\""];
705- // (5) If the request url is followed by a query parameter, such as /api/v1/getUserExample?name=Tom,
706- // a form tag must be added when defining the query parameter in the message,
707- // such as string name = 1 [(tagger.tags) = "form:\"name\""].
716+ /*
717+ Notes for defining message fields:
718+ 1. Suggest using camel case style naming for message field names, such as firstName, lastName, etc.
719+ 2. If the message field name ending in 'id', it is recommended to use xxxID naming format, such as userID, orderID, etc.
720+ 3. Add validate rules https://github.com/envoyproxy/protoc-gen-validate#constraint-rules, such as:
721+ uint64 id = 1 [(validate.rules).uint64.gte = 1];
722+
723+ If used to generate code that supports the HTTP protocol, notes for defining message fields:
724+ 1. If the route contains the path parameter, such as /api/v1/userExample/{id}, the defined
725+ message must contain the name of the path parameter and the name should be added
726+ with a new tag, such as int64 id = 1 [(tagger.tags) = "uri:\"id\""];
727+ 2. If the request url is followed by a query parameter, such as /api/v1/getUserExample?name=Tom,
728+ a form tag must be added when defining the query parameter in the message, such as:
729+ string name = 1 [(tagger.tags) = "form:\"name\""].
730+ 3. If the message field name contain underscores(such as 'field_name'), it will cause a problem
731+ where the JSON field names of the Swagger request parameters are different from those of the
732+ GRPC JSON tag names. There are two solutions: Solution 1, remove the underline from the
733+ message field name. Option 2, use the tool 'protoc-go-inject-tag' to modify the JSON tag name,
734+ such as: string first_name = 1 ; // @gotags: json:"firstName"
735+ */
708736
709737
710738// protoMessageCreateCode
0 commit comments