From 57089bcd823029c032dfab1a53735194abfd9773 Mon Sep 17 00:00:00 2001 From: Johan Brandhorst Date: Sun, 24 May 2020 22:44:41 +0100 Subject: [PATCH] protoc-gen-swagger: update bazel rule json_names_for_fields defaults to true now --- docs/_docs/v2-migration.md | 2 ++ protoc-gen-swagger/defs.bzl | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/_docs/v2-migration.md b/docs/_docs/v2-migration.md index 8e1b749f7d1..fde14f82124 100644 --- a/docs/_docs/v2-migration.md +++ b/docs/_docs/v2-migration.md @@ -39,6 +39,8 @@ To change the swagger generator behaviour to match, set `json_names_for_fields=f --swagger_out=json_names_for_fields=false:./gen/swagger path/to/my/proto/v1/myproto.proto ``` +If using the Bazel rule, set `json_names_for_fields=False`. + ## We now emit default vaules for all fields See [the original issue](https://github.com/grpc-ecosystem/grpc-gateway/issues/233) diff --git a/protoc-gen-swagger/defs.bzl b/protoc-gen-swagger/defs.bzl index 2cb1f22fdda..be6c7d3b4f1 100644 --- a/protoc-gen-swagger/defs.bzl +++ b/protoc-gen-swagger/defs.bzl @@ -66,8 +66,8 @@ def _run_proto_gen_swagger( extra_inputs.append(grpc_api_configuration) args.add("--swagger_opt", "grpc_api_configuration=%s" % grpc_api_configuration.path) - if json_names_for_fields: - args.add("--swagger_opt", "json_names_for_fields=true") + if not json_names_for_fields: + args.add("--swagger_opt", "json_names_for_fields=false") proto_file_infos = _direct_source_infos(proto_info) @@ -173,7 +173,7 @@ protoc_gen_swagger = rule( mandatory = False, ), "json_names_for_fields": attr.bool( - default = False, + default = True, mandatory = False, ), "_protoc": attr.label(