(t *testing.T)
| 349 | } |
| 350 | |
| 351 | func TestClassifyExposeTopLevelSingleObject(t *testing.T) { |
| 352 | doc := loadDoc(t, ` |
| 353 | openapi: 3.0.0 |
| 354 | info: { title: Test, version: 1.0.0 } |
| 355 | paths: |
| 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 | |
| 383 | func TestClassifyAppliesOperationDefaults(t *testing.T) { |
| 384 | doc := loadDoc(t, ` |
nothing calls this directly
no test coverage detected