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

xs:annotations not support #10

Closed ghilainm closed 5 years ago

ghilainm commented 5 years ago

The code seems to not support xs:annotations.

Here is an example of failing xsd:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" >
  <xs:simpleType name="XXXX">
    <xs:annotation>
      <xs:documentation>
        <usedBy>Used somewhere over a rainbow</usedBy>
      </xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:token">
      <xs:pattern value=".{1,24}" />
    </xs:restriction>
  </xs:simpleType>
</xs:schema>

Remove the xs:annotations and it works fine :)

andrewbober commented 5 years ago

Hi ghilainm - Thanks for the feedback. I can see what's wrong. It's actually the xs:documentation processing. I have a fix I will publish tomorrow after I complete unit tests.

ghilainm commented 5 years ago

@andrewbober Thx a lot! By the way how do you activate debug of the tool?

andrewbober commented 5 years ago

Xsd2JsonSchema uses the debug library for logging. Enable debugging output by setting the DEBUG environment variable.

I like to use this setting: export DEBUG=xsd2jsonschema:BaseConverter,xsd2jsonschema:ParsingState

For all possible logs use this setting (warning - this results in a ton of logging) export DEBUG=xsd2jsonschema:*

andrewbober commented 5 years ago

This is resolved in version 0.3.2