Open MichaelBaySAP opened 3 years ago
schema2.json { "$schema": "http://json-schema.org/draft-07/schema", "definitions": { "templateDefinition": { "description": "The overall Template Definition.", "type": "object", "properties": { "kind": "string" } } } }
{ "$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" } }
{ "templateDefinition": { "kind": "test" } }
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) } }`
Error message:
@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.)
file:///schema2.json
file://
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: