Add option to generate each root message in a sparate proto file to solve cyclic dependencies
Opened this issue · 0 comments
Some XSD schemas have cyclic dependencies between namespaces when some type1 from namespace1 use field of type2 from namespace2, but that field of type2 from namespace2 use some another type3 from namespace1.
Mentioned type1, type2 and type2 does not create cyclic dependency itself, by type1 and type3 are located in one namespace which cause cyclic dependencies between proto file imports because one proto file is generated for one namespace.
This issue become more actual after derivationBySubsumption was implemented, because child types inserted into parent message bring their namespace imports into parent file and usually child messages are based on some types located in parent namespace. So this option very often cause cyclic dependencies.
There are two options to solve this issue:
- Extract only conflict types automatically into separate proto file like mentioned in ProtoSerializer line 706.
- Add new option to serialize each root message into its own separate proto file, which should avoid cyclic dependencies between namespaces completely by default.
In case of option 1, all conflict types should be extracted into their own proto files because of two reason:
- they may be from different namespaces and cannot put into one proto file;
- they may also create cyclic dependencies together in one file between this extracted file and basic namespace file, so it will be better to put each conflict message into separate file.
Additionally, in case of option 2 I propose to add new option to avoid adding enum type name to enum values, as each enum will be in separate file and all its values be unique by default.