if (err) return callback(err);
// Root element of schema should have type dispositif
jsonSchema.$ref = '#/definitions/sformatspivotsadullactnetpublicdispositifv1:DispositifType';
+ // bug fix of xsd2json with complexType
+ var bugFix = function(o) {
+ for (var i in o) {
+ if (typeof o[i] === 'object') {
+ if (o[i].properties && o[i].properties.type === 'string') {
+ console.log('delete invalid type property for ' + i);
+ delete o[i].properties.type;
+ }
+ // recursive bugFix
+ bugFix(o[i]);
+ }
+ }
+ return o;
+ };
+ jsonSchema = bugFix(jsonSchema);
+
fs.writeFile('./dispositif.json', JSON.stringify(jsonSchema, null, 2), callback);
});
});