Expand description
OpenAPI 3 spec → tool descriptor conversion. OpenAPI Tool Generation — Automatically create tools from OpenAPI 3.x specs
Parses OpenAPI specifications and generates Tool definitions that can
be registered in a ToolRegistry and executed by agents.
§Feature Gate
This module requires the openapi feature:
brainwires-tools = { version = "0.10", features = ["openapi"] }§Usage
ⓘ
use brainwires_tool_runtime::openapi::{openapi_to_tools, execute_openapi_tool, OpenApiAuth};
// Parse spec and get tools
let spec_json = std::fs::read_to_string("openapi.json")?;
let api_tools = openapi_to_tools(&spec_json)?;
// Register tools
for api_tool in &api_tools {
registry.register(api_tool.tool.clone());
}
// Execute a tool call
let result = execute_openapi_tool(
&api_tools[0],
&args,
&reqwest::Client::new(),
Some(&OpenApiAuth::Bearer("token".into())),
).await?;Structs§
- Open
ApiEndpoint - HTTP endpoint details extracted from an OpenAPI spec.
- Open
ApiParam - A single parameter from an OpenAPI spec.
- Open
ApiTool - A parsed OpenAPI endpoint with its corresponding tool definition.
Enums§
- Http
Method - HTTP method for an OpenAPI endpoint.
- Open
ApiAuth - Authentication configuration for OpenAPI tool execution.
Functions§
- execute_
openapi_ tool - Execute an OpenAPI tool by making the HTTP request.
- openapi_
to_ tools - Parse an OpenAPI 3.x JSON or YAML spec and generate tool definitions.