Skip to content

Commit f075d2b

Browse files
authored
Merge pull request #72 from MoonWalkerAZ/master
Add: support for --name-mappings parameter.
2 parents 781192c + 4903314 commit f075d2b

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

internal/openapi_generator.bzl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ def _new_generator_command(ctx, declared_dir, rjars):
5151
reserved_words_mappings = ",".join(ctx.attr.reserved_words_mappings),
5252
)
5353

54+
if ctx.attr.name_mappings:
55+
gen_cmd += ' --name-mappings "{mappings}"'.format(
56+
mappings = _comma_separated_pairs(ctx.attr.name_mappings),
57+
)
58+
5459
if ctx.attr.config:
5560
gen_cmd += " --config {config}".format(
5661
config = ctx.attr.config.files.to_list()[0].path,
@@ -170,6 +175,7 @@ _openapi_generator = rule(
170175
"system_properties": attr.string_dict(),
171176
"engine": attr.string(),
172177
"type_mappings": attr.string_dict(),
178+
"name_mappings": attr.string_dict(),
173179
"import_mappings": attr.string_dict(),
174180
"reserved_words_mappings": attr.string_list(),
175181
"is_windows": attr.bool(mandatory = True),

internal/test/basic/BUILD.bazel

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,32 +45,42 @@ openapi_generator(
4545
openapi_generator(
4646
name = "petstore_java_reserved_words",
4747
generator = "java",
48-
spec = "petstore.yaml",
4948
reserved_words_mappings = [
5049
"interface=interface",
5150
],
51+
spec = "petstore.yaml",
5252
)
5353

5454
openapi_generator(
5555
name = "petstore_python_flask_with_config_tag",
56+
config = "config.yaml",
5657
generator = "python-flask",
5758
spec = "petstore.yaml",
58-
config = "config.yaml"
5959
)
6060

6161
openapi_generator(
6262
name = "petstore_python_flask_with_template_dir",
6363
generator = "python-flask",
6464
spec = "petstore.yaml",
65-
template_dir = "python-templates"
65+
template_dir = "python-templates",
6666
)
6767

6868
openapi_generator(
6969
name = "petstore_java_import_mappings",
7070
generator = "java",
71-
spec = "petstore.yaml",
7271
import_mappings = {
7372
"Date": "java.time.LocalDate",
7473
"DateTime": "java.time.OffsetDateTime",
7574
},
75+
spec = "petstore.yaml",
76+
)
77+
78+
openapi_generator(
79+
name = "petstore_java_name_mappings",
80+
generator = "java",
81+
name_mappings = {
82+
"code": "statusCode",
83+
"message": "statusMessage",
84+
},
85+
spec = "petstore.yaml",
7686
)

0 commit comments

Comments
 (0)