Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support json_names_for_fields in starlark rule protoc_gen_swagger #1077

Merged
merged 2 commits into from
Nov 5, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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