mirror of
https://github.com/Fishwaldo/huma.git
synced 2025-03-15 19:31:27 +00:00
fix: skip fields named "-" when generating schemas
This commit is contained in:
parent
8004efb597
commit
3a6046412a
2 changed files with 15 additions and 0 deletions
|
@ -169,6 +169,11 @@ func GenerateWithMode(t reflect.Type, mode Mode, schema *Schema) (*Schema, error
|
|||
name = jsonTags[0]
|
||||
}
|
||||
|
||||
if name == "-" {
|
||||
// Skip deliberately filtered out items
|
||||
continue
|
||||
}
|
||||
|
||||
s, err := GenerateWithMode(f.Type, mode, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
@ -515,6 +515,16 @@ func TestSchemaNonStringExampleErrorCast(t *testing.T) {
|
|||
assert.Error(t, err)
|
||||
}
|
||||
|
||||
func TestSchemaFieldFilteredOut(t *testing.T) {
|
||||
type Example struct {
|
||||
Foo bool `json:"-"`
|
||||
}
|
||||
|
||||
s, err := Generate(reflect.ValueOf(Example{}).Type())
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, 0, len(s.Properties))
|
||||
}
|
||||
|
||||
func TestPointerHelpers(t *testing.T) {
|
||||
// Just confirm this compiles.
|
||||
_ = Schema{
|
||||
|
|
Loading…
Add table
Reference in a new issue