-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
An error occurred in the xsd2jsonSchema function when processing xsd with a pattern containing unnecessary escaping of characters "." and "+"
For example for "\+":
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="TestElemet" type="SomeIdVariation48_Type"></xs:element>
<xs:complexType name="Ch_struct2">
<xs:sequence>
<xs:element name="Wdt" type="xs:string"></xs:element>
</xs:sequence>
</xs:complexType>
<xs:simpleType name="SomeIdVariation48_Type">
<xs:restriction base="xs:string">
<xs:pattern value="((-|\+)[0-9]{2}:[0-9]{2})?)?)?" />
</xs:restriction>
</xs:simpleType>
</xs:schema>Expected result:
{
"properties": {
"TestElemet": {
"pattern": "((-|+)[0-9]{2}:[0-9]{2})?)?)?",
"type": "string"
}
},
"type": "object"
}Actual result:
console.log
SyntaxError: Unexpected token + in JSON at position 77
at JSON.parse (<anonymous>)
at xmlSchemaOBJtoJsonSchema (xsdlib\index.js:551:21)
at xsd2jsonSchema (xsdlib\index.js:880:21)
at Object.<anonymous> (xsdlib\__tests__\XsdTest.js:337:18)
at Object.asyncJestTest (xsdlib\node_modules\jest-jasmine2\build\jasmineAsyncInstall.js:106:37)
at xsdlib\node_modules\jest-jasmine2\build\queueRunner.js:45:12
at new Promise (<anonymous>)
at mapper (xsdlib\node_modules\jest-jasmine2\build\queueRunner.js:28:19)
at xsdlib\node_modules\jest-jasmine2\build\queueRunner.js:75:41
at xsd2jsonSchema (index.js:882:13)
For example for ".":
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="TestElemet" type="SomeIdVariation48_Type">
</xs:element>
<xs:complexType name="Ch_struct2">
<xs:sequence>
<xs:element name="Wdt" type="xs:string">
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:simpleType name="SomeIdVariation48_Type">
<xs:restriction base="xs:string">
<xs:pattern value="(\.[0-9]{3})?"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>Expected result:
{
"properties": {
"TestElemet": {
"pattern": "(.[0-9]{3})?",
"type": "string"
}
},
"type": "object"
}Actual result:
console.log
SyntaxError: Unexpected token . in JSON at position 74
at JSON.parse (<anonymous>)
at xmlSchemaOBJtoJsonSchema (xsdlib\index.js:551:21)
at xsd2jsonSchema (xsdlib\index.js:880:21)
at Object.<anonymous> (xsdlib\__tests__\XsdTest.js:315:18)
at Object.asyncJestTest (xsdlib\node_modules\jest-jasmine2\build\jasmineAsyncInstall.js:106:37)
at xsdlib\node_modules\jest-jasmine2\build\queueRunner.js:45:12
at new Promise (<anonymous>)
at mapper (xsdlib\node_modules\jest-jasmine2\build\queueRunner.js:28:19)
at xsdlib\node_modules\jest-jasmine2\build\queueRunner.js:75:41
at xsd2jsonSchema (index.js:882:13)
Metadata
Metadata
Assignees
Labels
No labels