rules_openapi
API reference, generated from the module’s .bzl docstrings (stardoc).
OpenAPI plugin conformance test.
openapi_plugin_contract_test(name, plugin) runs the rules_openapi
plugin contract scenarios against any plugin executable. Mirrors
rules_jsonschema’s jsonschema_plugin_contract_test but with
OpenAPI-flavored fixtures (a minimal OpenAPI 3.1 document instead
of a JSON Schema).
openapi_plugin_contract_test
load("@rules_openapi//openapi:contract_test.bzl", "openapi_plugin_contract_test")
openapi_plugin_contract_test(name, plugin)
Run the rules_openapi plugin contract scenarios against a plugin binary.
ATTRIBUTES
| Name | Description | Type | Mandatory | Default |
|---|---|---|---|---|
| name | A unique name for this target. | Name | required | |
| plugin | The plugin binary to test. | Label | required |
Rust user-facing rules for rules_openapi.
openapi_rust_client is the Rust client codegen rule:
- Resolves the
rust_client_codegen_toolchain_typetoolchain. - Runs the toolchain’s binary on the OpenAPI spec (stdin/argv/
stdout per
//openapi/plugin_contract.md), producing a.rs. - Wraps the
.rsin arust_librarywhose deps includeprogenitor-client,reqwest,serde,serde_json, and any additional crates the consumer threads through.
The default toolchain (registered by MODULE.bazel) points at the
in-repo openapi_to_rust_client binary, which wraps progenitor
under the hood. Swap by declaring your own openapi_codegen_toolchain
and registering it ahead of the default.
openapi_rust_client
load("@rules_openapi//rust:defs.bzl", "openapi_rust_client")
openapi_rust_client(name, spec, extra_args, progenitor_client, reqwest, serde, serde_json, regress,
visibility, **rust_library_kwargs)
Generate a rust_library of a typed OpenAPI HTTP client.
The library exports a Client struct with one method per
OpenAPI operation, plus a types module containing serde
structs for components/schemas.
PARAMETERS
Providers exposed by rules_openapi.
Same shape as rules_jsonschema’s JsonschemaCodegenToolchainInfo —
the plugin contract is identical (stdin/argv/stdout), the only
difference is the schema content shipped on stdin (OpenAPI document
rather than a JSON Schema).
OpenapiCodegenToolchainInfo
load("@rules_openapi//openapi:providers.bzl", "OpenapiCodegenToolchainInfo")
OpenapiCodegenToolchainInfo(binary)
An OpenAPI → code codegen tool.
FIELDS
| Name | Description |
|---|---|
| binary | File: the codegen executable. Invoked with --schema-name=NAME --rule-name=NAME plus per-plugin flags the calling rule passes through. |
Toolchain rules for rules_openapi codegen.
openapi_codegen_toolchain wraps a single codegen executable as a
Bazel toolchain. Toolchain types are split per (language, use_case)
pair — Rust clients, Go clients, Rust servers, etc. — so a consumer
can swap one plugin without affecting the rest.
Default toolchains are registered in the per-language directories
(//rust:BUILD.bazel, …). To swap an implementation, declare your
own openapi_codegen_toolchain and register_toolchains(...) it
ahead of rules_openapi’s default in your MODULE.bazel.
openapi_codegen_toolchain
load("@rules_openapi//openapi:toolchains.bzl", "openapi_codegen_toolchain")
openapi_codegen_toolchain(name, binary)
Declare an OpenAPI → code codegen executable as a Bazel toolchain.
ATTRIBUTES