Documentation
¶
Overview ¶
Package graph infers producer-consumer dependencies between OpenAPI operations. It analyzes response schemas (producers) and request parameters/bodies (consumers), then matches them using name, type and path signals to produce a confidence-scored dependency graph.
Index ¶
Constants ¶
const MinConfidence = 0.50
MinConfidence is the minimum confidence score for a dependency edge to be included in the graph.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Dependency ¶
type Dependency struct {
Producer ValueRef `json:"producer"`
Consumer ValueRef `json:"consumer"`
Confidence float64 `json:"confidence"`
Reason Reason `json:"reason"`
}
Dependency is a confidence-scored edge from a producer value to a consumer value.
func Match ¶
func Match(producers, consumers []ValueRef) []Dependency
Match takes extracted producers and consumers and infers confidence-scored dependency edges.
func (Dependency) String ¶
func (d Dependency) String() string
String returns a one-line description of the dependency.
type Graph ¶
type Graph struct {
Producers []ValueRef `json:"producers"`
Consumers []ValueRef `json:"consumers"`
Dependencies []Dependency `json:"dependencies"`
}
Graph is the inferred dependency graph for a spec.
func Build ¶
Build is the top-level entry point: extract producers and consumers from the spec, match them, and return the complete graph.
func (*Graph) EdgesForConsumer ¶
func (g *Graph) EdgesForConsumer(operationKey string) []Dependency
EdgesForConsumer returns all dependencies that produce values for the given consumer operation key.
func (*Graph) EdgesFromProducer ¶
func (g *Graph) EdgesFromProducer(operationKey string) []Dependency
EdgesFromProducer returns all dependencies that consume values from the given producer operation key.
func (*Graph) SortedDependencies ¶
func (g *Graph) SortedDependencies() []Dependency
SortedDependencies returns dependencies sorted by confidence (descending), then by producer and consumer strings for determinism.
type Location ¶
type Location string
Location describes where a value lives in an operation's input or output.
type Reason ¶
type Reason struct {
Signals []Signal `json:"signals"`
}
Reason describes why a dependency edge was inferred, listing the signals that matched and their individual contributions.
type Signal ¶
type Signal struct {
Name string `json:"name"`
Confidence float64 `json:"confidence"`
Detail string `json:"detail"`
}
Signal is a single piece of evidence supporting a dependency edge.
type ValueRef ¶
type ValueRef struct {
OperationKey string `json:"operation"`
Method string `json:"method"`
Path string `json:"path"`
Location Location `json:"location"`
FieldPath string `json:"field"`
Schema *schema.Schema `json:"-"`
}
ValueRef references a single value in an operation's input or output. FieldPath uses dot notation for nested object fields (e.g. "user.id").
func ExtractConsumers ¶
ExtractConsumers walks all operations' request parameters and request bodies and extracts candidate consumer values.
func ExtractProducers ¶
ExtractProducers walks all operations' success (2xx) response schemas and extracts candidate producer values. Object response schemas yield their properties; array responses yield their item schema's properties.