forked from googlemaps/openapi-specification
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BUILD.bazel
140 lines (126 loc) · 3.15 KB
/
BUILD.bazel
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
load("//rules:swagger_cli.bzl", "bundle", "validate")
load("@rules_pkg//:pkg.bzl", "pkg_tar")
load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_test")
load("@npm//openapi-examples-validator:index.bzl", "openapi_examples_validator_test")
load("@npm//openapi-to-postmanv2:index.bzl", "openapi2postmanv2")
exports_files(
["tsconfig.json"],
visibility = ["//visibility:public"],
)
BUNDLE_NAME = "google-maps-platform-openapi3"
# has .yml and .json outputs
bundle(
name = BUNDLE_NAME,
data = ["//specification:openapi3"],
entry = "$(locations //specification:openapi3)/index.yml",
)
validate(
name = "validate_yml_test",
data = "//:{}.yml".format(BUNDLE_NAME),
)
validate(
name = "validate_json_test",
data = "//:{}.json".format(BUNDLE_NAME),
)
pkg_tar(
name = "dist",
srcs = [
"//:{}.yml".format(BUNDLE_NAME),
"//:{}.json".format(BUNDLE_NAME),
"//:google-maps-platform-postman.json",
],
strip_prefix = ".",
deps = [
"//generator/documentation:parameters.tar",
"//generator/documentation:schemas.tar",
"//generator/requests:snippets.tar",
],
)
filegroup(
name = "outputs",
srcs = [
":dist",
":parameters",
],
)
# test diff
filegroup(
name = "dist_files",
srcs = glob(["dist/**/*"]),
)
nodejs_test(
name = "dist-is-updated",
data = [
":dist",
":dist_files",
"//rules:dist-is-updated",
],
entry_point = "//rules:dist-is-updated.ts",
templated_args = [
"--archive",
"$(rootpath :dist)",
"--dist",
"$(locations :dist_files)",
],
)
openapi_examples_validator_test(
name = "validate_examples",
data = ["//:{}.json".format(BUNDLE_NAME)],
templated_args = [
"--no-additional-properties",
"$(rootpath //:{}.json)".format(BUNDLE_NAME),
],
)
nodejs_test(
name = "schema-in-index",
data = [
":dist",
"//rules:schema-in-index",
"//specification:openapi3",
],
entry_point = "//rules:schema-in-index.ts",
templated_args = [
"--archive",
"$(rootpath :dist)",
],
)
nodejs_test(
name = "schema-title",
data = [
"//:google-maps-platform-openapi3.json",
"//rules:schema-title",
],
entry_point = "//rules:schema-title.ts",
templated_args = [
"--spec",
"$(rootpath //:{}.json)".format(BUNDLE_NAME),
],
)
openapi2postmanv2(
name = "postman",
outs = ["google-maps-platform-postman.json"],
args = [
"--spec",
"$(location //:google-maps-platform-openapi3.json)",
"--pretty",
"--options-config",
"$(location //:postman-config.json)",
"--output $@",
],
data = [
"//:google-maps-platform-openapi3.json",
"//:postman-config.json",
],
visibility = ["//visibility:public"],
)
genrule(
name = "parameters",
srcs = [
"//specification:openapi3",
"@npm//glob",
"@npm//yargs",
],
outs = ["parameters.yml"],
cmd = "$(location //rules:parameters) --output $@ $(locations //specification:openapi3)",
tools = ["//rules:parameters"],
)