OpenAPI Converter for automatic API discovery and tool generation.
Converts OpenAPI 2.0 and 3.0 specifications into UTCP tools, enabling AI agents to interact with existing APIs directly without server modifications.
Features
- OpenAPI 2.0 and 3.0 support
- Automatic tool generation from API operations
- Authentication scheme mapping
- Parameter and response schema handling
- Variable substitution support
- Batch processing of multiple specs
Usage
# Convert from URL
{:ok, manual} = OpenApiConverter.convert_from_url("https://api.github.com/openapi.json")
# Convert from local file
{:ok, manual} = OpenApiConverter.convert_from_file("path/to/spec.json")
# Convert from map
{:ok, manual} = OpenApiConverter.convert(spec_map)
# Convert with custom options
{:ok, manual} = OpenApiConverter.convert(spec_map, %{
base_url: "https://api.example.com",
auth: %{type: "api_key", api_key: "Bearer ${API_KEY}"},
prefix: "github"
})
Summary
Functions
Converts an OpenAPI specification to a UTCP manual.
Converts an OpenAPI specification from a local file.
Converts an OpenAPI specification from a URL.
Converts multiple OpenAPI specifications and merges them into a single manual.
Validates an OpenAPI specification without converting it.
Functions
Converts an OpenAPI specification to a UTCP manual.
Parameters
spec: OpenAPI specification as a mapopts: Optional configuration map with keys::base_url- Override base URL from spec:auth- Authentication configuration:prefix- Prefix for tool names:include_deprecated- Include deprecated operations (default: false):filter_tags- Only include operations with these tags:exclude_tags- Exclude operations with these tags
Returns
{:ok, manual} on success, {:error, reason} on failure.
Converts an OpenAPI specification from a local file.
Parameters
file_path: Path to the OpenAPI specification fileopts: Optional configuration (same as convert/2)
Returns
{:ok, manual} on success, {:error, reason} on failure.
Converts an OpenAPI specification from a URL.
Parameters
url: URL to the OpenAPI specificationopts: Optional configuration (same as convert/2)
Returns
{:ok, manual} on success, {:error, reason} on failure.
Converts multiple OpenAPI specifications and merges them into a single manual.
Parameters
specs: List of specification sources (maps, URLs, or file paths)opts: Optional configuration (same as convert/2)
Returns
{:ok, manual} on success, {:error, reason} on failure.
@spec validate(map()) :: {:ok, ExUtcp.OpenApiConverter.Types.ValidationResult.t()}
Validates an OpenAPI specification without converting it.
Parameters
spec: OpenAPI specification as a map
Returns
{:ok, validation_result} on success, {:error, reason} on failure.