Use buf to generate definitions for dependencies #2970
-
Hi, I've recently discovered the My project depends on a third-party API that ships with a buf generate https://github.com/third-party/api.git
# alternatively pulling the module from BSR
buf generate buf.build/third-party/api When I call # buf.yaml in my project
version: v1
breaking:
use:
- FILE
lint:
use:
- DEFAULT
deps:
- buf.build/third-party/api
# buf.gen.yaml
version: v1
plugins:
- name: php
out: var/ However, when I run buf mod update
buf generate --debug --verbose
DEBUG get_ref {"duration": "38.037µs"}
DEBUG get_config {"duration": "147.738µs"}
DEBUG get_config {"duration": "491.131µs"}
DEBUG get_config {"duration": "79.544µs"}
DEBUG get_module_config {"duration": "1.626034ms"}
DEBUG command {"duration": "43.218858ms"}
Failure: no .proto target files found Any advice? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
If you are just trying to use/call APIs defined in modules outside of your project, then you just need to define and configure your own With v1 buf.gen.yaml, if you want to generate code for multiple inputs, you need to call We just released a v2 format for buf.gen.yaml which makes this use case easier, so recommend you checking that out too. For completeness, Generated SDKs are another option. They make it possible to download generated code directly from the BSR for your language so you don't need to manage code generation at all. Generated SDKs doesn't support PHP though, and it looks like you might be trying to generate PHP code so this might not be an option for you, but I wanted to mention this in case you ever need to generate for other languages. Hope that helps! |
Beta Was this translation helpful? Give feedback.
buf.yaml
is for declaring a Protobuf module. If you have no proto files in your repo, then you don't need abuf.yaml
.If you are just trying to use/call APIs defined in modules outside of your project, then you just need to define and configure your own
buf.gen.yaml
and callbuf generate
.With v1 buf.gen.yaml, if you want to generate code for multiple inputs, you need to call
buf generate
multiple times (and have a separatebuf.gen.yaml
for each invocation ofbuf generate
.We just released a v2 format for buf.gen.yaml which makes this use case easier, so recommend you checking that out too.
For completeness, Generated SDKs are another op…