Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/okdistribute/protobufit
Turn that schema into a protobuf
https://github.com/okdistribute/protobufit
Last synced: 27 days ago
JSON representation
Turn that schema into a protobuf
- Host: GitHub
- URL: https://github.com/okdistribute/protobufit
- Owner: okdistribute
- Created: 2015-08-31T23:31:12.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-09-04T15:50:12.000Z (over 9 years ago)
- Last Synced: 2024-11-03T11:34:22.890Z (about 1 month ago)
- Language: JavaScript
- Homepage:
- Size: 137 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
- awesome-starred - okdistribute/protobufit - Turn that schema into a protobuf (others)
README
# protobufit
Converts various schema types into [Protocol Buffers](https://developers.google.com/protocol-buffers/?hl=en) format (v2).
Supports:
* [SQL `CREATE TABLE` statements](http://www.w3schools.com/sql/sql_create_table.asp)
* [JSON Schema](json-schema.org)Yes, this handles:
* Multiple schema definitions in a single file
* Tries to auto-detect the given schema format if not specified
* `required` and `repeated````
npm install -g protobufit
```### CLI usage
```
protobufit [input-file] [-f ]
: 'sql' or 'jsonschema'
```### Example
```
protobufit schema.sql -f sql > schema.proto
```schema.sql
```
CREATE TABLE "pluto" (
"boroughtext" text,
"block" integer,
"lot" bigint,
"cd" date NOT NULL,
);
```schema.proto
```
syntax = "proto2";message pluto {
optional string boroughtext = 1;
optional int32 block = 2;
optional int64 lot = 3;
required string cd = 4;
```### JS usage
```js
var protobufit = require('protobufit')
var data = fs.readFileSync('schema.sql').toString()
var opts = {format: 'sql'}
console.log(protobufit(data, opts))
```### TODO
* datapackage.json
* Rdata?