Skip to content

Commit e66d4f0

Browse files
authored
Merge pull request #64 from BradHolmes/correct-client-setup
fix: Push OpenaAPI generator client version choice down to the bazel client
2 parents ba8871c + 4d29dd4 commit e66d4f0

19 files changed

+2543
-1991
lines changed

.bcr/metadata.template.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"homepage": "https://github.com/OpenAPITools/openapi-generator-bazel",
3+
"maintainers": [
4+
{
5+
"name": "William Cheng",
6+
"email": "wing328hk@gmail.com",
7+
"github": "wing328"
8+
},
9+
{
10+
"name": "Christian Behon",
11+
"email": "christian.behon@knusperleicht.at",
12+
"github": "nucle"
13+
},
14+
{
15+
"name": "Brad Holmes",
16+
"email": "bradholmes04@gmail.com",
17+
"github": "BradHolmes"
18+
}
19+
],
20+
"repository": [
21+
"github:OpenAPITools/openapi-generator-bazel"
22+
],
23+
"versions": [],
24+
"yanked_versions": {}
25+
}
26+

.bazelci/presubmit.yml renamed to .bcr/presubmit.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
tasks:
33
ubuntu1804:
44
build_targets:
5-
- "..."
5+
- "//:*"
66
test_targets:
7-
- "..."
7+
- "//:*"
88
macos:
99
build_targets:
10-
- "..."
10+
- "//:*"
1111
test_targets:
12-
- "..."
12+
- "//:*"

.bcr/source.template.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"integrity": "",
3+
"strip_prefix": "{REPO}-{VERSION}",
4+
"url": "https://github.com/{OWNER}/{REPO}/releases/download/{TAG}/{REPO}-{TAG}.tar.gz"
5+
}

.github/workflows/ci.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,8 @@ jobs:
3434
cd internal/test/bcr
3535
bazel mod path
3636
bazel build //...
37+
38+
- name: Integration BCR with older version
39+
run: |
40+
cd internal/test/bcr-custom-version
41+
bazel build //...

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [0.2.0] - 2025-03-18
9+
10+
### Added
11+
12+
- Add CI to automatically publish to BCR
13+
- Update to support bazel v7+, and register in BCR

MODULE.bazel

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
module(
22
name = "openapi_tools_generator_bazel",
3-
version = "0.1.7",
3+
version = "0.2.0",
44
compatibility_level = 0,
55
)
66

77
bazel_dep(name = "rules_pkg", version = "1.0.1")
88
openapi_gen = use_extension("@openapi_tools_generator_bazel//:extension.bzl", "openapi_gen")
9-
openapi_gen.client()
109
use_repo(openapi_gen, "openapi_tools_generator_bazel_cli")
1110

MODULE.bazel.lock

Lines changed: 133 additions & 427 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,22 @@ If you find this project useful, please kindly consider supporting this project
88

99
## Quickstart
1010

11-
To use the Bazel bindings provided by this repo within a Bazel workspace,
12-
you must do the following steps:
11+
As of v0.1.8, this only supports [Bazel Modules](https://bazel.build/external/module). The setup is much simpler.
1312

14-
1. Add the following code to your WORKSPACE file at the root of your repository
13+
1. Add the following code to your `MODULE.bazel` file at the root of your repository
1514

16-
```
17-
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
18-
19-
http_archive(
20-
name = "openapi_tools_generator_bazel",
21-
sha256 = "ada94694b10f2503c52a48427bd8589323bff5910bd1a7e5212ce34702d0af65",
22-
urls = ["https://github.com/OpenAPITools/openapi-generator-bazel/releases/download/v0.1.7/openapi-tools-generator-bazel-0.1.7.tar.gz"],
23-
)
24-
25-
load("@openapi_tools_generator_bazel//:defs.bzl", "openapi_tools_generator_bazel_repositories")
15+
```
16+
bazel_dep(name = "openapi_tools_generator_bazel", version = "0.1.8")
17+
openapi_gen = use_extension("@openapi_tools_generator_bazel//:extension.bzl", "openapi_gen")
18+
openapi_gen.client(
19+
sha256 = "f18d771e98f2c5bb169d1d1961de4f94866d2901abc1e16177dd7e9299834721",
20+
version = "6.5.0",
21+
)
22+
use_repo(openapi_gen, "openapi_tools_generator_bazel_cli")
2623
27-
# You can provide any version of the CLI that has been uploaded to Maven
28-
openapi_tools_generator_bazel_repositories(
29-
openapi_generator_cli_version = "5.1.0",
30-
sha256 = "62f9842f0fcd91e4afeafc33f19a7af41f2927c7472c601310cedfc72ff1bb19"
31-
)
32-
```
24+
# Or, to use the default client (currently 7.2.0), remove the parameters to client().
25+
openapi_gen.client()
26+
```
3327

3428
2. Create a BUILD.bazel file next to the .yaml file you wish to generate code from.
3529
The below example generates a go library within a generated directory named `petstore_go`

internal/test/basic/MODULE.bazel

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module(
2+
name = "openapi_tools_generator_bazel_bcr_tests",
3+
version = "1.2.3",
4+
)
5+
6+
bazel_dep(name = "openapi_tools_generator_bazel", version = "")
7+
local_path_override(
8+
module_name = "openapi_tools_generator_bazel",
9+
path = "../../..",
10+
)
11+
openapi_gen = use_extension("@openapi_tools_generator_bazel//:extension.bzl", "openapi_gen")
12+
openapi_gen.client()
13+
use_repo(openapi_gen, "openapi_tools_generator_bazel_cli")
14+

internal/test/basic/MODULE.bazel.lock

Lines changed: 275 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
bazel-bcr
2+
bazel-bin
3+
bazel-out
4+
bazel-testlogs
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
load("@openapi_tools_generator_bazel//:defs.bzl", "openapi_generator")
2+
3+
openapi_generator(
4+
name = "pylib",
5+
config = "config.yaml",
6+
spec = "petstore.yaml",
7+
generator = "python",
8+
)
9+
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
module(
2+
name = "openapi_tools_generator_bazel_bcr_tests",
3+
version = "1.2.3",
4+
)
5+
6+
bazel_dep(name = "openapi_tools_generator_bazel", version = "")
7+
local_path_override(
8+
module_name = "openapi_tools_generator_bazel",
9+
path = "../../..",
10+
)
11+
openapi_gen = use_extension("@openapi_tools_generator_bazel//:extension.bzl", "openapi_gen")
12+
openapi_gen.client(
13+
sha256 = "f18d771e98f2c5bb169d1d1961de4f94866d2901abc1e16177dd7e9299834721",
14+
version = "6.5.0",
15+
)
16+
use_repo(openapi_gen, "openapi_tools_generator_bazel_cli")
17+

0 commit comments

Comments
 (0)