(t *testing.T, ctx string, schema *openapi.Schema, types map[string]*openapi.Schema, expected *additionalPropsType, prefix string)
| 417 | } |
| 418 | |
| 419 | func validateAdditionalPropsSchema(t *testing.T, ctx string, schema *openapi.Schema, types map[string]*openapi.Schema, expected *additionalPropsType, prefix string) { |
| 420 | // Handle reference case |
| 421 | if expected.Ref != "" { |
| 422 | if schema.Ref == "" { |
| 423 | t.Errorf("%s: %sexpected reference to %s, but got inline schema", ctx, prefix, expected.Ref) |
| 424 | return |
| 425 | } |
| 426 | if schema.Ref != expected.Ref { |
| 427 | t.Errorf("%s: %sexpected reference %s, got %s", ctx, prefix, expected.Ref, schema.Ref) |
| 428 | } |
| 429 | return |
| 430 | } |
| 431 | |
| 432 | // Resolve reference if present |
| 433 | if schema.Ref != "" { |
| 434 | typeName := nameFromRef(schema.Ref) |
| 435 | resolvedSchema, ok := types[typeName] |
| 436 | if !ok { |
| 437 | t.Errorf("%s: %scould not resolve reference %s", ctx, prefix, schema.Ref) |
| 438 | return |
| 439 | } |
| 440 | schema = resolvedSchema |
| 441 | } |
| 442 | |
| 443 | // Check type |
| 444 | if string(schema.Type) != expected.Type { |
| 445 | t.Errorf("%s: %sexpected type %s, got %s", ctx, prefix, expected.Type, schema.Type) |
| 446 | } |
| 447 | |
| 448 | // Check array items if expected |
| 449 | if expected.Items != nil { |
| 450 | if schema.Items == nil { |
| 451 | t.Errorf("%s: %sexpected array items to be set", ctx, prefix) |
| 452 | } else { |
| 453 | validateAdditionalPropsSchema(t, ctx, schema.Items, types, expected.Items, prefix+"items: ") |
| 454 | } |
| 455 | } |
| 456 | } |
| 457 | |
| 458 | func TestTypesOnlyDifferByEnum(t *testing.T) { |
| 459 | root := codegen.RunDSL(t, dsls.StringEnumBodyDSL()) |
no test coverage detected