Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
MichaelBaySAP opened this issue Nov 22, 2021 · 1 comment
Open

Comments

@MichaelBaySAP
Copy link

MichaelBaySAP commented Nov 22, 2021

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 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
@jaypipes
Copy link

@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.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants