| 3470 | } |
| 3471 | |
| 3472 | func TestNestedResolverWithPath(t *testing.T) { |
| 3473 | r, app := humatest.New(t, huma.DefaultConfig("Test API", "1.0.0")) |
| 3474 | huma.Register(app, huma.Operation{ |
| 3475 | OperationID: "test", |
| 3476 | Method: http.MethodPut, |
| 3477 | Path: "/test", |
| 3478 | }, func(ctx context.Context, input *NestedResolverRequest) (*struct{}, error) { |
| 3479 | return nil, nil |
| 3480 | }) |
| 3481 | |
| 3482 | req, _ := http.NewRequest(http.MethodPut, "/test", strings.NewReader(`{"field1": {"foo": [{"field2": "bar"}]}}`)) |
| 3483 | req.Header.Set("Content-Type", "application/json") |
| 3484 | w := httptest.NewRecorder() |
| 3485 | r.ServeHTTP(w, req) |
| 3486 | assert.Equal(t, http.StatusUnprocessableEntity, w.Code, w.Body.String()) |
| 3487 | assert.Contains(t, w.Body.String(), `"location":"body.field1.foo[0].field2"`) |
| 3488 | } |
| 3489 | |
| 3490 | type ResolverCustomStatus struct{} |
| 3491 | |