Skip to content

Latest commit

 

History

History
64 lines (50 loc) · 1.72 KB

File metadata and controls

64 lines (50 loc) · 1.72 KB
rule
aep name summary
131
core
0131
request-path-reference
Get RPCs should annotate the `path` field with `(aep.api.field_info).resource_reference`.
permalink /131/request-path-reference
redirect_from
/0131/request-path-reference

Get methods: Resource reference

This rule enforces that all Get standard methods have (aep.api.field_info).resource_reference on their string path field, as mandated in AEP-131.

Details

This rule looks at the path field of any message matching Get*Request and complains if it does not have a (aep.api.field_info).resource_reference annotation.

Examples

Incorrect code for this rule:

// Incorrect.
message GetBookRequest {
  // The `(aep.api.field_info).resource_reference` annotation should also be included.
  string path = 1 [(aep.api.field_info).field_behavior = FIELD_BEHAVIOR_REQUIRED];
}

Correct code for this rule:

// Correct.
message GetBookRequest {
  string path = 1 [
    (aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED,
    (aep.api.field_info).resource_reference = "library.googleapis.com/Book"
  ];
}

Disabling

If you need to violate this rule, use a leading comment above the field. Remember to also include an aep.dev/not-precedent comment explaining why.

message GetBookRequest {
  // (-- api-linter: core::0131::request-path-reference=disabled
  //     aep.dev/not-precedent: We need to do this because reasons. --)
  string path = 1 [(aep.api.field_info).field_behavior = FIELD_BEHAVIOR_REQUIRED];
}

If you need to violate this rule for an entire file, place the comment at the top of the file.