Compares two popular Go libraries for generating struct types from JSON Schema documents: github.com/atombender/go-jsonschema (supports draft-07) and git.sr.ht/~emersion/go-jsonschema (supports 2020-12). The first generates individual named types with enum constants and comprehensive struct tags, while the second creates a single struct with anonymous nested types. Both tools can be integrated using go:generate directives, with tips provided for using $refs to create named types instead of anonymous ones.

26m read timeFrom jvt.me
Post cover image
Table of contents
The schemaGenerating with github.com/atombender/go-jsonschemaGenerating with git.sr.ht/~emersion/go-jsonschemaTipsFinal thoughts

Sort: