Documentation
¶
Overview ¶
Package generate implements a tooling to generate Golang structs from a JSON schema file. It is intended to be used with the go generate, https://blog.golang.org/generate
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildStructs ¶
BuildStructs is a backward-compatibility wrapper for BuildStructsRename.
func BuildStructsRename ¶ added in v0.5.13
func BuildStructsRename(schemaPath string, outputDir string, useMessagePack bool, nameMap map[string]string) error
BuildStructsRename takes a JSON Schema and generates Golang structs that match the schema. The structs include struct tags for marshaling/unmarshaling to/from JSON. One file will be created for each included allOf/oneOf file in the root schema with any allOf files resulting in structs which are embedded in the oneOf files.
The JSON schema can specify more information than the structs enforce (like field size) and so validation of any JSON generated from the structs is still necessary.
If undefined outputPath defaults to the current working directory.
The package name is set to the outputPath directory name.
The nameMap allows specifying the type name of the structure for each JSON file.
NOTE: If oneOf/allOf entries exist than any JSON schema instances in the root schema file will be skipped.
Types ¶
This section is empty.