Skip to content

Commit

Permalink
add reserved-words-mappings parameter (#33)
Browse files Browse the repository at this point in the history
* add reserved-words-mappings parameter

Add the option to pass the `--reserved-words-mappings` flag
to the generator.

* Update openapi_generator.bzl

* test

* Update openapi_generator.bzl
  • Loading branch information
worxli authored Jan 12, 2022
1 parent fc7a691 commit fb7e302
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions internal/openapi_generator.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ def _new_generator_command(ctx, declared_dir, rjars):
gen_cmd += ' --type-mappings "{mappings}"'.format(
mappings = _comma_separated_pairs(ctx.attr.type_mappings),
)

gen_cmd += ' --reserved-words-mappings "{reserved_words_mappings}"'.format(
reserved_words_mappings = ",".join(ctx.attr.reserved_words_mappings),
)

if ctx.attr.api_package:
gen_cmd += " --api-package {package}".format(
Expand Down Expand Up @@ -161,6 +165,7 @@ _openapi_generator = rule(
"system_properties": attr.string_dict(),
"engine": attr.string(),
"type_mappings": attr.string_dict(),
"reserved_words_mappings": attr.string_list(),
"is_windows": attr.bool(mandatory = True),
"_jdk": attr.label(
default = Label("@bazel_tools//tools/jdk:current_java_runtime"),
Expand Down
10 changes: 10 additions & 0 deletions internal/test/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,13 @@ openapi_generator(
"Integer": "java.math.BigDecimal",
},
)

openapi_generator(
name = "petstore_java_reserved_words",
generator = "java",
spec = "petstore.yaml",
reserved_words_mappings = [
"interface=interface",
],
)

0 comments on commit fb7e302

Please sign in to comment.