devongovett / protobuf-jsonschema Goto Github PK
View Code? Open in Web Editor NEWCompiles Protobuf IDL to JSON Schema
Compiles Protobuf IDL to JSON Schema
i.e. PROTO:
message TIMESTAMP {
// Represents seconds of UTC time since Unix epoch
required int64 seconds = 1;
// Non-negative fractions of a second at millisecond resolution
required int32 millis = 2;
}
JSON SCHEMA:
"TIMESTAMP": {
"title": "TIMESTAMP",
"type": "object",
"properties": {
"seconds": {
"type": "integer",
"minimum": -9007199254740991,
"maximum": 9007199254740991,
"$comment" : "Represents seconds of UTC time since Unix epoch"
},
"millis": {
"type": "integer",
"minimum": -2147483648,
"maximum": 2147483647,
"$comment" : "Non-negative fractions of a second at millisecond resolution",
}
},
"required": [
"seconds",
"millis"
]
}
According to the Proto3 JSON spec, 64 bit numbers should be treated as string to avoid data loss.
https://developers.google.com/protocol-buffers/docs/proto3#json
I am using the version 1.1.1 of the protobuf-jsonschema and I try to convert the following proto file:
syntax = "proto3";
message Directory {
string name = 1;
repeated Directory sub_directories = 2;
repeated File files = 3;
}
message File {
string name = 1;
}
The result of the execution is the following
/home/.../lib/node_modules/protobuf-jsonschema/index.js:85
var id = lookup.slice(0, i).concat(type).join('.');
^
RangeError: Maximum call stack size exceeded
at Array.join (native)
at Compiler.resolve (/home/.../lib/node_modules/protobuf-jsonschema/index.js:85:46)
at Compiler.build (/home/.../lib/node_modules/protobuf-jsonschema/index.js:128:18)
at Compiler.<anonymous> (/home/.../lib/node_modules/protobuf-jsonschema/index.js:175:14)
at Array.forEach (<anonymous>)
at Compiler.compileMessage (/home/.../lib/node_modules/protobuf-jsonschema/index.js:157:18)
at Compiler.resolve (/home/.../lib/node_modules/protobuf-jsonschema/index.js:101:18)
at Compiler.build (/home/.../lib/node_modules/protobuf-jsonschema/index.js:128:18)
at Compiler.<anonymous> (/home/.../lib/node_modules/protobuf-jsonschema/index.js:175:14)
at Array.forEach (<anonymous>)
I am using the node module on
start:
type: integer
minimum: -9007199254740991
maximum: 9007199254740991
Similar output occurs for int32. These should be omitted.
hello team i tried your library for proto3 syntax but it seems like not supoorted ,(look parser.js line 355 there is no check for syntax).
Hello, thank you for your work. Can you specify the MIT (or Apache2,...) license in a LICENSE file
Converting a .proto file to json using this tool creates a list of definitions, but none of them have the $schema$
field. This is a problem, because then you don't know what version of JSONschema the schema is, and you can't validate it against it.
In the short term however, what draft of jsonschema does this tool generate out?
When map<int32, int32> appears in .proto file, it will throw error.
throw new Error('Can only use strings as map keys at ' + message.id + '.' + field.name);
Is it possible to solve?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.