Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .bcr/metadata.template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"homepage": "https://github.com/OpenAPITools/openapi-generator-bazel",
"maintainers": [
{
"name": "William Cheng",
"email": "wing328hk@gmail.com",
"github": "wing328"
},
{
"name": "Christian Behon",
"email": "christian.behon@knusperleicht.at",
"github": "nucle"
},
{
"name": "Brad Holmes",
"email": "bradholmes04@gmail.com",
"github": "BradHolmes"
}
],
"repository": [
"github:OpenAPITools/openapi-generator-bazel"
],
"versions": [],
"yanked_versions": {}
}

8 changes: 4 additions & 4 deletions .bazelci/presubmit.yml → .bcr/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
tasks:
ubuntu1804:
build_targets:
- "..."
- "//:*"
test_targets:
- "..."
- "//:*"
macos:
build_targets:
- "..."
- "//:*"
test_targets:
- "..."
- "//:*"
5 changes: 5 additions & 0 deletions .bcr/source.template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"integrity": "",
"strip_prefix": "{REPO}-{VERSION}",
"url": "https://github.com/{OWNER}/{REPO}/releases/download/{TAG}/{REPO}-{TAG}.tar.gz"
}
5 changes: 5 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,8 @@ jobs:
cd internal/test/bcr
bazel mod path
bazel build //...

- name: Integration BCR with older version
run: |
cd internal/test/bcr-custom-version
bazel build //...
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.2.0] - 2025-03-18

### Added

- Add CI to automatically publish to BCR
- Update to support bazel v7+, and register in BCR
3 changes: 1 addition & 2 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
module(
name = "openapi_tools_generator_bazel",
version = "0.1.7",
version = "0.2.0",
compatibility_level = 0,
)

bazel_dep(name = "rules_pkg", version = "1.0.1")
openapi_gen = use_extension("@openapi_tools_generator_bazel//:extension.bzl", "openapi_gen")
openapi_gen.client()
use_repo(openapi_gen, "openapi_tools_generator_bazel_cli")

560 changes: 133 additions & 427 deletions MODULE.bazel.lock

Large diffs are not rendered by default.

32 changes: 13 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,22 @@ If you find this project useful, please kindly consider supporting this project

## Quickstart

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

1. Add the following code to your WORKSPACE file at the root of your repository
1. Add the following code to your `MODULE.bazel` file at the root of your repository

```
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "openapi_tools_generator_bazel",
sha256 = "ada94694b10f2503c52a48427bd8589323bff5910bd1a7e5212ce34702d0af65",
urls = ["https://github.com/OpenAPITools/openapi-generator-bazel/releases/download/v0.1.7/openapi-tools-generator-bazel-0.1.7.tar.gz"],
)

load("@openapi_tools_generator_bazel//:defs.bzl", "openapi_tools_generator_bazel_repositories")
```
bazel_dep(name = "openapi_tools_generator_bazel", version = "0.1.8")
openapi_gen = use_extension("@openapi_tools_generator_bazel//:extension.bzl", "openapi_gen")
openapi_gen.client(
sha256 = "f18d771e98f2c5bb169d1d1961de4f94866d2901abc1e16177dd7e9299834721",
version = "6.5.0",
)
use_repo(openapi_gen, "openapi_tools_generator_bazel_cli")

# You can provide any version of the CLI that has been uploaded to Maven
openapi_tools_generator_bazel_repositories(
openapi_generator_cli_version = "5.1.0",
sha256 = "62f9842f0fcd91e4afeafc33f19a7af41f2927c7472c601310cedfc72ff1bb19"
)
```
# Or, to use the default client (currently 7.2.0), remove the parameters to client().
openapi_gen.client()
```

2. Create a BUILD.bazel file next to the .yaml file you wish to generate code from.
The below example generates a go library within a generated directory named `petstore_go`
Expand Down
14 changes: 14 additions & 0 deletions internal/test/basic/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module(
name = "openapi_tools_generator_bazel_bcr_tests",
version = "1.2.3",
)

bazel_dep(name = "openapi_tools_generator_bazel", version = "")
local_path_override(
module_name = "openapi_tools_generator_bazel",
path = "../../..",
)
openapi_gen = use_extension("@openapi_tools_generator_bazel//:extension.bzl", "openapi_gen")
openapi_gen.client()
use_repo(openapi_gen, "openapi_tools_generator_bazel_cli")

275 changes: 275 additions & 0 deletions internal/test/basic/MODULE.bazel.lock

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions internal/test/bcr-custom-version/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
bazel-bcr
bazel-bin
bazel-out
bazel-testlogs
9 changes: 9 additions & 0 deletions internal/test/bcr-custom-version/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
load("@openapi_tools_generator_bazel//:defs.bzl", "openapi_generator")

openapi_generator(
name = "pylib",
config = "config.yaml",
spec = "petstore.yaml",
generator = "python",
)

17 changes: 17 additions & 0 deletions internal/test/bcr-custom-version/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module(
name = "openapi_tools_generator_bazel_bcr_tests",
version = "1.2.3",
)

bazel_dep(name = "openapi_tools_generator_bazel", version = "")
local_path_override(
module_name = "openapi_tools_generator_bazel",
path = "../../..",
)
openapi_gen = use_extension("@openapi_tools_generator_bazel//:extension.bzl", "openapi_gen")
openapi_gen.client(
sha256 = "f18d771e98f2c5bb169d1d1961de4f94866d2901abc1e16177dd7e9299834721",
version = "6.5.0",
)
use_repo(openapi_gen, "openapi_tools_generator_bazel_cli")

Loading