Closed Kiyo5hi closed 3 years ago
Hello @Kiyo5hi, and thanks for your interest in the project.
In your example, are your proto files separated into different packages? Proto packages are namespaced, and protoc-gen-jsonschema produces one file per message.
Eg is a/pet.proto in a package called "a", and b/pet.proto in a package with a different name like "b"?
If so, then you could look at using the prefix_schema_files_with_package
option. This would actually result in the generated jsonschema files being in different directories (matching your proto package structure). This option was introduced a long time ago and probably doesn't get a lot of use, but it might just be the thing you need! You will see an example of this here.
Please let me know how you get on with this!
Otherwise you could consider just running protoc more than once (once against the A directory, then a second time against the B directory (though I'm not entirely sure of your use-case of course).
That does the math for me, though it does not maintain the original directory structure but using packages is a solution; thank you!
BTW, how do I apply multiple options at once?
I'm pleased to hear that works!
Use multiple options with this syntax:
protoc --jsonschema_out=prefix_schema_files_with_package,all_fields_required:.
(Separated by comma)
I've defined two protos with exactly the same content, but in different folders as such:
As I expect the output should be in the same structure as shown above just like when using
--python_out
or other options,protoc
throwsTried to write the same file twice.
Even if I rename one of the messages to
message Pet1
, the output structure is flat, like so:Should that be fixed? Cuz reading and writing files recursively should be a feature.