Skip to content

Commit fb7e302

Browse files
authored
add reserved-words-mappings parameter (#33)
* 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
1 parent fc7a691 commit fb7e302

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

internal/openapi_generator.bzl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ def _new_generator_command(ctx, declared_dir, rjars):
5959
gen_cmd += ' --type-mappings "{mappings}"'.format(
6060
mappings = _comma_separated_pairs(ctx.attr.type_mappings),
6161
)
62+
63+
gen_cmd += ' --reserved-words-mappings "{reserved_words_mappings}"'.format(
64+
reserved_words_mappings = ",".join(ctx.attr.reserved_words_mappings),
65+
)
6266

6367
if ctx.attr.api_package:
6468
gen_cmd += " --api-package {package}".format(
@@ -161,6 +165,7 @@ _openapi_generator = rule(
161165
"system_properties": attr.string_dict(),
162166
"engine": attr.string(),
163167
"type_mappings": attr.string_dict(),
168+
"reserved_words_mappings": attr.string_list(),
164169
"is_windows": attr.bool(mandatory = True),
165170
"_jdk": attr.label(
166171
default = Label("@bazel_tools//tools/jdk:current_java_runtime"),

internal/test/BUILD.bazel

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,13 @@ openapi_generator(
4141
"Integer": "java.math.BigDecimal",
4242
},
4343
)
44+
45+
openapi_generator(
46+
name = "petstore_java_reserved_words",
47+
generator = "java",
48+
spec = "petstore.yaml",
49+
reserved_words_mappings = [
50+
"interface=interface",
51+
],
52+
)
53+

0 commit comments

Comments
 (0)