api-linter icon indicating copy to clipboard operation
api-linter copied to clipboard

Please add the necessary include to https://linter.aip.dev/203/optional

Open Alasdair-Mackintosh opened this issue 5 years ago • 4 comments
trafficstars

The page at https://linter.aip.dev/203/optional should have the following for the sample code:

// Correct. import "google/api/field_behavior.proto";

message Book { string name = 1;

// The foreword for the book. string foreword = 2 [(google.api.field_behavior) = OPTIONAL]; }

Alasdair-Mackintosh avatar Jul 14 '20 22:07 Alasdair-Mackintosh

Hmm. I take the point, but in general we have not done imports across most of these.

I assume this was an issue for you, or else you would not have filed the bug. I am hesitant to go make "universal import statements" a policy, though. Is there an "in-between" approach that would be less confusing for you?

lukesneeringer avatar Jul 15 '20 04:07 lukesneeringer

I was directed to that page as a guideline on how to fix a linter error.

It's always handy, when this happens, for the page to tell you everything you need to know to fix the error. So as well as the syntax example (which is there, and easily copyable), it would be nice to know what you need to include in order to fix the issue. I'm not wedded to any one approach, but knowing that import "google/api/field_behavior.proto"; was the text I need to ad to the file would have been useful.

Thanks,

Alasdair

Alasdair-Mackintosh avatar Jul 15 '20 06:07 Alasdair-Mackintosh

Perhaps instead we can auto-link the annotation types to their corresponding definition in https://github.com/googleapis/googleapis? Most of the examples in the docs are not syntactically complete proto files.

apasel422 avatar Oct 21 '20 18:10 apasel422

We also now have a new site generator for aip.dev that knows how to include snippets of an actual file. We could shift toward that (and that could be useful for testing reasons also).

lukesneeringer avatar Oct 27 '20 19:10 lukesneeringer