openapi

package
v0.0.0-...-5b49586 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 1, 2026 License: Apache-2.0 Imports: 24 Imported by: 0

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

func NewOpenAPIUpstream() upstream.Upstream

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.

type PathItem

type PathItem struct {
	PathRef *openapi3.PathItem
}

PathItem represents a single path within an OpenAPI specification and holds a reference to its corresponding openapi3.PathItem.

Summary: Represents a PathItem.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL