Skip to content

Commit b1dffd8

Browse files
author
Elena Deneva
committed
Run proto gen swagger with protos from external repository
Currently the protoc_gen_swagger doesn't work with protos from external repositories. The bazel rule because the swagger.json file is not stored at the expected place. Example if the rule for the proto @remote//proto:action_proto is passed to the protoc_gen_swagger, the action.swagger.json file is written to proto/action.swagger.json and is expected to be at the same place as the proto external/remote/proto/action.swagger.json.
1 parent 52a539e commit b1dffd8

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

protoc-gen-swagger/defs.bzl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ def _run_proto_gen_swagger(ctx, direct_proto_srcs, transitive_proto_srcs, action
3838
sibling = proto,
3939
)
4040

41+
output_dir = ctx.bin_dir.path
42+
if proto.owner.workspace_root:
43+
output_dir = "/".join([output_dir, proto.owner.workspace_root])
44+
4145
inputs = direct_proto_srcs + transitive_proto_srcs
4246
tools = [protoc_gen_swagger]
4347

@@ -50,7 +54,7 @@ def _run_proto_gen_swagger(ctx, direct_proto_srcs, transitive_proto_srcs, action
5054

5155
args = actions.args()
5256
args.add("--plugin=%s" % protoc_gen_swagger.path)
53-
args.add("--swagger_out=%s:%s" % (",".join(options), ctx.bin_dir.path))
57+
args.add("--swagger_out=%s:%s" % (",".join(options), output_dir))
5458
args.add_all(["-I%s" % include for include in includes])
5559
args.add(proto.path)
5660

0 commit comments

Comments
 (0)