https://github.com/openapitools/openapi-generator-bazel
Bazel plugin for OpenAPI Generator
https://github.com/openapitools/openapi-generator-bazel
Last synced: 4 months ago
JSON representation
Bazel plugin for OpenAPI Generator
- Host: GitHub
- URL: https://github.com/openapitools/openapi-generator-bazel
- Owner: OpenAPITools
- License: apache-2.0
- Created: 2019-10-18T21:42:30.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2025-03-06T09:30:43.000Z (10 months ago)
- Last Synced: 2025-03-06T10:32:22.912Z (10 months ago)
- Language: Starlark
- Size: 59.6 KB
- Stars: 67
- Watchers: 10
- Forks: 52
- Open Issues: 14
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## This project is looking for maintainers. Please refer to the [announcement](https://github.com/OpenAPITools/openapi-generator-bazel/issues/60) for more information.
# OpenAPI Generator Bazel
This repo was created to integrate the OpenAPI code generation CLI with Bazel.
If you find this project useful, please kindly consider supporting this project financially via https://opencollective.com/openapi_generator :pray:
## Quickstart
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 `MODULE.bazel` file at the root of your repository
```
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")
# 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`
```
load("@openapi_tools_generator_bazel//:defs.bzl", "openapi_generator")
openapi_generator(
name = "petstore_go",
generator = "go",
spec = "petstore.yaml",
)
```