github.com/googleapis/api-linter@v1.65.2/docs/rules/0191/file-layout.md (about)

     1  ---
     2  rule:
     3    aip: 191
     4    name: [core, '0191', file-layout]
     5    summary: Proto files should follow a consistent layout.
     6  permalink: /191/file-layout
     7  redirect_from:
     8    - /0191/file-layout
     9  ---
    10  
    11  # File layout
    12  
    13  This rule attempts to enforce a consistent file layout for proto files, as
    14  mandated in [AIP-191][].
    15  
    16  ## Details
    17  
    18  This rule checks for common file layout mistakes, but does not currently check
    19  the exhaustive file layout in AIP-191. This rule currently complains if within a
    20  file:
    21  
    22  - ...services appear below messages.
    23  - ...top-level enums appear above messages.
    24  
    25  ## Examples
    26  
    27  **Incorrect** code for this rule:
    28  
    29  ```proto
    30  // Incorrect.
    31  // Services should appear before messages.
    32  message Book {
    33    string name = 1;
    34  }
    35  
    36  service Library {
    37    rpc GetBook(GetBookRequest) returns (Book) {
    38      option (google.api.http) = {
    39        get: "/v1/{name=publishers/*/books/*}"
    40      };
    41    }
    42  }
    43  
    44  message GetBookRequest {
    45    string name = 1;
    46  }
    47  ```
    48  
    49  **Correct** code for this rule:
    50  
    51  ```proto
    52  // Correct.
    53  service Library {
    54    rpc GetBook(GetBookRequest) returns (Book) {
    55      option (google.api.http) = {
    56        get: "/v1/{name=publishers/*/books/*}"
    57      };
    58    }
    59  }
    60  
    61  message Book {
    62    string name = 1;
    63  }
    64  
    65  message GetBookRequest {
    66    string name = 1;
    67  }
    68  ```
    69  
    70  ## Disabling
    71  
    72  If you need to violate this rule, use a comment at the top of the file.
    73  Remember to also include an [aip.dev/not-precedent][] comment explaining why.
    74  
    75  ```proto
    76  // (-- api-linter: core::0191::file-layout=disabled
    77  //     aip.dev/not-precedent: We need to do this because reasons. --)
    78  syntax = "proto3";
    79  
    80  import "google/api/anotations.proto";
    81  
    82  message Book {
    83    string name = 1;
    84  }
    85  
    86  service Library {
    87    rpc GetBook(GetBookRequest) returns (Book) {
    88      option (google.api.http) = {
    89        get: "/v1/{name=publishers/*/books/*}"
    90      };
    91    }
    92  }
    93  
    94  message GetBookRequest {
    95    string name = 1;
    96  }
    97  ```
    98  
    99  [aip-191]: https://aip.dev/191
   100  [aip.dev/not-precedent]: https://aip.dev/not-precedent