github.com/googleapis/api-linter@v1.65.2/docs/rules/0123/resource-singular.md (about)

     1  ---
     2  rule:
     3    aip: 123
     4    name: [core, '0123', resource-singular]
     5    summary: Resource singular is required and must be lowerCamelCase of type
     6  permalink: /123/resource-singular
     7  redirect_from:
     8    - /0123/resource-singular
     9  ---
    10  
    11  # Resource type name
    12  
    13  This rule enforces that messages that have a `google.api.resource` annotation,
    14  have a properly formatted `singular`, as described in [AIP-123][].
    15  
    16  ## Details
    17  
    18  This rule scans messages with a `google.api.resource` annotation, and validates
    19  the format of the `singular` field is the lower camel case of type.
    20  
    21  ## Examples
    22  
    23  **Incorrect** code for this rule:
    24  
    25  ```proto
    26  // Incorrect.
    27  message Book {
    28    option (google.api.resource) = {
    29      type: "library.googleapis.com/BookShelf"
    30      pattern: "publishers/{publisher}/bookShelves/{book_shelf}"
    31      // does not match type.
    32      singular: "shelf",
    33    };
    34  
    35    string name = 1;
    36  }
    37  ```
    38  
    39  **Correct** code for this rule:
    40  
    41  ```proto
    42  // Correct.
    43  message Book {
    44    option (google.api.resource) = {
    45      type: "library.googleapis.com/BookShelf"
    46      pattern: "publishers/{publisher}/bookShelves/{book_shelf}"
    47      singular: "bookShelf",
    48    };
    49  
    50    string name = 1;
    51  }
    52  ```
    53  
    54  ## Disabling
    55  
    56  If you need to violate this rule, use a leading comment above the message.
    57  
    58  ```proto
    59  // (-- api-linter: core::0123::resource-singular=disabled
    60  //     aip.dev/not-precedent: We need to do this because reasons. --)
    61  message Book {
    62    option (google.api.resource) = {
    63      type: "library.googleapis.com/Genre/Mystery/Book"
    64      pattern: "publishers/{publisher}/books/{book}"
    65      singular: "shelf",
    66    };
    67  
    68    string name = 1;
    69  }
    70  ```
    71  
    72  If you need to violate this rule for an entire file, place the comment at the
    73  top of the file.
    74  
    75  [aip-123]: http://aip.dev/123
    76  [aip.dev/not-precedent]: https://aip.dev/not-precedent