Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/aaharu/schemarshal

Generates Go struct types from a JSON Schema.
https://github.com/aaharu/schemarshal

go go-generate json-schema json-schema-to-go-structs struct

Last synced: about 1 month ago
JSON representation

Generates Go struct types from a JSON Schema.

Awesome Lists containing this project

README

        

# schemarshal [![wercker status](https://app.wercker.com/status/ebb1f8ec249177acd0d47bd8a6a59dd2/s/master "wercker status")](https://app.wercker.com/project/byKey/ebb1f8ec249177acd0d47bd8a6a59dd2)

[![Coverage Status](https://coveralls.io/repos/github/aaharu/schemarshal/badge.svg)](https://coveralls.io/github/aaharu/schemarshal)
[![Go Report Card](https://goreportcard.com/badge/github.com/aaharu/schemarshal)](https://goreportcard.com/report/github.com/aaharu/schemarshal)
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Faaharu%2Fschemarshal.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Faaharu%2Fschemarshal?ref=badge_shield)

Generates Go struct types from a [JSON Schema](http://json-schema.org/).

## Installation

```bash
go get -u github.com/aaharu/schemarshal
```

## Usage

```
SYNOPSIS
schemarshal [options] []
OPTIONS
-h, -help
Show this help message.
-f , -file
Input file name.
-o , -output
Write output to file instead of stdout.
-p , -package
Package name for output. (default `main`)
-t , -type
Set default Type name.
-v, -version
Show version.
-nc, -nocomment
Do not output comments.
```

```bash
# with args
schemarshal -o api/schema/gen.go -p gen -f schema.json

# pipe
curl -s "https://raw.githubusercontent.com/aaharu/schemarshal/master/test_data/disk.json" | schemarshal
```

## TODO

- [ ] use go/ast

## [Examples](examples.md)

- [example a.json](examples.md#ajson)
- [example qiita schema](examples.md#qiita-v2-schema)

## Dependencies

* https://github.com/lestrrat/go-jsschema
- JSON Schema parser
- MIT License
* golang.org/x/crypto/ssh/terminal
- https://godoc.org/golang.org/x/crypto/ssh/terminal
- https://golang.org/LICENSE

## Similar Projects

* https://github.com/idubinskiy/schematyper
* https://github.com/dameleon/structr
* https://github.com/interagent/schematic

## License

BSD-2-Clause

[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Faaharu%2Fschemarshal.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Faaharu%2Fschemarshal?ref=badge_large)