googleapis / api-linter

A linter for APIs defined in protocol buffers.
https://linter.aip.dev/
Apache License 2.0
600 stars 144 forks source link

How do you import googleapis? #1358

Closed liveFreeOrCode closed 7 months ago

liveFreeOrCode commented 8 months ago

When I try to lint my files that contain lines like this:

import "google/api/annotations.proto";

When trying to run the linter, I get this error:

2024/03/18 11:30:05 test/test.proto:5:8: open google/api/annotations.proto: no such file or directory

How are people solving for this? Do I have to store all of the googleapis I use locally? Any recommendations for how to manage this dependency?

noahdietz commented 7 months ago

Do I have to store all of the googleapis I use locally?

Simply, yes, less simply, download only those protos from googleapis that you make use of. This is what protobuf dictates for imports: https://protobuf.dev/programming-guides/proto3/#importing

Then in use the linter include flag (-I, --proto-path, mirror's protoc's own flags for the same purpose) to include it in the execution.