22rule :
33 aep : 133
44 name : [core, '0133', resource-reference-type]
5- summary : Create should use a `child_type` reference to the created resource.
5+ summary :
6+ Create should use `resource_reference_child_type` to reference the created
7+ resource.
68permalink : /133/resource-reference-type
79redirect_from :
810 - /0133/resource-reference-type
@@ -11,15 +13,17 @@ redirect_from:
1113# Create methods: Parent field resource reference
1214
1315This rule enforces that all ` Create ` standard methods with a ` string parent `
14- field use a proper ` (aep.api.field_info).resource_reference ` , that being either a
15- ` child_type ` referring to the created resource or a ` type ` referring directly
16- to the parent resource, as mandated in [ AEP-133] [ ] .
16+ field use a proper ` (aep.api.field_info).resource_reference_child_type ` or
17+ ` (aep.api.field_info.).resource_reference ` to refer to the created resource, as
18+ mandated in [ AEP-133] [ ] .
1719
1820## Details
1921
20- This rule looks at any message matching ` Create*Request ` and complains if the
21- ` (aep.api.field_info).resource_reference ` on the ` parent ` field refers to the wrong
22- resource.
22+ This rule looks at any message matching ` Create*Request ` and complains if the
23+ ` (aep.api.field_info).resource_reference_child_type ` or
24+ ` (aep.api.field_info).resource_reference ` on the ` parent ` field refers to the
25+ wrong resource. The preferred approach is to use
26+ ` resource_reference_child_type ` to reference the child resource being created.
2327
2428## Examples
2529
@@ -28,9 +32,8 @@ resource.
2832``` proto
2933// Incorrect.
3034message CreateBooksRequest {
31- // `child_type` should be used instead of `type` when referring to the
32- // created resource on a parent field.
33- string parent = 1 [(aep.api.field_info).resource_reference.type = "library.googleapis.com/Book"];
35+ // Should reference the correct child resource type.
36+ string parent = 1 [(aep.api.field_info).resource_reference_child_type = "library.googleapis.com/Shelf"];
3437 Book book = 2;
3538}
3639```
@@ -40,7 +43,7 @@ message CreateBooksRequest {
4043``` proto
4144// Correct.
4245message CreateBooksRequest {
43- string parent = 1 [(aep.api.field_info).resource_reference.child_type = "library.googleapis.com/Book"];
46+ string parent = 1 [(aep.api.field_info).resource_reference_child_type = "library.googleapis.com/Book"];
4447 Book book = 2;
4548}
4649```
@@ -54,7 +57,7 @@ Remember to also include an [aep.dev/not-precedent][] comment explaining why.
5457message CreateBooksRequest {
5558 // (-- api-linter: core::0133::resource-reference-type=disabled
5659 // aep.dev/not-precedent: We need to do this because reasons. --)
57- string parent = 1 [(aep.api.field_info).resource_reference.type = "library.googleapis.com/Book "];
60+ string parent = 1 [(aep.api.field_info).resource_reference_child_type = "library.googleapis.com/Shelf "];
5861 Book book = 2;
5962}
6063```
0 commit comments