Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AIP-122: Disallow embedding other resources as fields in a resource #1193

Closed
noahdietz opened this issue Aug 8, 2023 · 1 comment · Fixed by #1196
Closed

AIP-122: Disallow embedding other resources as fields in a resource #1193

noahdietz opened this issue Aug 8, 2023 · 1 comment · Fixed by #1196
Labels
aip: amendment This AIP should be amended to add something.

Comments

@noahdietz
Copy link
Collaborator

AIP-122 outlines how a resource should refer to another resource in its own message definition, using a string field representing the other resource's name, with a google.api.resource_reference annotation to document the format.

It does not, however, call out the anti-pattern of embedding a resource reference as message type field. For example:

message Publisher {
  option (google.api.resource) = {
    // ...
  };

  // ...

  // Authors associated with the Publisher, where Author is also a resource.
  repeated Authors authors = 2;
}

Instead, the field should be:

  repeated string authors = 2 [
    (google.api.resource_reference).type = "library.googleapis.com/Author"
  ];

I propose that AIP-122 should call out this anti-pattern and correction explicitly.

@noahdietz noahdietz added the aip: amendment This AIP should be amended to add something. label Aug 8, 2023
@noahdietz noahdietz added this to the gcp-strict-aips-202312 milestone Aug 8, 2023
@noahdietz
Copy link
Collaborator Author

cc: @ibelle

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
aip: amendment This AIP should be amended to add something.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant