Documentation
¶
Overview ¶
Package openapi provides OpenAPI integration for the upstream service.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewOpenAPIUpstream ¶
NewOpenAPIUpstream creates a new instance of OpenAPIUpstream. It initializes a cache for storing parsed OpenAPI documents to avoid redundant parsing.
Returns:
- upstream.Upstream: The result.
Side Effects:
- None.
Summary: Initializes NewOpenAPIUpstream operation.
Parameters:
- TODO: Document parameters.
Returns:
- TODO: Document returns.
Errors:
- TODO: Document errors.
Side Effects:
- None.
Types ¶
type McpOperation ¶
type McpOperation struct {
OperationID string
Summary string
Description string
Method string // e.g., GET, POST
Path string
// Simplified schema representation for request body
// Key: content type (e.g., "application/json")
// Value: schema reference
RequestBodySchema map[string]*openapi3.SchemaRef
// Simplified schema representation for responses
// Key: status code (e.g., "200")
// Value: map of content type to schema reference
ResponseSchemas map[string]map[string]*openapi3.SchemaRef
Parameters openapi3.Parameters // Store operation parameters (query, path, header, cookie)
}
McpOperation provides a simplified, MCP-centric representation of an OpenAPI operation. It contains the essential details needed to convert an API endpoint into an executable tool.
Summary: Represents a McpOperation.
type OpenAPIUpstream ¶
type OpenAPIUpstream struct {
// contains filtered or unexported fields
}
OpenAPIUpstream implements the upstream.Upstream interface for services that are defined by an OpenAPI specification. It parses the spec, discovers the available operations, and registers them as tools.
Summary: Represents a OpenAPIUpstream.
func (*OpenAPIUpstream) Register ¶
func (u *OpenAPIUpstream) Register( ctx context.Context, serviceConfig *configv1.UpstreamServiceConfig, toolManager tool.ManagerInterface, promptManager prompt.ManagerInterface, resourceManager resource.ManagerInterface, isReload bool, ) (string, []*configv1.ToolDefinition, []*configv1.ResourceDefinition, error)
Register processes an OpenAPI service configuration. It parses the OpenAPI specification, extracts the operations, converts them into tools, and registers them with the tool manager.
Parameters:
- ctx (context.Context): The context for the request.
- serviceConfig (*configv1.UpstreamServiceConfig): The serviceConfig parameter.
- toolManager (tool.ManagerInterface): The toolManager parameter.
- promptManager (prompt.ManagerInterface): The promptManager parameter.
- resourceManager (resource.ManagerInterface): The resourceManager parameter.
- isReload (bool): The isReload parameter.
Returns:
- string: The resulting string.
- []*configv1.ToolDefinition: The resulting []*configv1.ToolDefinition.
- []*configv1.ResourceDefinition: The resulting []*configv1.ResourceDefinition.
- error: An error if the operation fails.
Errors:
- Returns an error if the operation fails or is invalid.
Side Effects:
- None
Summary: Executes Register operation.
Parameters:
- TODO: Document parameters.
Returns:
- TODO: Document returns.
Errors:
- TODO: Document errors.
Side Effects:
- None.
func (*OpenAPIUpstream) Shutdown ¶
func (u *OpenAPIUpstream) Shutdown(_ context.Context) error
Shutdown gracefully terminates the OpenAPI upstream service. For HTTP-based services, this typically means closing any persistent connections.
Parameters:
- _ (context.Context): The parameter.
Returns:
- error: An error if the operation fails.
Errors:
- Returns an error if ...
Side Effects:
- None.
Summary: Executes Shutdown operation.
Parameters:
- TODO: Document parameters.
Returns:
- TODO: Document returns.
Errors:
- TODO: Document errors.
Side Effects:
- None.
type ParsedOpenAPIData ¶
type ParsedOpenAPIData struct {
Info openapi3.Info
Servers openapi3.Servers
Paths map[string]*PathItem
}
ParsedOpenAPIData holds the high-level information extracted from an OpenAPI specification, such as metadata, server details, and the defined paths.
Summary: Represents a ParsedOpenAPIData.