interagent / schematic

A Go point of view on JSON Schema
https://godoc.org/github.com/interagent/schematic
MIT License
321 stars 33 forks source link

Bugfix/fix time added to everything #54

Closed FreekingDean closed 4 years ago

FreekingDean commented 4 years ago

fixes #31

Its not an insanely elegant solution and doesn't cover every case (ex, a link targetSchema/Schema with custom properties requiring time), but it seems to do the trick!

I think if instead we do a 2 pass evaluation on the schema we could know better ahead of time if it is fully required or not.

bernerdschaefer commented 4 years ago

Hey @FreekingDean, thanks for this! I'd not seen #31 (2014, eesh!).

I've seen other code generators (particularly gRPC) add issues like this by injecting something that does use the import but throws it away, like var _ = time.Second. What do you think about having schematic do the same? Looks like it could perhaps go at the end of imports.tmpl?

FreekingDean commented 4 years ago

Hello! Sorry for the delay. That seems like something that would totally solve the problem in a much simpler way. :)

bernerdschaefer commented 4 years ago

@FreekingDean looks like it also needed a go generate after updating the template, which I've pushed up. I verified that the generated code for the heroku schema still compiles correctly and now includes the time usage, so this looks good. Thanks for your contribution!