Code generator for JSON schema
Switch branches/tags
Nothing to show
Clone or download
fiorix Add travis-ci integration
Using macOS in travis-ci because homebrew has thrift 0.11 while latest
ubuntu has thrift 0.9, which won't compile the generated thrift spec.
Latest commit 3ece5e3 Sep 9, 2018

README.md

jsonschema2go

Build Status

jsonschema2go is a code generator for JSON schemas. Supports schemas from local files or URL, and generates Go code, or thrift spec.

This is a very naive and incomplete implementation. I wrote this code specifically to codegen the NVD JSON schema, based on a few requirements:

  • The output is a single file
  • Consistent output given same input
  • Capable of generating at least Go and Thrift

Download, install

Requires Go 1.10 or newer. The generated thrift spec requires thrift compiler 0.11 or newer.

Assuming you have a working Go environment:

go get github.com/fiorix/jsonschema2go
go install github.com/fiorix/jsonschema2go

Output binary is $GOPATH/bin/jsonschema2go.

Usage

Generate Go code:

jsonschema2go -gen go https://csrc.nist.gov/schema/nvd/feed/0.1/nvd_cve_feed_json_0.1_beta.schema

Generate Thrift spec:

jsonschema2go -gen thrift https://csrc.nist.gov/schema/nvd/feed/0.1/nvd_cve_feed_json_0.1_beta.schema