Skip to main content

Module openapi

Module openapi 

Source
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§

OpenApiEndpoint
HTTP endpoint details extracted from an OpenAPI spec.
OpenApiParam
A single parameter from an OpenAPI spec.
OpenApiTool
A parsed OpenAPI endpoint with its corresponding tool definition.

Enums§

HttpMethod
HTTP method for an OpenAPI endpoint.
OpenApiAuth
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.