Skip to content

Instantly share code, notes, and snippets.

@brandur
Last active August 29, 2015 14:01
Show Gist options
  • Save brandur/fb3eb8e804cfbf9e1b7d to your computer and use it in GitHub Desktop.
Save brandur/fb3eb8e804cfbf9e1b7d to your computer and use it in GitHub Desktop.
gojsonschema issue #14 reproduction

gojsonschema issue #14 repro

Clone into $GOPATH and run:

git clone https://gist.github.com/fb3eb8e804cfbf9e1b7d.git repro
cd repro
go build
./repro
panic: description must be of type string

goroutine 1 [running]:
runtime.panic(0x1f3e20, 0xc21000a730)
        /usr/local/go/src/pkg/runtime/panic.c:266 +0xb6
main.main()
        /Users/brandur/Documents/go/src/github.com/brandur/gojsonschema-repro/main.go:10 +0xa8

Explanation

The contents of schema.json are the minimal required set of attributes to reproduce the bug. By inspecting them you can see that description points to a subschema as allowed by the specification, but when compiled against gojsonschema it seems to be confused with the description attribute of a schema.

package main
import (
"github.com/sigu-399/gojsonschema"
)
func main() {
_, err := gojsonschema.NewJsonSchemaDocument("file://./schema.json")
if err != nil {
panic(err.Error())
}
}
{
"description": "The description of a schema.",
"definitions": {
"description": {
"description": "A subschema named description."
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment