diff --git a/go.mod b/go.mod index 7e337bb..c0bb714 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.25.0 require ( github.com/gobuffalo/here v0.6.0 - github.com/google/jsonschema-go v0.4.2 + github.com/google/jsonschema-go v0.4.3 github.com/jsonnet-libs/docsonnet v0.0.6 github.com/markbates/pkger v0.15.1 github.com/spf13/cobra v1.10.2 diff --git a/go.sum b/go.sum index 2f359f8..e78fc2f 100644 --- a/go.sum +++ b/go.sum @@ -11,8 +11,8 @@ github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/go-jsonnet v0.21.0 h1:43Bk3K4zMRP/aAZm9Po2uSEjY6ALCkYUVIcz9HLGMvA= github.com/google/go-jsonnet v0.21.0/go.mod h1:tCGAu8cpUpEZcdGMmdOu37nh8bGgqubhI5v2iSk3KJQ= -github.com/google/jsonschema-go v0.4.2 h1:tmrUohrwoLZZS/P3x7ex0WAVknEkBZM46iALbcqoRA8= -github.com/google/jsonschema-go v0.4.2/go.mod h1:r5quNTdLOYEz95Ru18zA0ydNbBuYoo9tgaYcxEYhJVE= +github.com/google/jsonschema-go v0.4.3 h1:/DBOLZTfDow7pe2GmaJNhltueGTtDKICi8V8p+DQPd0= +github.com/google/jsonschema-go v0.4.3/go.mod h1:r5quNTdLOYEz95Ru18zA0ydNbBuYoo9tgaYcxEYhJVE= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= diff --git a/vendor/github.com/google/jsonschema-go/jsonschema/infer.go b/vendor/github.com/google/jsonschema-go/jsonschema/infer.go index 9c195f5..1b3d975 100644 --- a/vendor/github.com/google/jsonschema-go/jsonschema/infer.go +++ b/vendor/github.com/google/jsonschema-go/jsonschema/infer.go @@ -7,6 +7,7 @@ package jsonschema import ( + "encoding" "fmt" "log/slog" "maps" @@ -199,14 +200,12 @@ func forType(t reflect.Type, seen map[reflect.Type]bool, ignore bool, schemas ma // Unrestricted case reflect.Map: - if t.Key().Kind() != reflect.String { + if t.Key().Kind() != reflect.String && !t.Key().Implements(reflect.TypeFor[encoding.TextMarshaler]()) { if ignore { return nil, nil // ignore } return nil, fmt.Errorf("unsupported map key type %v", t.Key().Kind()) } - if t.Key().Kind() != reflect.String { - } s.Type = "object" s.AdditionalProperties, err = forType(t.Elem(), seen, ignore, schemas) if err != nil { diff --git a/vendor/github.com/google/jsonschema-go/jsonschema/validate.go b/vendor/github.com/google/jsonschema-go/jsonschema/validate.go index bbef590..03fe409 100644 --- a/vendor/github.com/google/jsonschema-go/jsonschema/validate.go +++ b/vendor/github.com/google/jsonschema-go/jsonschema/validate.go @@ -262,14 +262,15 @@ func (st *state) validate(instance reflect.Value, schema *Schema, callerAnns *an } if schema.AnyOf != nil { // We must visit them all, to collect annotations. - ok := false + var errs []error for _, ss := range schema.AnyOf { - if valid(ss, &anns) { - ok = true + if err := st.validate(instance, ss, &anns); err != nil { + errs = append(errs, err) } } - if !ok { - return fmt.Errorf("anyOf: did not validate against any of %v", schema.AnyOf) + if len(errs) == len(schema.AnyOf) { + return fmt.Errorf("anyOf: did not validate against any of %v:\n%v", + schema.AnyOf, errors.Join(errs...)) } } if schema.OneOf != nil { diff --git a/vendor/modules.txt b/vendor/modules.txt index fda199c..eb59e41 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -14,7 +14,7 @@ github.com/google/go-jsonnet/internal/errors github.com/google/go-jsonnet/internal/parser github.com/google/go-jsonnet/internal/program github.com/google/go-jsonnet/toolutils -# github.com/google/jsonschema-go v0.4.2 +# github.com/google/jsonschema-go v0.4.3 ## explicit; go 1.23.0 github.com/google/jsonschema-go/jsonschema # github.com/inconshreveable/mousetrap v1.1.0