MCPcopy
hub / github.com/danielgtaylor/huma / TestNestedResolverWithPath

Function TestNestedResolverWithPath

huma_test.go:3472–3488  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

3470}
3471
3472func 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
3490type ResolverCustomStatus struct{}
3491

Callers

nothing calls this directly

Calls 3

NewFunction · 0.92
ServeHTTPMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…