You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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)
}
}`
Error message:
The text was updated successfully, but these errors were encountered:
MichaelBaySAP
changed the title
Schema and json rejected schema must be canonical
Schema and json rejected; error message: schema must be canonical
Nov 22, 2021
@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.)
schema2.json
{ "$schema": "http://json-schema.org/draft-07/schema", "definitions": { "templateDefinition": { "description": "The overall Template Definition.", "type": "object", "properties": { "kind": "string" } } } }
testinput2.json
{ "templateDefinition": { "kind": "test" } }
Test Code
`schemaLoader := gojsonschema.NewReferenceLoader("file://schema2.json")
documentLoader := gojsonschema.NewReferenceLoader("file://testinput2.json")
Error message:
The text was updated successfully, but these errors were encountered: