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

Function TestClassifyExposeTopLevelSingleObject

core/openapi/classifier_test.go:351–381  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

349}
350
351func TestClassifyExposeTopLevelSingleObject(t *testing.T) {
352 doc := loadDoc(t, `
353openapi: 3.0.0
354info: { title: Test, version: 1.0.0 }
355paths:
356 /api/dataset/{datasetId}/summary.json:
357 get:
358 operationId: getDatasetSummary
359 parameters:
360 - { name: datasetId, in: path, required: true, schema: { type: string } }
361 responses:
362 '200':
363 description: ok
364 content:
365 application/json:
366 schema:
367 type: object
368 properties:
369 id: { type: string }
370 name: { type: string }
371`)
372
373 spec := &Spec{Key: "is"}
374 cfg := SpecConfig{Operations: map[string]OperationOverride{
375 "getDatasetSummary": {ExposeTopLevel: true},
376 }}
377 ops, _ := classifyAll(spec, doc, cfg)
378 if ops[0].Mode != OpModeSingleByID {
379 t.Errorf("opt-in mode = %v, want OpModeSingleByID (object response, not array)", ops[0].Mode)
380 }
381}
382
383func TestClassifyAppliesOperationDefaults(t *testing.T) {
384 doc := loadDoc(t, `

Callers

nothing calls this directly

Calls 2

loadDocFunction · 0.85
classifyAllFunction · 0.85

Tested by

no test coverage detected