MCPcopy
hub / github.com/dosco/graphjin / classifyAll

Function classifyAll

core/openapi/classifier.go:17–68  ·  view source on GitHub ↗

classifyAll walks every path/operation pair in doc and produces an OpDescriptor per operation. Operations that can't be auto-exposed are returned with Mode == OpModeSkipped and a populated SkipReason; nothing is dropped silently. Per-operation diagnostic warnings (typically internal inconsistencies

(spec *Spec, doc *openapi3.T, cfg SpecConfig)

Source from the content-addressed store, hash-verified

15// internal inconsistencies the user might want to know about) are
16// returned alongside.
17func classifyAll(spec *Spec, doc *openapi3.T, cfg SpecConfig) ([]OpDescriptor, []string) {
18 if doc == nil || doc.Paths == nil {
19 return nil, nil
20 }
21
22 var ops []OpDescriptor
23 var warnings []string
24
25 // Iterate paths in deterministic order so registry output is stable
26 // across boots — important for log diffing and tests.
27 pathKeys := make([]string, 0, len(doc.Paths.Map()))
28 for k := range doc.Paths.Map() {
29 pathKeys = append(pathKeys, k)
30 }
31 sort.Strings(pathKeys)
32
33 for _, path := range pathKeys {
34 item := doc.Paths.Find(path)
35 if item == nil {
36 continue
37 }
38
39 // Method-by-method so the per-method skip reasons are accurate.
40 // (Currently only GET is allowed; other methods are skipped with
41 // an explicit "mutating verb" reason for log clarity.)
42 methodOps := []struct {
43 method string
44 op *openapi3.Operation
45 }{
46 {"GET", item.Get},
47 {"POST", item.Post},
48 {"PUT", item.Put},
49 {"PATCH", item.Patch},
50 {"DELETE", item.Delete},
51 }
52
53 for _, mo := range methodOps {
54 if mo.op == nil {
55 continue
56 }
57 op := classifyOne(spec.Key, path, mo.method, mo.op, item, cfg)
58 ops = append(ops, op)
59 if op.Mode == OpModeSkipped {
60 warnings = append(warnings, fmt.Sprintf(
61 "openapi: %s %s %s — skipped: %s",
62 spec.Key, mo.method, path, op.SkipReason))
63 }
64 }
65 }
66
67 return ops, warnings
68}
69
70// classifyOne is the per-operation classifier. It first decides whether
71// the operation can be exposed at all (mutating verbs, async patterns,

Calls 2

classifyOneFunction · 0.85
FindMethod · 0.45