internal/util: move FieldJSONInfo into jsonschema/util (#251)

This CL effectively removes any dependencies on mcp from jsonschema.
This will enable us to move the repo.
This CL also deletes unused marshalStructWithMap and
unmarshalStructWithMap which had a dependency on FieldJSONInfo.

Fixes: #250
This commit is contained in:
Sam Thanawalla 2025-08-06 12:07:57 -04:00 • committed by GitHub
commit b392875dc5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -184,3 +184,31 @@ func TestMarshalStructWithMap(t *testing.T) {
}
})
}
func TestJSONInfo(t *testing.T) {
type S struct {
A int
B int `json:","`
C int `json:"-"`
D int `json:"-,"`
E int `json:"echo"`
F int `json:"foxtrot,omitempty"`
g int `json:"golf"`
}
want := []jsonInfo{
{name: "A"},
{name: "B"},
{omit: true},
{name: "-"},
{name: "echo"},
{name: "foxtrot", settings: map[string]bool{"omitempty": true}},
{omit: true},
}
tt := reflect.TypeFor[S]()
for i := range tt.NumField() {
got := fieldJSONInfo(tt.Field(i))
if !reflect.DeepEqual(got, want[i]) {
t.Errorf("got %+v, want %+v", got, want[i])
}
}
}