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

Function loadDoc

core/openapi/classifier_test.go:13–26  ·  view source on GitHub ↗

loadDoc parses an inline OpenAPI YAML/JSON document. Failures abort the test rather than returning an error so callers don't need a t.Fatal at every spec-build site.

(t *testing.T, src string)

Source from the content-addressed store, hash-verified

11// test rather than returning an error so callers don't need a t.Fatal at
12// every spec-build site.
13func loadDoc(t *testing.T, src string) *openapi3.T {
14 t.Helper()
15 loader := openapi3.NewLoader()
16 doc, err := loader.LoadFromData([]byte(src))
17 if err != nil {
18 t.Fatalf("load doc: %v", err)
19 }
20 if err := doc.Validate(context.Background()); err != nil {
21 // Validation failures are warnings in production code but tests
22 // should fail loudly when a fixture is malformed.
23 t.Logf("warning: doc validation: %v", err)
24 }
25 return doc
26}
27
28func TestClassifySingleByID(t *testing.T) {
29 doc := loadDoc(t, `

Calls 1

ValidateMethod · 0.80

Tested by

no test coverage detected