From 51065ea828bd29210497158dcb81dee3efb6bfcc Mon Sep 17 00:00:00 2001 From: Yann Hamon Date: Sun, 16 Jul 2023 09:32:36 +0200 Subject: [PATCH] Force Draft version of JsonSchema --- pkg/validator/validator.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkg/validator/validator.go b/pkg/validator/validator.go index f4827c8..b9f7c8d 100644 --- a/pkg/validator/validator.go +++ b/pkg/validator/validator.go @@ -6,6 +6,7 @@ import ( "errors" "fmt" "io" + "strings" jsonschema "github.com/santhosh-tekuri/jsonschema/v5" _ "github.com/santhosh-tekuri/jsonschema/v5/httploader" @@ -254,7 +255,12 @@ func downloadSchema(registries []registry.Registry, kind, version, k8sVersion st for _, reg := range registries { path, schemaBytes, err = reg.DownloadSchema(kind, version, k8sVersion) if err == nil { - schema, err := jsonschema.CompileString(path, string(schemaBytes)) + c := jsonschema.NewCompiler() + c.Draft = jsonschema.Draft4 + if err := c.AddResource(path, strings.NewReader(string(schemaBytes))); err != nil { + continue + } + schema, err := c.Compile(path) // If we got a non-parseable response, we try the next registry if err != nil { continue