| 3706 | } |
| 3707 | |
| 3708 | func 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 | |
| 3729 | func TestCustomSchemaErrors(t *testing.T) { |
| 3730 | // Ensure that custom schema errors are correctly reported without having |