santhosh-tekuri/jsonschema

Invalid JSON schema does not error out

Closed this issue · 2 comments

Hello! I am testing out adding resource with invalid json, such as {}A. In this example, the trailing character is invalid. However, AddResource does not return an error.

Here is how to reproduce the error:

func TestInvalidJsonSchema(t *testing.T) {
	if err := jsonschema.NewCompiler().AddResource("schema.json", strings.NewReader("{}A")); err == nil {
		t.Error("error expected")
	}
}

I was expecting decoder.Token) to not return nil in this line of code. But it returns nil.

fixed with 620600d

thanks for the prompt fix!!