internal/mcp/jsonschema: validate defaults
Optionally validate a schema's defaults when resolving it. We simply walk the tree of schemas, validating each locally. This can't handle dynamic references, which require maintaing the stack from the root. It seems unlikely that a default would require one, however. Since there may be other options to Resolve, use an options struct to future-proof it. Also, fix a bug: you can't resolve a schema twice. Change-Id: I374c582d9cc49d66d4ed56233d1070b8b3263bdf Reviewed-on: https://go-review.googlesource.com/c/tools/+/676395 Reviewed-by: Alan Donovan <adonovan@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
parent
b0d437f1c5
commit
9e88f4ff68
1 changed files with 110 additions and 28 deletions
|
|
@ -182,7 +182,9 @@ type anchorInfo struct {
|
|||
// String returns a short description of the schema.
|
||||
func (s *Schema) String() string {
|
||||
if s.uri != nil {
|
||||
return s.uri.String()
|
||||
if u := s.uri.String(); u != "" {
|
||||
return u
|
||||
}
|
||||
}
|
||||
if a := cmp.Or(s.Anchor, s.DynamicAnchor); a != "" {
|
||||
return fmt.Sprintf("%q, anchor %s", s.base.uri.String(), a)
|
||||
|
|
|
|||
Loading…
Reference in a new issue