Help us shape the future of Go! Take the 2026 Go Developer Survey

openapi

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2025 License: AGPL-3.0 Imports: 2 Imported by: 0

Documentation

Overview

internal/openapi/schema.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Components

type Components struct {
	Schemas         map[string]Schema         `json:"schemas,omitempty"`
	SecuritySchemes map[string]SecurityScheme `json:"securitySchemes,omitempty"`
}

type Info

type Info struct {
	Title       string `json:"title"`
	Description string `json:"description"`
	Version     string `json:"version"`
}

type MediaType

type MediaType struct {
	Schema Schema `json:"schema"`
}

type OpenAPISchema

type OpenAPISchema struct {
	OpenAPI    string                `json:"openapi"`
	Info       Info                  `json:"info"`
	Servers    []Server              `json:"servers"`
	Paths      map[string]PathItem   `json:"paths"`
	Specs      []ToolSpec            `json:"specs,omitempty"` // Added specs field for OpenWebUI
	Components Components            `json:"components"`
	Security   []map[string][]string `json:"security,omitempty"`
}

OpenAPISchema represents an OpenAPI 3.0 schema.

func GenerateOpenAPISchema

func GenerateOpenAPISchema(serverName string, tools []Tool) (*OpenAPISchema, error)

GenerateOpenAPISchema generates an OpenAPI schema for MCP tools with full annotations.

type Operation

type Operation struct {
	Summary     string                `json:"summary"`
	Description string                `json:"description,omitempty"`
	OperationID string                `json:"operationId"`
	RequestBody RequestBody           `json:"requestBody,omitempty"`
	Responses   map[string]Response   `json:"responses"`
	Security    []map[string][]string `json:"security,omitempty"`
	Tags        []string              `json:"tags,omitempty"`
	// MCP Operation Extensions
	MCPMethod string           `json:"x-mcp-method,omitempty"`
	MCPHints  *ToolAnnotations `json:"x-mcp-hints,omitempty"`
}

type PathItem

type PathItem struct {
	Post Operation `json:"post,omitempty"`
}

type RequestBody

type RequestBody struct {
	Required bool                 `json:"required"`
	Content  map[string]MediaType `json:"content"`
}

type Response

type Response struct {
	Description string               `json:"description"`
	Content     map[string]MediaType `json:"content,omitempty"`
}

type Schema

type Schema struct {
	Type                 string            `json:"type,omitempty"`
	Properties           map[string]Schema `json:"properties,omitempty"`
	Required             []string          `json:"required,omitempty"`
	Items                *Schema           `json:"items,omitempty"`
	Description          string            `json:"description,omitempty"`
	Ref                  string            `json:"$ref,omitempty"`
	AdditionalProperties *Schema           `json:"additionalProperties,omitempty"`
}

type SecurityScheme

type SecurityScheme struct {
	Type         string `json:"type"`
	Scheme       string `json:"scheme,omitempty"`
	BearerFormat string `json:"bearerFormat,omitempty"`
	Name         string `json:"name,omitempty"`
	In           string `json:"in,omitempty"`
}

type Server

type Server struct {
	URL         string `json:"url"`
	Description string `json:"description,omitempty"`
}

type Tool

type Tool struct {
	Name        string                 `json:"name"`
	Description string                 `json:"description"`
	InputSchema map[string]interface{} `json:"inputSchema"`
	// MCP Tool Annotations
	Annotations *ToolAnnotations `json:"annotations,omitempty"`
}

Enhanced Tool with MCP annotations.

type ToolAnnotations

type ToolAnnotations struct {
	ReadOnlyHint    bool `json:"readOnlyHint,omitempty"`    // Tool is read-only
	DestructiveHint bool `json:"destructiveHint,omitempty"` // Tool may be destructive
	IdempotentHint  bool `json:"idempotentHint,omitempty"`  // Tool is idempotent
	OpenWorldHint   bool `json:"openWorldHint,omitempty"`   // Tool accepts arbitrary parameters
}

ToolAnnotations represents MCP tool annotations.

type ToolSpec

type ToolSpec struct {
	Type        string                 `json:"type"`
	Name        string                 `json:"name"`
	Description string                 `json:"description,omitempty"`
	Parameters  map[string]interface{} `json:"parameters,omitempty"`
	// MCP Tool Annotations
	Annotations *ToolAnnotations `json:"annotations,omitempty"`
}

Enhanced ToolSpec with full MCP annotations.

Jump to

Keyboard shortcuts

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