xeipuuv/gojsonschema

Schema and json rejected; error message: schema must be canonical

MichaelBaySAP opened this issue · 1 comments

schema2.json
{ "$schema": "http://json-schema.org/draft-07/schema", "definitions": { "templateDefinition": { "description": "The overall Template Definition.", "type": "object", "properties": { "kind": "string" } } } }

image

testinput2.json
{ "templateDefinition": { "kind": "test" } }
image

Test Code

`schemaLoader := gojsonschema.NewReferenceLoader("file://schema2.json")
documentLoader := gojsonschema.NewReferenceLoader("file://testinput2.json")

result, err := gojsonschema.Validate(schemaLoader, documentLoader)
if err != nil {
	panic(err.Error())
}

if result.Valid() {
	fmt.Printf("The document is valid\n")
} else {
	fmt.Printf("The document is not valid. see errors :\n")
	for _, desc := range result.Errors() {
		fmt.Printf("- %s\n", desc)
	}
}`

image

Error message:
image

@MichaelBaySAP use file:///schema2.json (note: the prefix for files is file:// and then you need an absolute path, which on Linux systems, starts with another forward slash.)