diff --git a/protoc-gen-swagger/defs.bzl b/protoc-gen-swagger/defs.bzl index 4dfca37fdac..652e4a20b1a 100644 --- a/protoc-gen-swagger/defs.bzl +++ b/protoc-gen-swagger/defs.bzl @@ -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 @@ -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: @@ -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, ), ), )] @@ -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,