Documentation
¶
Overview ¶
Package webindex analyzes GoForj route declarations and emits route and OpenAPI metadata.
Index ¶
Constants ¶
const ManifestVersion = "1"
ManifestVersion is the schema version for the API index output.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BodyShape ¶
type BodyShape struct {
TypeName string `json:"type_name,omitempty"`
Schema any `json:"schema,omitempty"`
Source string `json:"source,omitempty"`
Confidence string `json:"confidence,omitempty"`
}
BodyShape describes inferred request body information.
type Diagnostic ¶
type Diagnostic struct {
Severity string `json:"severity"`
Code string `json:"code"`
Message string `json:"message"`
File string `json:"file,omitempty"`
Line int `json:"line,omitempty"`
Operation string `json:"operation,omitempty"`
}
Diagnostic captures parser/indexer warnings and informational findings.
type HandlerRef ¶
type HandlerRef struct {
Expression string `json:"expression"`
Package string `json:"package,omitempty"`
Receiver string `json:"receiver,omitempty"`
Function string `json:"function,omitempty"`
File string `json:"file,omitempty"`
Line int `json:"line,omitempty"`
}
HandlerRef points to the handler function/method.
type IndexOptions ¶
type IndexOptions struct {
Root string
OutPath string
DiagnosticsPath string
OpenAPIPath string
RouteCompositionPath string
}
IndexOptions controls API index generation behavior.
type InputShape ¶
type InputShape struct {
PathParams []Parameter `json:"path_params,omitempty"`
QueryParams []Parameter `json:"query_params,omitempty"`
Headers []Parameter `json:"headers,omitempty"`
Body *BodyShape `json:"body,omitempty"`
}
InputShape describes request inputs inferred from AST.
type Manifest ¶
type Manifest struct {
Version string `json:"version"`
Operations []Operation `json:"operations"`
Schemas []Schema `json:"schemas"`
Diagnostics []Diagnostic `json:"diagnostics"`
}
Manifest is the canonical API index artifact.
func Run ¶
func Run(_ context.Context, opts IndexOptions) (Manifest, error)
Run indexes API metadata from source and writes artifacts. @group Indexing Example:
manifest, err := webindex.Run(context.Background(), webindex.IndexOptions{
Root: ".",
OutPath: "webindex.json",
})
fmt.Println(err == nil, manifest.Version != "")
// true true
type OpenAPIDocument ¶
type OpenAPIDocument struct {
OpenAPI string `json:"openapi"`
Info map[string]string `json:"info"`
Paths map[string]map[string]OpenAPIOp `json:"paths"`
Components map[string]any `json:"components,omitempty"`
}
OpenAPIDocument is a minimal OpenAPI projection generated from the API index.
type OpenAPIOp ¶
type OpenAPIOp struct {
OperationID string `json:"operationId"`
Parameters []OpenAPIParameter `json:"parameters,omitempty"`
RequestBody map[string]any `json:"requestBody,omitempty"`
Responses map[string]map[string]any `json:"responses"`
}
OpenAPIOp is a minimal operation model for OpenAPI output.
type OpenAPIParameter ¶
type OpenAPIParameter struct {
Name string `json:"name"`
In string `json:"in"`
Required bool `json:"required,omitempty"`
Schema map[string]string `json:"schema,omitempty"`
}
OpenAPIParameter is a minimal parameter projection.
type Operation ¶
type Operation struct {
ID string `json:"id"`
Method string `json:"method"`
Path string `json:"path"`
Handler HandlerRef `json:"handler"`
Middleware []string `json:"middleware,omitempty"`
Inputs InputShape `json:"inputs"`
Outputs OutputShape `json:"outputs"`
}
Operation describes one HTTP operation discovered in source.
type OutputShape ¶
type OutputShape struct {
Responses []ResponseShape `json:"responses,omitempty"`
}
OutputShape describes response outputs inferred from AST.
type Parameter ¶
type Parameter struct {
Name string `json:"name"`
In string `json:"in"`
Required bool `json:"required"`
Confidence string `json:"confidence"`
}
Parameter describes an input parameter.
type ResponseShape ¶
type ResponseShape struct {
StatusCode int `json:"status_code"`
TypeName string `json:"type_name,omitempty"`
Schema any `json:"schema,omitempty"`
Source string `json:"source,omitempty"`
Confidence string `json:"confidence,omitempty"`
}
ResponseShape describes one possible response.