@utcp/sdk
Version:
Universal Tool Calling Protocol (UTCP) client library for TypeScript
77 lines (76 loc) • 2.77 kB
TypeScript
import { UtcpManual } from '../shared/utcp-manual';
interface OpenApiConverterOptions {
specUrl?: string;
providerName?: string;
}
/**
* Converts an OpenAPI JSON specification into a UtcpManual.
*/
export declare class OpenApiConverter {
private spec;
private specUrl;
private providerName;
/**
* Creates a new OpenAPI converter instance
* @param openapi_spec The OpenAPI specification object
* @param options Optional settings, like the specUrl
*/
constructor(openapi_spec: Record<string, any>, options?: OpenApiConverterOptions);
/**
* Parses the OpenAPI specification and returns a UtcpManual.
* @returns A UTCP manual containing tools derived from the OpenAPI specification
*/
convert(): UtcpManual;
/**
* Resolves a local JSON reference.
* @param ref The reference string (e.g. #/components/schemas/Pet)
* @returns The resolved schema object
*/
private _resolveRef;
/**
* Recursively resolves all $refs in a schema object.
* @param schema The schema object that may contain references
* @returns The resolved schema with all references replaced by their actual values
*/
private _resolveSchema;
/**
* Creates a Tool object from an OpenAPI operation.
* @param path The API path
* @param method The HTTP method (GET, POST, etc.)
* @param operation The operation definition from OpenAPI
* @param baseUrl The base URL from the servers array
* @returns A Tool object or null if operationId is not defined
*/
private _createTool;
/**
* Extracts the input schema from an OpenAPI operation, resolving refs.
* @param operation The OpenAPI operation object
* @returns The input schema, header fields, and body field
*/
private _extractInputs;
/**
* Extracts the output schema from an OpenAPI operation, resolving refs.
* @param operation The OpenAPI operation object
* @returns The output schema
*/
private _extractOutputs;
/**
* Extracts authentication information from OpenAPI operation and global security schemes.
* @param operation The OpenAPI operation object
* @returns An Auth object or undefined if no authentication is specified
*/
private _extractAuth;
/**
* Gets security schemes supporting both OpenAPI 2.0 and 3.0.
* @returns A record of security schemes
*/
private _getSecuritySchemes;
/**
* Creates an Auth object from an OpenAPI security scheme.
* @param scheme The security scheme object
* @param schemeName The name of the scheme
* @returns An Auth object or undefined if the scheme is not supported
*/
private _createAuthFromScheme;
}
export {};