# jsonschema-protobuf

> json-schema.org to protobuf object converter

Latest version **1.0.2** (published 2017-12-24) · BSD license · 0 weekly downloads

## Install

```sh
npm install jsonschema-protobuf
pnpm add jsonschema-protobuf
yarn add jsonschema-protobuf
bun add jsonschema-protobuf
```

Provides the command `jsonschema-protobuf`.

## Health

**Score 23/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2017-12-24 |
| First published | 2015-08-31 |
| Weekly downloads | 0 |
| License | BSD |
| TypeScript types | separate (@types/jsonschema-protobuf) |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 103 |
| Author | Karissa McKelvey |
| Maintainers | karissa |

## Links

- npm: https://www.npmjs.com/package/jsonschema-protobuf
- Repository: https://github.com/karissa/jsonschema-protobuf
- Issues: https://github.com/karissa/jsonschema-protobuf/issues
- npm.io page: https://npm.io/package/jsonschema-protobuf

## Dependencies (2)

- [tape](https://npm.io/package/tape.md) ^4.2.0
- [protocol-buffers-schema](https://npm.io/package/protocol-buffers-schema.md) ^2.0.3

## Recent versions

- 1.0.2 (latest) — 2017-12-24
- 1.0.1 — 2015-08-31
- 1.0.0 — 2015-08-31

## README

# jsonschema-protobuf
[![NPM](https://nodei.co/npm/jsonschema-protobuf.png)](https://nodei.co/npm/jsonschema-protobuf/)

Converts [JSON Schema](http://json-schema.org/) to [Protocol Buffers](https://developers.google.com/protocol-buffers).

## Install
```
npm install -g jsonschema-protobuf
```

## Example
```
$ jsonschema-protobuf test.jsonschema
syntax = "proto2";

message person {
  message location {
    optional string city = 1;
    optional string state = 2;
  }

  required string name = 1;
  required int32 age = 2;
  required int32 income = 3;
  optional string universe = 4;
  optional boolean living = 5;
  repeated string alterEgos = 6;
}
```

test.jsonschema
```
{
  "type": "object",
  "name": "person",
  "properties": {
    "name": {"type": "string"},
    "age": {"type": "integer", "min": 0, "max": 120},
    "income": {"type": "number", "min": 0},
    "universe": {"type": "string", "enum": ["Marvel", "DC"]},
    "living": {"type": "boolean", "default": true},
    "alterEgos": {"type": "array", "items": {"type": "string"}},
    "location": {
      "type": "object",
      "properties": {
        "city": {"type": "string"},
        "state": {"type": "string", "regex": "/[A-Z]{2}/"}
      }
    }
  },
  "required": ["name", "age", "income"]
}
```

## JS usage

```js
var convert = require('jsonschema-protobuf')
var jsonschema = fs.readFileSync("test.jsonschema").toString()
var protobuf = convert(jsonschema)
console.log(protobuf)
```

## TODO

* Enum

---
_Source: https://npm.io/package/jsonschema-protobuf · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
