devongovett / protobuf-jsonschema

Compiles Protobuf IDL to JSON Schema
119 stars 37 forks source link

Problem converting messages with recursive type references. #11

Open chillinski opened 5 years ago

chillinski commented 5 years ago

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

thetimetraveler commented 5 years ago

@devongovett any thoughts in this issue?

geek29 commented 5 years ago

@devongovett I am also stuck at recursivee type references. Json schema supports recursive types. I looked into the code specifically resolve method : resolve but couldnt figure out why it is not able to resolve to use already defined messages

chillinski commented 5 years ago

I will have a look into this again. It shouldn't be a big problem to solve this.