MCPcopy Index your code
hub / github.com/danielgtaylor/huma / TestParameterExampleRedundancy

Function TestParameterExampleRedundancy

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

Source from the content-addressed store, hash-verified

3706}
3707
3708func TestParameterExampleRedundancy(t *testing.T) {
3709 _, app := humatest.New(t, huma.DefaultConfig("Test API", "1.0.0"))
3710
3711 type Input struct {
3712 Name string `query:"name" example:"world"`
3713 }
3714
3715 huma.Get(app, "/test", func(ctx context.Context, input *Input) (*struct{}, error) {
3716 return nil, nil
3717 })
3718
3719 param := app.OpenAPI().Paths["/test"].Get.Parameters[0]
3720 assert.Equal(t, "name", param.Name)
3721
3722 // The example should be in the schema, not at the parameter level.
3723 // OpenAPI 3.1+ prefers examples in the schema.
3724 assert.Nil(t, param.Example)
3725 require.NotNil(t, param.Schema)
3726 assert.Equal(t, []any{"world"}, param.Schema.Examples)
3727}
3728
3729func TestCustomSchemaErrors(t *testing.T) {
3730 // Ensure that custom schema errors are correctly reported without having

Callers

nothing calls this directly

Calls 3

NewFunction · 0.92
GetMethod · 0.65
OpenAPIMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…