andrewbober / xsd2jsonschema

A pure JavaScript library for translating complex XML Schemas into JSON Schemas.
https://www.xsd2jsonschema.org
Apache License 2.0
48 stars 25 forks source link

Fix support for XSD group #13

Open ghilainm opened 5 years ago

ghilainm commented 5 years ago

For the moment xs:group are handled the same way xs:complexType are handled if I am not wrong.

A new property is added to the type define with points to a type defined by the group. This should not be the case but rather all the property defined in the group should be copied in the type itself as if they were directly defined in the type.

andrewbober commented 5 years ago

Just confirming: Are you talking about group references or group definitions?

ghilainm commented 5 years ago

If I am not wrong group references. I have in my XSDs a group definition with all the message headers and those headers are referenced in all messages via a group a reference.

With your implement I have a new field messageHeader instead of having all the headers copied to each of the message directly at the root of the message.

andrewbober commented 5 years ago

Are you able to share the schema in question?

ghilainm commented 5 years ago

Example of definition of message group

 <xs:group name="MESSAGE">
    <xs:sequence>
      <xs:element name="messageSender" type="MessageSenderContentType">
        <xs:annotation>
          <xs:documentation>
            <description xmlns="" value="Message sender" />
          </xs:documentation>
        </xs:annotation>
      </xs:element>
    </xs:sequence>
  </xs:group>

Example of usage:

<xs:complexType name="SomeMessageType">
    <xs:sequence>
      <xs:group ref="MESSAGE" />
    </xs:sequence>
    <xs:attribute name="SomeAttribute" type="xs:token" />
  </xs:complexType>