generate

package
v0.5.11 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 21, 2018 License: MIT Imports: 12 Imported by: 0

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

func BuildStructs(schemaPath string, outputDir string, useMessagePack bool) error

BuildStructs 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.

NOTE: If oneOf/allOf entries exist than any JSON schema instances in the root schema file will be skipped.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL