internal/mcp/jsonschema: apply schema defaults to an instance

This CL handles only the limited case of defaults on properties.

This is just a start: I need to think more about defaults on other
schema keywords, and I need to set defaults recursively.

As part of this work, I realized that the Schema.Default field is
more usable when represented as a json.RawMessage instead of a *any.

Change-Id: Iedcedb405b52607a312dbd895fa61e7f7f94c6bc
Reviewed-on: https://go-review.googlesource.com/c/tools/+/676938
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Auto-Submit: Jonathan Amsterdam <jba@google.com>
This commit is contained in:
Jonathan Amsterdam 2025-05-27 07:08:57 -04:00 • committed by Gopher Robot
commit c5a3591742

View file

@ -223,7 +223,7 @@ func (root *Schema) checkStructure() error {
func (s *Schema) checkLocal(report func(error)) {
addf := func(format string, args ...any) {
msg := fmt.Sprintf(format, args...)
report(fmt.Errorf("jsonschema.Schema: %s: %s", s.path, msg))
report(fmt.Errorf("jsonschema.Schema: %s: %s", s, msg))
}
if s == nil {