fnogatz / xsd2json

Translate XML Schema into equivalent JSON Schema
MIT License
149 stars 28 forks source link

Problem with elements named "description" #30

Closed dguyonvarch closed 8 years ago

dguyonvarch commented 8 years ago

the xsd2jon command fails with this xsd :

<?xml version="1.0" encoding="UTF-8"?>
<s:schema targetNamespace="http://www.mgdis.fr/public/demande-paiement/v1" 
    xmlns:s="http://www.w3.org/2001/XMLSchema" 
    xmlns:tns="http://www.mgdis.fr/public/demande-paiement/v1" 
    elementFormDefault="qualified">
  <s:element name="acomplexobject">
    <s:complexType>
      <s:sequence>
        <s:element name="aproperty" type="s:string" minOccurs="0"/>
        <s:element name="description" type="s:string" minOccurs="0">
          <s:annotation>
            <s:documentation xml:lang="EN">A description for the description field</s:documentation>
          </s:annotation>
        </s:element>
      </s:sequence>
    </s:complexType>
   </s:sequence>
</s:schema> 

This should generate a json like :

{
  "type":"object",
  "properties": {
    "description": {
      "description":"A description for the description field",
      "type":"string"
    },
    "aproperty": {"type":"string"}
  }
}

but the process returns this error :

ERROR: Prolog initialisation failed:
ERROR: string_concat/3: Type error: `atomic' expected, found `json([description=A description for the description field,type=string])'
fnogatz commented 8 years ago

This was a bug in merge_json, thanks for the report! I've pushed a fix, the new version is available as 1.4.9 at npm.