Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GenerateOptions ¶
type GenerateOptions struct {
BaseURL string
IncludeTags []string
ExcludeTags []string
Prefix string
}
GenerateOptions configures tool generation.
type GeneratedTool ¶
type GeneratedTool struct {
Name string `json:"name"`
Description string `json:"description"`
Schema llm.ToolSchema `json:"schema"`
Method string `json:"method"`
Path string `json:"path"`
BaseURL string `json:"base_url"`
Parameters []Parameter `json:"parameters"`
RequestBody *RequestBody `json:"request_body,omitempty"`
}
GeneratedTool represents a tool generated from OpenAPI.
type Generator ¶
type Generator struct {
// contains filtered or unexported fields
}
Generator generates tools from OpenAPI specifications.
func NewGenerator ¶
func NewGenerator(config GeneratorConfig, logger *zap.Logger) *Generator
NewGenerator creates a new OpenAPI tool generator.
func (*Generator) GenerateTools ¶
func (g *Generator) GenerateTools(spec *OpenAPISpec, opts GenerateOptions) ([]*GeneratedTool, error)
GenerateTools generates tools from an OpenAPI spec.
type GeneratorConfig ¶
GeneratorConfig configures the generator.
type Info ¶
type Info struct {
Title string `json:"title"`
Description string `json:"description,omitempty"`
Version string `json:"version"`
}
Info contains API metadata.
type JSONSchema ¶
type JSONSchema struct {
Type string `json:"type,omitempty"`
Description string `json:"description,omitempty"`
Properties map[string]JSONSchema `json:"properties,omitempty"`
Required []string `json:"required,omitempty"`
Items *JSONSchema `json:"items,omitempty"`
Enum []any `json:"enum,omitempty"`
Default any `json:"default,omitempty"`
}
JSONSchema represents a JSON Schema.
type MediaType ¶
type MediaType struct {
Schema *JSONSchema `json:"schema,omitempty"`
}
MediaType represents a media type.
type OpenAPISpec ¶
type OpenAPISpec struct {
OpenAPI string `json:"openapi"`
Info Info `json:"info"`
Servers []Server `json:"servers,omitempty"`
Paths map[string]PathItem `json:"paths"`
}
OpenAPISpec represents a parsed OpenAPI specification.
type Operation ¶
type Operation struct {
OperationID string `json:"operationId,omitempty"`
Summary string `json:"summary,omitempty"`
Description string `json:"description,omitempty"`
Parameters []Parameter `json:"parameters,omitempty"`
RequestBody *RequestBody `json:"requestBody,omitempty"`
Responses Responses `json:"responses,omitempty"`
Tags []string `json:"tags,omitempty"`
}
Operation represents an API operation.
type Parameter ¶
type Parameter struct {
Name string `json:"name"`
In string `json:"in"` // query, path, header, cookie
Description string `json:"description,omitempty"`
Required bool `json:"required,omitempty"`
Schema *JSONSchema `json:"schema,omitempty"`
}
Parameter represents an operation parameter.
type PathItem ¶
type PathItem struct {
Get *Operation `json:"get,omitempty"`
Post *Operation `json:"post,omitempty"`
Put *Operation `json:"put,omitempty"`
Delete *Operation `json:"delete,omitempty"`
Patch *Operation `json:"patch,omitempty"`
}
PathItem represents operations on a path.
type RequestBody ¶
type RequestBody struct {
Description string `json:"description,omitempty"`
Required bool `json:"required,omitempty"`
Content map[string]MediaType `json:"content,omitempty"`
}
RequestBody represents a request body.
type ResponseObj ¶
type ResponseObj struct {
Description string `json:"description,omitempty"`
Content map[string]MediaType `json:"content,omitempty"`
}
ResponseObj represents a response.