Documentation
¶
Index ¶
- Variables
- func Compress(next http.Handler) http.Handler
- func ContextWithRequest(ctx context.Context, r *http.Request) context.Context
- func NewCobraExecutableCommand(cmd *cobra.Command) entity.ExecutableCommand
- func NewOpenAPICommand() *cobra.Command
- func NewOpenAPICommandWithConfig(config *OpenAPIConfig) *cobra.Command
- func NewServeCommand() *cobra.Command
- func NewServeCommandWithConfig(config *OpenAPIConfig) *cobra.Command
- func OpenBrowser(url string) error
- func ParamRole(op RPCOperation, param RPCParameter) string
- func RequestFromContext(ctx context.Context) (*http.Request, bool)
- func ResponseSchema(op RPCOperation) (map[string]any, error)
- func ValidateRPCOperation(operation *RPCOperation) error
- func ValidateRPCService(service *RPCService) error
- type ClickyLookupMeta
- type ClickyOperationMeta
- type ClickyParameterMeta
- type ClickySpecMeta
- type ClickySurface
- type CobraExecutableCommand
- func (c *CobraExecutableCommand) Execute(ctx context.Context, opts entity.ExecuteOptions) (string, string, error)
- func (c *CobraExecutableCommand) Hidden() bool
- func (c *CobraExecutableCommand) IsBoolFlag(name string) bool
- func (c *CobraExecutableCommand) Name() string
- func (c *CobraExecutableCommand) Path() string
- func (c *CobraExecutableCommand) RootName() string
- func (c *CobraExecutableCommand) Runnable() bool
- type CommandExecutor
- func (e *CommandExecutor) ExecuteCommand(op *RPCOperation, req *ExecutionRequest) (any, *ExecutionResponse, error)
- func (e *CommandExecutor) ExtractRequestFromHTTP(r *http.Request, op *RPCOperation) (*ExecutionRequest, error)
- func (e *CommandExecutor) FindLookupOperation(method, path string) *RPCOperation
- func (e *CommandExecutor) FindOperation(method, path string) *RPCOperation
- func (e *CommandExecutor) ValidateParameters(req *ExecutionRequest, op *RPCOperation) error
- type Config
- type ContextDataFunc
- type ContextLookupFunc
- type Converter
- type DataFunc
- type EntityActionDTO
- type EntityDTO
- type EntityOperationDTO
- type ExecutionRequest
- type ExecutionResponse
- type ExecutorConfig
- type ExportMeta
- type HealthResponse
- type OpenAPIComponents
- type OpenAPIConfig
- type OpenAPIContact
- type OpenAPIExample
- type OpenAPIExternalDocs
- type OpenAPIGenerator
- type OpenAPIHeader
- type OpenAPIInfo
- type OpenAPILicense
- type OpenAPIMediaType
- type OpenAPIOAuthFlow
- type OpenAPIOAuthFlows
- type OpenAPIOperation
- type OpenAPIParameter
- type OpenAPIPath
- type OpenAPIRequestBody
- type OpenAPIResponse
- type OpenAPISchema
- type OpenAPISecurityScheme
- type OpenAPIServer
- type OpenAPISpec
- type OpenAPITag
- type OpenAPIValidator
- type OpenAPIVariable
- type Property
- type RPCOperation
- type RPCParameter
- type RPCService
- type Schema
- type SchemaDescriber
- type ServeConfig
- type SwaggerServer
- func (s *SwaggerServer) ConverterConfig() *Config
- func (s *SwaggerServer) Executor() *CommandExecutor
- func (s *SwaggerServer) HandleEntities(w http.ResponseWriter, r *http.Request)
- func (s *SwaggerServer) HandleHealth(w http.ResponseWriter, r *http.Request)
- func (s *SwaggerServer) HandleOpenAPIJSON(w http.ResponseWriter, r *http.Request)
- func (s *SwaggerServer) HandleOpenAPIYAML(w http.ResponseWriter, r *http.Request)
- func (s *SwaggerServer) RegisterExecutionRoutes(mux *http.ServeMux)
- func (s *SwaggerServer) RegisterRoutes(mux *http.ServeMux)
- func (s *SwaggerServer) Start(ctx context.Context) error
- type TemplateData
- type ValidationError
- type ValidationResult
Constants ¶
This section is empty.
Variables ¶
var DefaultConfig = entity.DefaultConfig
DefaultConfig returns a sensible default RPC conversion configuration.
Functions ¶
func Compress ¶ added in v1.21.55
Compress wraps next so responses are gzipped for callers that accept it.
The wrapper is closed after next returns and before the server writes any declared trailer, so a trailing X-Truncated still lands after a complete compressed body rather than inside one.
func ContextWithRequest ¶ added in v1.21.29
ContextWithRequest returns a context carrying the originating *http.Request so context-based entity handlers (CreateWithContext/UpdateWithContext) can read the raw, nested JSON body the executor would otherwise flatten to string flags.
func NewCobraExecutableCommand ¶ added in v1.21.29
func NewCobraExecutableCommand(cmd *cobra.Command) entity.ExecutableCommand
NewCobraExecutableCommand wraps cmd as an entity.ExecutableCommand. It returns a nil interface for a nil command so callers can keep their existing `if op.Command == nil` guards.
func NewOpenAPICommand ¶
NewOpenAPICommand creates the OpenAPI command group that can be added to any cobra CLI
func NewOpenAPICommandWithConfig ¶
func NewOpenAPICommandWithConfig(config *OpenAPIConfig) *cobra.Command
NewOpenAPICommandWithConfig creates the OpenAPI command group with custom configuration
func NewServeCommand ¶ added in v1.21.48
NewServeCommand creates a top-level OpenAPI server command.
func NewServeCommandWithConfig ¶ added in v1.21.48
func NewServeCommandWithConfig(config *OpenAPIConfig) *cobra.Command
NewServeCommandWithConfig creates a top-level OpenAPI server command with custom configuration.
func OpenBrowser ¶
OpenBrowser opens the default browser to the specified URL
func ParamRole ¶
func ParamRole(op RPCOperation, param RPCParameter) string
ParamRole classifies a parameter within its operation, deriving the supportsLookup/isListOp signals from the operation's Clicky metadata. Returns the UI role ("limit", "offset", "time-from", "time-to", "filter") or "".
func RequestFromContext ¶ added in v1.21.29
RequestFromContext returns the originating *http.Request stashed by the HTTP executor. The second result is false on the CLI path, where there is no request.
func ResponseSchema ¶ added in v1.21.54
func ResponseSchema(op RPCOperation) (map[string]any, error)
ResponseSchema returns op's response body as a plain JSON-schema map, or nil when the operation declares no static response type. It is the public entry point for consumers that publish a schema alongside a tool or endpoint — the chat tool catalog's outputSchema — instead of embedding it in a full OpenAPI document.
The result is self-contained: reflection inlines every nested type, so the map never carries a $ref and can be interpreted standalone.
A nil map is the honest signal that the operation declares no typed response. Callers publish nothing rather than substitute a placeholder, and must not coerce the result to an object — a ResponseArray operation is legitimately a top-level array.
func ValidateRPCOperation ¶
func ValidateRPCOperation(operation *RPCOperation) error
ValidateRPCOperation validates a single RPC operation
func ValidateRPCService ¶
func ValidateRPCService(service *RPCService) error
ValidateRPCService validates an RPC service before converting to OpenAPI
Types ¶
type ClickyLookupMeta ¶ added in v1.21.29
type ClickyLookupMeta struct {
// Ref points at the reusable filter definition in
// components.x-clicky-filters (e.g. "#/components/x-clicky-filters/users").
Ref string `json:"$ref,omitempty"`
// URL is the lookup endpoint (the owning entity's list path).
URL string `json:"url,omitempty"`
// Filter is the bound flag key, sent as __lookup_filter for server-side search.
Filter string `json:"filter,omitempty"`
// SearchParam is the query-string key for the search term (__lookup_q).
SearchParam string `json:"searchParam,omitempty"`
// Multi reports whether the control accepts multiple selections.
Multi bool `json:"multi,omitempty"`
}
ClickyLookupMeta is the x-clicky-lookup extension on a filter parameter. It references the reusable named-filter definition via Ref and tells the client where to fetch options: URL is the owning entity's list path, which serves the lookup via the ?__lookup=filters convention with Filter/SearchParam as the per-filter search keys.
type ClickyOperationMeta ¶
type ClickyOperationMeta = entity.ClickyOperationMeta
The RPC operation model's canonical home is the entity/ subpackage (see the inversion described in entity/doc.go). These aliases keep rpc.RPCOperation, rpc.Schema, etc. working for existing callers (rpc internals, mcp, aichat).
type ClickyParameterMeta ¶
type ClickyParameterMeta struct {
// Role tells the UI how to render this parameter. Empty means "no
// special handling". Recognised values:
// - "filter" — show as a filter pill in the DataTable's FilterBar
// (entity .Filters(...) keys or any list-op query param
// when the op declares SupportsLookup).
// - "limit" — drives DataTable pagination's pageSize.
// - "offset" — drives DataTable pagination's page.
// - "time-from" — left edge of a time-range picker.
// - "time-to" — right edge of a time-range picker.
Role string `json:"role,omitempty"`
}
ClickyParameterMeta carries UI hints for a single OpenAPI parameter so the explorer can route it to the right widget instead of treating every query param as a free-text input. Role is derived from the parameter name plus the operation's lookup capability — see paramRole.
type ClickySpecMeta ¶
type ClickySpecMeta = entity.ClickySpecMeta
The RPC operation model's canonical home is the entity/ subpackage (see the inversion described in entity/doc.go). These aliases keep rpc.RPCOperation, rpc.Schema, etc. working for existing callers (rpc internals, mcp, aichat).
type ClickySurface ¶
type ClickySurface = entity.ClickySurface
The RPC operation model's canonical home is the entity/ subpackage (see the inversion described in entity/doc.go). These aliases keep rpc.RPCOperation, rpc.Schema, etc. working for existing callers (rpc internals, mcp, aichat).
type CobraExecutableCommand ¶ added in v1.21.29
type CobraExecutableCommand struct {
// contains filtered or unexported fields
}
CobraExecutableCommand adapts a *cobra.Command to entity.ExecutableCommand.
func (*CobraExecutableCommand) Execute ¶ added in v1.21.29
func (c *CobraExecutableCommand) Execute(ctx context.Context, opts entity.ExecuteOptions) (string, string, error)
Execute applies opts onto the wrapped command and runs a child-less copy with the full cobra lifecycle (flag/arg parsing, required-flag validation, RunE), capturing everything written to os.Stdout/os.Stderr. The whole call is serialized by globalCaptureMu so concurrent callers neither corrupt each other's captured streams nor race on the shared command's flag state.
func (*CobraExecutableCommand) Hidden ¶ added in v1.21.29
func (c *CobraExecutableCommand) Hidden() bool
func (*CobraExecutableCommand) IsBoolFlag ¶ added in v1.21.29
func (c *CobraExecutableCommand) IsBoolFlag(name string) bool
func (*CobraExecutableCommand) Name ¶ added in v1.21.29
func (c *CobraExecutableCommand) Name() string
func (*CobraExecutableCommand) Path ¶ added in v1.21.29
func (c *CobraExecutableCommand) Path() string
func (*CobraExecutableCommand) RootName ¶ added in v1.21.29
func (c *CobraExecutableCommand) RootName() string
func (*CobraExecutableCommand) Runnable ¶ added in v1.21.29
func (c *CobraExecutableCommand) Runnable() bool
type CommandExecutor ¶
type CommandExecutor struct {
// contains filtered or unexported fields
}
CommandExecutor handles dynamic execution of Cobra commands via HTTP requests
func NewCommandExecutor ¶
func NewCommandExecutor(service *RPCService, config *ExecutorConfig) *CommandExecutor
NewCommandExecutor creates a new command executor
func (*CommandExecutor) ExecuteCommand ¶
func (e *CommandExecutor) ExecuteCommand(op *RPCOperation, req *ExecutionRequest) (any, *ExecutionResponse, error)
ExecuteCommand executes a Cobra command with the given parameters.
func (*CommandExecutor) ExtractRequestFromHTTP ¶
func (e *CommandExecutor) ExtractRequestFromHTTP(r *http.Request, op *RPCOperation) (*ExecutionRequest, error)
ExtractRequestFromHTTP extracts execution parameters from HTTP request
func (*CommandExecutor) FindLookupOperation ¶
func (e *CommandExecutor) FindLookupOperation(method, path string) *RPCOperation
func (*CommandExecutor) FindOperation ¶
func (e *CommandExecutor) FindOperation(method, path string) *RPCOperation
FindOperation finds an RPC operation by HTTP method and path. Supports templated paths like /api/v1/policy/{id} matched against concrete paths like /api/v1/policy/12345.
func (*CommandExecutor) ValidateParameters ¶
func (e *CommandExecutor) ValidateParameters(req *ExecutionRequest, op *RPCOperation) error
ValidateParameters validates request parameters against operation schema
type Config ¶
The RPC operation model's canonical home is the entity/ subpackage (see the inversion described in entity/doc.go). These aliases keep rpc.RPCOperation, rpc.Schema, etc. working for existing callers (rpc internals, mcp, aichat).
type ContextDataFunc ¶
type ContextDataFunc = entity.ContextDataFunc
The RPC operation model's canonical home is the entity/ subpackage (see the inversion described in entity/doc.go). These aliases keep rpc.RPCOperation, rpc.Schema, etc. working for existing callers (rpc internals, mcp, aichat).
type ContextLookupFunc ¶
type ContextLookupFunc = entity.ContextLookupFunc
The RPC operation model's canonical home is the entity/ subpackage (see the inversion described in entity/doc.go). These aliases keep rpc.RPCOperation, rpc.Schema, etc. working for existing callers (rpc internals, mcp, aichat).
type Converter ¶
type Converter struct {
// contains filtered or unexported fields
}
Converter handles converting Cobra commands to generic RPC operations
func NewConverter ¶
NewConverter creates a new RPC converter with the given configuration
func (*Converter) ConvertCommand ¶
func (c *Converter) ConvertCommand(cmd *cobra.Command) (*RPCOperation, error)
ConvertCommand converts a single Cobra command to an RPC operation
func (*Converter) ConvertCommandTree ¶
func (c *Converter) ConvertCommandTree(rootCmd *cobra.Command) (*RPCService, error)
ConvertCommandTree recursively converts a command and its subcommands
type DataFunc ¶
The RPC operation model's canonical home is the entity/ subpackage (see the inversion described in entity/doc.go). These aliases keep rpc.RPCOperation, rpc.Schema, etc. working for existing callers (rpc internals, mcp, aichat).
type EntityActionDTO ¶
EntityActionDTO is the JSON shape of a registered action or bulk action.
type EntityDTO ¶
type EntityDTO struct {
Name string `json:"name"`
Aliases []string `json:"aliases,omitempty"`
Parent string `json:"parent,omitempty"`
IsAdmin bool `json:"is_admin,omitempty"`
Operations []EntityOperationDTO `json:"operations,omitempty"`
Actions []EntityActionDTO `json:"actions,omitempty"`
BulkActions []EntityActionDTO `json:"bulk_actions,omitempty"`
}
EntityDTO is the JSON-serialisable projection of clicky.EntityInfo. reflect.Type and function fields are stripped so the registry can be exposed to HTTP clients (typically the web UI building its sidebar).
func EntitySnapshot ¶
func EntitySnapshot() []EntityDTO
EntitySnapshot returns a serialisable projection of the current entity registry. Callers that need to embed the registry in something other than the HTTP handler (tests, custom routes) can call this directly.
type EntityOperationDTO ¶
type EntityOperationDTO struct {
Verb string `json:"verb"`
}
EntityOperationDTO is the JSON shape of a registered CRUD operation.
type ExecutionRequest ¶
type ExecutionRequest struct {
Args []string `json:"args,omitempty"` // Positional arguments
Flags map[string]string `json:"flags,omitempty"` // Flag values
// Context carries the request's context.Context to a ContextDataFunc. On the
// HTTP path it is r.Context(); on the CLI path it is cmd.Context(). It is
// never serialized — it is transport state, not part of the wire contract.
Context context.Context `json:"-"`
}
ExecutionRequest represents parameters for command execution
type ExecutionResponse ¶
type ExecutionResponse struct {
Success bool `json:"success"`
Message string `json:"message,omitempty"`
Output string `json:"output,omitempty"` // Combined stdout+stderr for backward compatibility
Stdout string `json:"stdout,omitempty"` // Standard output only
Stderr string `json:"stderr,omitempty"` // Standard error only
ExitCode int `json:"exit_code"` // Command exit code (0 = success)
Error string `json:"error,omitempty"` // Error description
Input *ExecutionRequest `json:"input,omitempty"` // Processed input parameters (included on errors for debugging)
CLI string `json:"cli,omitempty"` // Equivalent CLI command to reproduce this execution
// DataIsStructured is true when the operation returned data via a DataFunc
// (entity list/get) rather than captured stdout. The HTTP layer uses it to
// serialize the data payload directly for structured wire formats instead of
// substituting this (output-less) envelope. Not serialized — it's transport
// metadata, not part of the response contract.
DataIsStructured bool `json:"-"`
}
ExecutionResponse represents the result of command execution
type ExecutorConfig ¶
type ExecutorConfig struct {
Enabled bool // Enable dynamic command execution
SkipPreRun bool // Skip pre-run hooks during execution
PathPrefix string // Path prefix for execution endpoints (defaults to /api/v1)
}
ExecutorConfig holds configuration for command execution
type ExportMeta ¶ added in v1.21.38
type ExportMeta = entity.ExportMeta
The RPC operation model's canonical home is the entity/ subpackage (see the inversion described in entity/doc.go). These aliases keep rpc.RPCOperation, rpc.Schema, etc. working for existing callers (rpc internals, mcp, aichat).
type HealthResponse ¶
type HealthResponse struct {
Status string `json:"status"`
Timestamp string `json:"timestamp"`
Server string `json:"server"`
Version string `json:"version"`
}
HealthResponse represents the health check response
type OpenAPIComponents ¶
type OpenAPIComponents struct {
Schemas map[string]*OpenAPISchema `json:"schemas,omitempty"`
Responses map[string]OpenAPIResponse `json:"responses,omitempty"`
Parameters map[string]OpenAPIParameter `json:"parameters,omitempty"`
RequestBodies map[string]OpenAPIRequestBody `json:"requestBodies,omitempty"`
Headers map[string]OpenAPIHeader `json:"headers,omitempty"`
SecuritySchemes map[string]OpenAPISecurityScheme `json:"securitySchemes,omitempty"`
// ClickyFilters holds the reusable named-filter definitions referenced by
// filter parameters' x-clicky-lookup.$ref, emitted under x-clicky-filters.
ClickyFilters map[string]entity.FilterSpec `json:"x-clicky-filters,omitempty"`
}
OpenAPIComponents contains reusable components
type OpenAPIConfig ¶
type OpenAPIConfig struct {
Title string
Description string
Version string
Servers []OpenAPIServer
Contact *OpenAPIContact
License *OpenAPILicense
Tags []OpenAPITag
}
OpenAPIConfig holds configuration for OpenAPI generation
type OpenAPIContact ¶
type OpenAPIContact struct {
Name string `json:"name,omitempty"`
URL string `json:"url,omitempty"`
Email string `json:"email,omitempty"`
}
OpenAPIContact contains contact information for the API
type OpenAPIExample ¶
type OpenAPIExample struct {
Summary string `json:"summary,omitempty"`
Description string `json:"description,omitempty"`
Value interface{} `json:"value,omitempty"`
}
OpenAPIExample represents an example in the OpenAPI spec
type OpenAPIExternalDocs ¶
type OpenAPIExternalDocs struct {
Description string `json:"description,omitempty"`
URL string `json:"url"`
}
OpenAPIExternalDocs represents external documentation
type OpenAPIGenerator ¶
type OpenAPIGenerator struct {
// contains filtered or unexported fields
}
OpenAPIGenerator generates OpenAPI specifications from RPC services
func NewOpenAPIGenerator ¶
func NewOpenAPIGenerator(config *OpenAPIConfig) *OpenAPIGenerator
NewOpenAPIGenerator creates a new OpenAPI generator
func (*OpenAPIGenerator) GenerateFromCobra ¶
func (g *OpenAPIGenerator) GenerateFromCobra(rootCmd *cobra.Command) (*OpenAPISpec, error)
GenerateFromCobra generates an OpenAPI spec directly from a Cobra command tree using the default converter Config. Equivalent to GenerateFromCobraWithConfig with a nil config.
func (*OpenAPIGenerator) GenerateFromCobraWithConfig ¶
func (g *OpenAPIGenerator) GenerateFromCobraWithConfig(rootCmd *cobra.Command, cfg *Config) (*OpenAPISpec, error)
GenerateFromCobraWithConfig generates an OpenAPI spec from a Cobra command tree using the supplied converter Config (path prefix, default method, tags). Pass nil to fall back to DefaultConfig. Callers that mount the executor under a non-default PathPrefix (see ExecutorConfig.PathPrefix) MUST use this so the generated spec paths match the actually-registered ServeMux patterns.
func (*OpenAPIGenerator) GenerateFromService ¶
func (g *OpenAPIGenerator) GenerateFromService(service *RPCService) *OpenAPISpec
GenerateFromService generates an OpenAPI spec from an RPC service
type OpenAPIHeader ¶
type OpenAPIHeader struct {
Description string `json:"description,omitempty"`
Required bool `json:"required,omitempty"`
Schema *OpenAPISchema `json:"schema,omitempty"`
}
OpenAPIHeader represents a header in the OpenAPI spec
type OpenAPIInfo ¶
type OpenAPIInfo struct {
Title string `json:"title"`
Description string `json:"description,omitempty"`
Version string `json:"version"`
Contact *OpenAPIContact `json:"contact,omitempty"`
License *OpenAPILicense `json:"license,omitempty"`
}
OpenAPIInfo contains metadata about the API
type OpenAPILicense ¶
OpenAPILicense contains license information for the API
type OpenAPIMediaType ¶
type OpenAPIMediaType struct {
Schema *OpenAPISchema `json:"schema,omitempty"`
Example interface{} `json:"example,omitempty"`
Examples map[string]OpenAPIExample `json:"examples,omitempty"`
}
OpenAPIMediaType represents a media type in the OpenAPI spec
type OpenAPIOAuthFlow ¶
type OpenAPIOAuthFlow struct {
AuthorizationURL string `json:"authorizationUrl,omitempty"`
TokenURL string `json:"tokenUrl,omitempty"`
RefreshURL string `json:"refreshUrl,omitempty"`
Scopes map[string]string `json:"scopes"`
}
OpenAPIOAuthFlow represents an OAuth flow
type OpenAPIOAuthFlows ¶
type OpenAPIOAuthFlows struct {
Implicit *OpenAPIOAuthFlow `json:"implicit,omitempty"`
Password *OpenAPIOAuthFlow `json:"password,omitempty"`
ClientCredentials *OpenAPIOAuthFlow `json:"clientCredentials,omitempty"`
AuthorizationCode *OpenAPIOAuthFlow `json:"authorizationCode,omitempty"`
}
OpenAPIOAuthFlows represents OAuth flows
type OpenAPIOperation ¶
type OpenAPIOperation struct {
Tags []string `json:"tags,omitempty"`
Summary string `json:"summary,omitempty"`
Description string `json:"description,omitempty"`
OperationID string `json:"operationId,omitempty"`
Parameters []OpenAPIParameter `json:"parameters,omitempty"`
RequestBody *OpenAPIRequestBody `json:"requestBody,omitempty"`
Responses map[string]OpenAPIResponse `json:"responses"`
Security []map[string][]string `json:"security,omitempty"`
Clicky *ClickyOperationMeta `json:"x-clicky,omitempty"`
}
OpenAPIOperation represents an operation in the OpenAPI spec
type OpenAPIParameter ¶
type OpenAPIParameter struct {
Name string `json:"name"`
In string `json:"in"`
Description string `json:"description,omitempty"`
Required bool `json:"required,omitempty"`
Schema *OpenAPISchema `json:"schema,omitempty"`
Example interface{} `json:"example,omitempty"`
Clicky *ClickyParameterMeta `json:"x-clicky,omitempty"`
Lookup *ClickyLookupMeta `json:"x-clicky-lookup,omitempty"`
}
OpenAPIParameter represents a parameter in the OpenAPI spec
type OpenAPIPath ¶
type OpenAPIPath map[string]OpenAPIOperation
OpenAPIPath represents a path item in the OpenAPI spec
type OpenAPIRequestBody ¶
type OpenAPIRequestBody struct {
Description string `json:"description,omitempty"`
Content map[string]OpenAPIMediaType `json:"content"`
Required bool `json:"required,omitempty"`
}
OpenAPIRequestBody represents a request body in the OpenAPI spec
type OpenAPIResponse ¶
type OpenAPIResponse struct {
Description string `json:"description"`
Headers map[string]OpenAPIHeader `json:"headers,omitempty"`
Content map[string]OpenAPIMediaType `json:"content,omitempty"`
}
OpenAPIResponse represents a response in the OpenAPI spec
type OpenAPISchema ¶
type OpenAPISchema struct {
Ref string `json:"$ref,omitempty"`
Type string `json:"type,omitempty"`
Title string `json:"title,omitempty"`
Format string `json:"format,omitempty"`
Description string `json:"description,omitempty"`
Enum []interface{} `json:"enum,omitempty"`
Default interface{} `json:"default,omitempty"`
Properties map[string]*OpenAPISchema `json:"properties,omitempty"`
Required []string `json:"required,omitempty"`
Items *OpenAPISchema `json:"items,omitempty"`
OneOf []*OpenAPISchema `json:"oneOf,omitempty"`
AdditionalProperties *OpenAPISchema `json:"additionalProperties,omitempty"`
Nullable bool `json:"nullable,omitempty"`
Example interface{} `json:"example,omitempty"`
// Extensions carries vendor keys (e.g. x-clicky-component, x-clicky-workload,
// x-clicky-default-source, x-clicky-property) that are merged into the object
// at marshal time. They never appear as their own JSON field.
Extensions map[string]any `json:"-"`
}
OpenAPISchema represents a schema in the OpenAPI spec
func SchemaForStruct ¶ added in v1.21.29
func SchemaForStruct(v any) *OpenAPISchema
SchemaForStruct reflects v's type into an OpenAPISchema, honoring the clicky:"..." field tags and the SchemaDescriber interface. It is the public entry point for schema generators that build forms from Go structs.
func (OpenAPISchema) MarshalJSON ¶ added in v1.21.29
func (s OpenAPISchema) MarshalJSON() ([]byte, error)
MarshalJSON merges Extensions into the marshalled object so vendor x-* keys sit alongside the standard schema keywords.
type OpenAPISecurityScheme ¶
type OpenAPISecurityScheme struct {
Type string `json:"type"`
Description string `json:"description,omitempty"`
Name string `json:"name,omitempty"`
In string `json:"in,omitempty"`
Scheme string `json:"scheme,omitempty"`
BearerFormat string `json:"bearerFormat,omitempty"`
Flows *OpenAPIOAuthFlows `json:"flows,omitempty"`
}
OpenAPISecurityScheme represents a security scheme
type OpenAPIServer ¶
type OpenAPIServer struct {
URL string `json:"url"`
Description string `json:"description,omitempty"`
Variables map[string]OpenAPIVariable `json:"variables,omitempty"`
}
OpenAPIServer represents a server in the OpenAPI spec
type OpenAPISpec ¶
type OpenAPISpec struct {
OpenAPI string `json:"openapi"`
Info OpenAPIInfo `json:"info"`
Servers []OpenAPIServer `json:"servers,omitempty"`
Paths map[string]OpenAPIPath `json:"paths"`
Components *OpenAPIComponents `json:"components,omitempty"`
Tags []OpenAPITag `json:"tags,omitempty"`
Clicky *ClickySpecMeta `json:"x-clicky,omitempty"`
}
OpenAPISpec represents an OpenAPI 3.0 specification
func GenerateFromRPCOperation ¶
func GenerateFromRPCOperation(operation *RPCOperation, config *OpenAPIConfig) (*OpenAPISpec, error)
GenerateFromRPCOperation creates an OpenAPI spec from a single RPC operation
func GenerateFromRPCService ¶
func GenerateFromRPCService(service *RPCService, config *OpenAPIConfig) (*OpenAPISpec, error)
GenerateFromRPCService creates an OpenAPI spec directly from an RPC service
func (*OpenAPISpec) ToJSON ¶
func (spec *OpenAPISpec) ToJSON() ([]byte, error)
ToJSON converts the OpenAPI spec to JSON
func (*OpenAPISpec) ToYAML ¶
func (spec *OpenAPISpec) ToYAML() ([]byte, error)
ToYAML converts the OpenAPI spec to YAML
type OpenAPITag ¶
type OpenAPITag struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
ExternalDocs *OpenAPIExternalDocs `json:"externalDocs,omitempty"`
}
OpenAPITag represents a tag for grouping operations
type OpenAPIValidator ¶
type OpenAPIValidator struct{}
OpenAPIValidator provides validation for OpenAPI specifications
func NewOpenAPIValidator ¶
func NewOpenAPIValidator() *OpenAPIValidator
NewOpenAPIValidator creates a new OpenAPI validator
func (*OpenAPIValidator) Validate ¶
func (v *OpenAPIValidator) Validate(spec *OpenAPISpec) *ValidationResult
Validate validates an OpenAPI specification
type OpenAPIVariable ¶
type OpenAPIVariable struct {
Enum []string `json:"enum,omitempty"`
Default string `json:"default"`
Description string `json:"description,omitempty"`
}
OpenAPIVariable represents a server variable
type Property ¶
The RPC operation model's canonical home is the entity/ subpackage (see the inversion described in entity/doc.go). These aliases keep rpc.RPCOperation, rpc.Schema, etc. working for existing callers (rpc internals, mcp, aichat).
type RPCOperation ¶
type RPCOperation = entity.RPCOperation
The RPC operation model's canonical home is the entity/ subpackage (see the inversion described in entity/doc.go). These aliases keep rpc.RPCOperation, rpc.Schema, etc. working for existing callers (rpc internals, mcp, aichat).
type RPCParameter ¶
type RPCParameter = entity.RPCParameter
The RPC operation model's canonical home is the entity/ subpackage (see the inversion described in entity/doc.go). These aliases keep rpc.RPCOperation, rpc.Schema, etc. working for existing callers (rpc internals, mcp, aichat).
type RPCService ¶
type RPCService = entity.RPCService
The RPC operation model's canonical home is the entity/ subpackage (see the inversion described in entity/doc.go). These aliases keep rpc.RPCOperation, rpc.Schema, etc. working for existing callers (rpc internals, mcp, aichat).
type Schema ¶
The RPC operation model's canonical home is the entity/ subpackage (see the inversion described in entity/doc.go). These aliases keep rpc.RPCOperation, rpc.Schema, etc. working for existing callers (rpc internals, mcp, aichat).
type SchemaDescriber ¶ added in v1.21.29
SchemaDescriber lets a type emit its own JSON-schema fragment instead of being structurally reflected. Known keys (type/title/format/description) populate the matching OpenAPISchema fields; everything else (e.g. x-clicky-*) goes into Extensions. Used by types whose string form hides a richer struct (e.g. commons-db's types.EnvVar, which renders as a plain secret-ref string).
type ServeConfig ¶
type ServeConfig struct {
Host string
Port int
Title string
Description string
Version string
AutoRefresh bool
Open bool
SkipHealth bool // Skip registering /health (caller provides their own)
Executor *ExecutorConfig // Optional command execution configuration
}
ServeConfig holds configuration for the OpenAPI serve command
func DefaultServeConfig ¶
func DefaultServeConfig() *ServeConfig
DefaultServeConfig returns default configuration for the serve command
type SwaggerServer ¶
type SwaggerServer struct {
// contains filtered or unexported fields
}
SwaggerServer serves API reference documentation for the OpenAPI specification.
func NewSwaggerServer ¶
func NewSwaggerServer(config *ServeConfig, rootCmd *cobra.Command, openAPIConfig *OpenAPIConfig) *SwaggerServer
NewSwaggerServer creates a new OpenAPI documentation server
func (*SwaggerServer) ConverterConfig ¶
func (s *SwaggerServer) ConverterConfig() *Config
ConverterConfig returns the converter Config used to build the executor's routes (path prefix, default method, etc.). Callers that re-run GenerateFromCobraWithConfig outside this server — e.g. to merge a separate OpenAPI document with the executor spec — should pass this value so the regenerated paths match the actually-registered ServeMux patterns. Returns nil when the server was constructed without an executor.
func (*SwaggerServer) Executor ¶ added in v1.21.38
func (s *SwaggerServer) Executor() *CommandExecutor
Executor returns the server's command executor, or nil when execution is not enabled. Callers can use it to invoke operations programmatically — resolve an operation with FindOperation(method, path) and run it via ExecuteCommand — so a stored operation descriptor can be replayed through the same code path the HTTP executor routes use.
func (*SwaggerServer) HandleEntities ¶
func (s *SwaggerServer) HandleEntities(w http.ResponseWriter, r *http.Request)
HandleEntities serves the entity metadata endpoint. Exported so callers composing their own mux can register it independently of RegisterRoutes.
func (*SwaggerServer) HandleHealth ¶
func (s *SwaggerServer) HandleHealth(w http.ResponseWriter, r *http.Request)
HandleHealth serves the liveness probe. Exported for the same reason as HandleEntities.
func (*SwaggerServer) HandleOpenAPIJSON ¶
func (s *SwaggerServer) HandleOpenAPIJSON(w http.ResponseWriter, r *http.Request)
HandleOpenAPIJSON serves the OpenAPI 3 spec as JSON. Exported so callers that compose their own mux (and want to wrap or override this endpoint) can re-mount it without going through RegisterRoutes.
func (*SwaggerServer) HandleOpenAPIYAML ¶
func (s *SwaggerServer) HandleOpenAPIYAML(w http.ResponseWriter, r *http.Request)
HandleOpenAPIYAML serves the OpenAPI 3 spec as YAML. See HandleOpenAPIJSON.
func (*SwaggerServer) RegisterExecutionRoutes ¶
func (s *SwaggerServer) RegisterExecutionRoutes(mux *http.ServeMux)
RegisterExecutionRoutes registers only the dynamic executor patterns derived from the RPC service (one method+path per operation). Exported so callers that want everything from RegisterRoutes except the openapi handlers (because they intend to wrap /api/openapi.json with a merge across multiple specs) can opt in route-by-route.
func (*SwaggerServer) RegisterRoutes ¶
func (s *SwaggerServer) RegisterRoutes(mux *http.ServeMux)
Start starts the HTTP server RegisterRoutes registers all API routes onto the provided mux. This allows callers to compose the SwaggerServer routes with other handlers.
type TemplateData ¶
type TemplateData struct {
Title string
Description string
Version string
Timestamp string
AutoRefresh bool
}
TemplateData holds data for rendering the HTML template
type ValidationError ¶
ValidationError represents a validation error
func (ValidationError) Error ¶
func (e ValidationError) Error() string
type ValidationResult ¶
type ValidationResult struct {
Valid bool
Errors []ValidationError
}
ValidationResult contains the results of validation
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package rpchttp provides request-scoped HTTP server timing that both the RPC executor path and hand-written handlers can feed, emitted once as a Server-Timing response header by TimingMiddleware.
|
Package rpchttp provides request-scoped HTTP server timing that both the RPC executor path and hand-written handlers can feed, emitted once as a Server-Timing response header by TimingMiddleware. |