Skip to content

Commit

Permalink
Run proto gen swagger with protos from external repository
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Elena Deneva committed Apr 18, 2019
1 parent 52a539e commit b1dffd8
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion protoc-gen-swagger/defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ def _run_proto_gen_swagger(ctx, direct_proto_srcs, transitive_proto_srcs, action
sibling = proto,
)

output_dir = ctx.bin_dir.path
if proto.owner.workspace_root:
output_dir = "/".join([output_dir, proto.owner.workspace_root])

inputs = direct_proto_srcs + transitive_proto_srcs
tools = [protoc_gen_swagger]

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

args = actions.args()
args.add("--plugin=%s" % protoc_gen_swagger.path)
args.add("--swagger_out=%s:%s" % (",".join(options), ctx.bin_dir.path))
args.add("--swagger_out=%s:%s" % (",".join(options), output_dir))
args.add_all(["-I%s" % include for include in includes])
args.add(proto.path)

Expand Down

0 comments on commit b1dffd8

Please sign in to comment.