a-h / generate

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

support recursive arrays / arrays of references (plus a bunch of other changes) #55

Closed mwlazlo closed 5 years ago

mwlazlo commented 6 years ago

This patch enables recursive references and nested arrays of references... I also added a few more test schemas of things I'd like to implement if I get some more time.

mwlazlo commented 6 years ago

So I had another branch I've been working on that I think has reached the point of a 0.1 release. It seems to handle anything I can throw at it with the exception of oneOf, allOf, anyOf.

It also generates code to marshal/unmarshal additionalProperties in the presence of regular properties.

a-h commented 6 years ago

Thanks so much for your efforts, it's looking pretty good to me so far. It definitely fixes a few things. Would be interested to hear from other people using the tool too.

Some of the output looks a little unformatted.

screen shot 2018-10-17 at 20 01 24

Maybe we need to rethink how sensible it is to use the description field as a type name. I'm seeing that used a lot for a long form description, so some type names are coming out silly.

screen shot 2018-10-17 at 20 05 04 screen shot 2018-10-17 at 20 05 22
mwlazlo commented 6 years ago

Fixed those formatting bugs, also removed Description from consideration in getSchemaName().

emicklei commented 5 years ago

is this PR ready to merge?

a-h commented 5 years ago

Sorry for the terribly long delay, thanks for the changes.