Skip to content

pvanacker/protobuf-jsonschema

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

protobuf-jsonschema

Compiles Protocol Buffer IDL to JSON Schema definitions.

Usage

You can use protobuf-jsonschema as a command line tool, or as a function in node.

The CLI can output JSON or YAML (e.g. for Swagger). If you specify a protobuf message name along with a file, it will output just that message and all dependencies. Otherwise, it will output all messages.

$ npm install protobuf-jsonschema -g
$ protobuf-jsonschema --help

  Usage: protobuf-jsonschema [options] <file> [model]

  Options:

    -h, --help             output usage information
    -V, --version          output the version number
    -f, --format [format]  output format: json or yaml [json]
    -a, --allow            true if validator should allow additional properties, false if not. This will apply to all objects in the schema.

In node, protobuf-jsonschema exports a single function that returns an object with the JSON Schema model.

var compile = require('protobuf-jsonschema');

var all = compile({ allow_additional_props: true }, 'models.proto');
var single = compile({ allow_additional_props: true }, 'models.proto', 'MyModel');

License

MIT

About

Compiles Protobuf IDL to JSON Schema

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%