rpc-naming
Since 0.9.0 · In the rulesets: Recommended at warning, Strict at error, All at error
This rule checks whether the name of every RPC of a Protobuf file is in PascalCase.
Rule details
RPC names become method names in the generated code and appear in the paths of gRPC requests
(/acme.pets.v1.PetService/GetPet). PascalCase is what the Protobuf style guide recommends, and
the rpc-request-standard-name and rpc-response-standard-name rules derive the names of the
request and response types from them.
The rpc-naming rule checks every RPC of every service, and reports RPC name '<name>' should be PascalCase for every name that is not in PascalCase. A name is in PascalCase when it
starts with an upper-case letter and contains only letters and digits, such as PetOwner
(acronyms such as HTTPServer are accepted).
When the name converted to PascalCase differs from the original and is itself valid, the
message ends with a suggestion, for example , e.g. '<converted>'. To convert a name, it is
split into words at underscores and other separators, at lower-to-upper case changes and before
the last capital of an acronym, and the words are capitalized and joined, so pet_owner becomes
PetOwner.
Turn the rule off if the names are part of an existing API that you cannot rename. To allow a single
RPC, add an // apigenie-lint-disable rpc-naming comment to it.
Examples
Good.
syntax = "proto3";
package acme.pets.v1;
service PetService {
rpc GetPet(GetPetRequest) returns (GetPetResponse);
}
message GetPetRequest {
string name = 1;
}
message GetPetResponse {
string name = 1;
}
Bad. The linter reports RPC name 'get_pet' should be PascalCase, e.g. 'GetPet'.
syntax = "proto3";
package acme.pets.v1;
service PetService {
rpc get_pet(GetPetRequest) returns (GetPetResponse);
}
message GetPetRequest {
string name = 1;
}
message GetPetResponse {
string name = 1;
}
Turn it off or change its severity
In apigenie.yaml, off turns the rule off and warning or error sets its severity; a rule with options takes the severity and the options as a pair, [warning, options]. lint.protobuf has the details.
commands:
lint:
protobuf:
rules:
rpc-naming: off