Expand description
gadk-openapi: an OpenAPI 3.0 and 3.1 toolset for gadk agents.
Load a document with OpenApiSpec (from a string with str::parse, a file with
OpenApiSpec::from_file, or a URL with OpenApiSpec::fetch), then build an
OpenApiToolset with an OpenApiConfig. Each operation becomes one tool, named after
its operationId in snake_case. A tool’s arguments are the operation’s path, query and
header parameters plus body for an application/json request body; a call returns
{"status": <u16>, "body": <body>} for any HTTP status. Redirects are not followed: a 3xx
response is returned as a result.
Calls of post, put, patch and delete operations need the user’s confirmation by
default (RequireConfirmation::Mutating). Credentials come from a gadk_auth credential
provider (OpenApiConfig::auth) or an API key in the query string
(OpenApiConfig::query_api_key).
use gadk_openapi::{OpenApiConfig, OpenApiSpec, OpenApiToolset};
let spec = OpenApiSpec::fetch("https://petstore3.swagger.io/api/v3/openapi.json").await?;
let toolset = OpenApiToolset::new(&spec, OpenApiConfig::new().prefix("petstore"))?;
for skipped in toolset.skipped_operations() {
println!("skipped {} {}: {}", skipped.method, skipped.path, skipped.reason);
}Out of scope: Swagger 2.0, remote $refs, cookie parameters, form and multipart bodies,
choosing credentials from securitySchemes, response schemas and streaming responses.
Structs§
- Open
ApiConfig - How
OpenApiToolsetcalls the API. Start fromOpenApiConfig::new(the same asDefault) and chain the builder methods. - Open
ApiSpec - An OpenAPI 3.0 or 3.1 document, parsed from JSON or YAML.
- Open
ApiToolset - The operations of one OpenAPI document as a
Toolsetnamedopenapi_toolset: one tool per operation, in document order. - Skipped
Operation - An operation that does not become a tool, and why.
Enums§
- Error
- An error loading an OpenAPI document, building the toolset, or sending a tool’s request.
- Require
Confirmation - Which tool calls need the user’s confirmation before the request is sent.
Constants§
- DEFAULT_
MAX_ RESPONSE_ BYTES - The default largest response body kept in a tool result, in bytes (256 KiB).
- DEFAULT_
TIMEOUT - The default request timeout.