Skip to content

Commit

Permalink
support json_names_for_fields
Browse files Browse the repository at this point in the history
  • Loading branch information
prestonvanloon authored and achew22 committed Nov 5, 2019
1 parent e4d09fd commit 25b3cf0
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion protoc-gen-swagger/defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def _collect_includes(gen_dir, srcs):

return includes

def _run_proto_gen_swagger(ctx, direct_proto_srcs, transitive_proto_srcs, actions, protoc, protoc_gen_swagger, grpc_api_configuration, single_output):
def _run_proto_gen_swagger(ctx, direct_proto_srcs, transitive_proto_srcs, actions, protoc, protoc_gen_swagger, grpc_api_configuration, single_output, json_names_for_fields):
swagger_files = []

inputs = direct_proto_srcs + transitive_proto_srcs
Expand All @@ -41,6 +41,9 @@ 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)

if json_names_for_fields:
options.append("json_names_for_fields=true")

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

if single_output:
Expand Down Expand Up @@ -117,6 +120,7 @@ def _proto_gen_swagger_impl(ctx):
protoc_gen_swagger = ctx.executable._protoc_gen_swagger,
grpc_api_configuration = grpc_api_configuration,
single_output = ctx.attr.single_output,
json_names_for_fields = ctx.attr.json_names_for_fields,
),
),
)]
Expand All @@ -136,6 +140,10 @@ protoc_gen_swagger = rule(
default = False,
mandatory = False,
),
"json_names_for_fields": attr.bool(
default = False,
mandatory = False,
),
"_protoc": attr.label(
default = "@com_google_protobuf//:protoc",
executable = True,
Expand Down

0 comments on commit 25b3cf0

Please sign in to comment.