a-h / generate

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

Values in "examples" (section 10.4) can be of any type #59

Closed yvesf closed 5 years ago

yvesf commented 5 years ago

As written here:

The value of this keyword MUST be an array. There are no restrictions placed on the values within the array. [...]

However, the schema struct defines:

    Examples []string

In consequence it fails if there is a number in the examples array. The error message then looks like this:

the JSON type 'number' cannot be converted into the Go 'string' type on struct 'Schema', field 'Examples'. See input file xxxxxx.json line 553, character 1

I believe this is fixed by just changing []string to []interface{}. Since the Examples field seems to be unused in the generator the will be no conflict.

a-h commented 5 years ago

Fixed in #60