Closed DmitrySamoylov closed 4 years ago
Consider this schema:
<?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://example.com" targetNamespace="http://example.com" elementFormDefault="qualified"> <xs:complexType name="FooType"> <xs:sequence> <xs:element name="Extension"> <xs:complexType/> </xs:element> </xs:sequence> </xs:complexType> <xs:complexType name="BarType"> <xs:sequence> <xs:element name="Extension"> <xs:complexType/> </xs:element> </xs:sequence> </xs:complexType> <xs:element name="Foo" type="tns:FooType"/> </xs:schema>
Currently Extension type is generated twice. What if we put it under a separate module:
Extension
pub mod foo_type { use super::*; #[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)] #[yaserde(prefix = "tns", namespace = "tns: http://example.com")] pub struct Extension {} } #[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)] #[yaserde(prefix = "tns", namespace = "tns: http://example.com")] pub struct FooType { #[yaserde(prefix = "tns", rename = "Min")] pub extension: foo_type::Extension, } pub mod bar_type { use super::*; #[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)] #[yaserde(prefix = "tns", namespace = "tns: http://example.com")] pub struct Extension {} } #[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)] #[yaserde(prefix = "tns", namespace = "tns: http://example.com")] pub struct BarType { #[yaserde(prefix = "tns", rename = "Min")] pub extension: bar_type::Extension, }
Test case (note that it is in a separate branch)
Another case that looks related
Consider this schema:
Currently
Extension
type is generated twice. What if we put it under a separate module: