UNPKG

adk-typescript

Version:

TypeScript port of Google's Agent Development Kit (ADK)

120 lines (119 loc) 3.67 kB
import { GoogleApiToOpenApiConverter } from './GoogleApiToolSet'; /** * Converts Google API Discovery documents to OpenAPI v3 format. * Implements the GoogleApiToOpenApiConverter interface. */ export declare class GoogleApiToOpenApiConverterImpl implements GoogleApiToOpenApiConverter { /** * The name of the Google API (e.g., "calendar") */ private apiName; /** * The version of the API (e.g., "v3") */ private apiVersion; /** * The Google API resource */ private googleApiResource; /** * The Google API specification */ private googleApiSpec; /** * The OpenAPI specification */ private openApiSpec; /** * Initialize the converter with the API name and version. * * @param apiName The name of the Google API (e.g., "calendar") * @param apiVersion The version of the API (e.g., "v3") */ constructor(apiName: string, apiVersion: string); /** * Fetches the Google API specification using discovery service. * * Note: In a real implementation, this would use the googleapis library. * For this port, we'll create a placeholder that simulates fetching the API spec. */ fetchGoogleApiSpec(): Promise<void>; /** * Convert the Google API spec to OpenAPI v3 format. * * @returns Object containing the converted OpenAPI v3 specification */ convert(): Promise<any>; /** * Convert basic API information. */ private _convertInfo; /** * Convert server information. */ private _convertServers; /** * Convert authentication and authorization schemes. */ private _convertSecuritySchemes; /** * Convert schema definitions (models). */ private _convertSchemas; /** * Recursively convert a Google API schema object to OpenAPI schema. * * @param schemaDef Google API schema definition * @returns Converted OpenAPI schema object */ private _convertSchemaObject; /** * Recursively convert all resources and their methods. * * @param resources Dictionary of resources from the Google API spec * @param parentPath The parent path prefix for nested resources */ private _convertResources; /** * Convert methods for a specific resource path. * * @param methods Dictionary of methods from the Google API spec * @param resourcePath The path of the resource these methods belong to */ private _convertMethods; /** * Extract path parameters from a URL path. * * @param path The URL path with path parameters * @returns List of parameter names */ private _extractPathParameters; /** * Convert a Google API method to an OpenAPI operation. * * @param methodData Google API method data * @param pathParams List of path parameter names * @returns OpenAPI operation object */ private _convertOperation; /** * Convert a parameter definition to an OpenAPI schema. * * @param paramData Google API parameter data * @returns OpenAPI schema for the parameter */ private _convertParameterSchema; /** * Save the OpenAPI specification to a file. * * @param outputPath Path where the OpenAPI spec should be saved */ saveOpenApiSpec(outputPath: string): void; } /** * Command line interface for the converter. * * Note: This is included for compatibility with the Python implementation, * but would typically be implemented differently in a TypeScript project. */ export declare function main(args: string[]): Promise<number>;