a-h / generate

Generates Go (golang) Structs from JSON schema.
MIT License
444 stars 137 forks source link

Not enough information in error messages #10

Closed wizpnz closed 7 years ago

wizpnz commented 7 years ago

When I try to convert some complex structure, I got messages like: Failed to parse the input JSON schema with error json: cannot unmarshal string into Go value of type jsonschema.Schema

There is no any information about a string in schema, where is a problem.

a-h commented 7 years ago

Do you have an example of the schema that's failing?

a-h commented 7 years ago

I've improved the error messages by checking whether there have been various JSON parsing and conversion errors. Here's a couple of examples:

Cannot parse JSON schema due to a syntax error at line 3, character 7: invalid character 'n' looking for beginning of object key string

The JSON type 'array' cannot be converted into the Go 'string' type on struct 'Schema', field 'type'. See input file line 13, character 23

a-h commented 7 years ago

See https://github.com/a-h/generate/commit/6d7bec4ccef3554fe527395a742916438465a301