# service-suffix

Source: https://apigenie.pl/docs/linter/protobuf/rules/service-suffix

This rule checks whether the name of every service ends with a suffix, `Service` by default.

## Rule Details

A common suffix makes services easy to tell apart from messages in the Protobuf files and in the
generated code, where the service name becomes the base of the client and server classes.

The `service-suffix` rule reports `Service name '<service>' should end with '<suffix>'` for every
service whose name does not end with the suffix. The comparison is case-sensitive.

## Configuration

The configuration block can be a string or an object.

If it is a string, its value is the suffix.

If it is an object, it must contain only the `suffix` property, whose value is the suffix.

The suffix cannot be empty.

**Configuration Example**. The following two examples are equivalent. They specify that service
names must end with `API`.

```yaml
version: "1.0"
commands:
  lint:
    protobuf:
      rules:
        service-suffix: [warning, API]
```

```yaml
version: "1.0"
commands:
  lint:
    protobuf:
      rules:
        service-suffix:
          - warning
          - suffix: API
```

## Examples

**Good**. With the default configuration.

```proto
syntax = "proto3";

package acme.pets.v1;

service PetStoreService {
  rpc GetPet(GetPetRequest) returns (GetPetResponse);
}

message GetPetRequest {
  string name = 1;
}

message GetPetResponse {
  string name = 1;
}
```

**Bad**. With the default configuration, the linter reports
`Service name 'PetStore' should end with 'Service'`.

```proto
syntax = "proto3";

package acme.pets.v1;

service PetStore {
  rpc GetPet(GetPetRequest) returns (GetPetResponse);
}

message GetPetRequest {
  string name = 1;
}

message GetPetResponse {
  string name = 1;
}
```

## When Not to Use It

You may disable this rule if the service names are part of an existing API that you cannot
rename.

## Compatibility

This rule is compatible with proto3 files. proto2 and editions files are rejected by the reader
and are not linted.
