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 authored and johanbrandhorst committed May 7, 2019
1 parent 5df6532 commit ab421d1
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 @@ -46,11 +46,15 @@ def _run_proto_gen_swagger(ctx, direct_proto_srcs, transitive_proto_srcs, action
options.append("grpc_api_configuration=%s" % grpc_api_configuration.path)
inputs.append(grpc_api_configuration)

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

includes = _collect_includes(ctx.genfiles_dir.path, direct_proto_srcs + transitive_proto_srcs)

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 ab421d1

Please sign in to comment.