wsdl-to-ts icon indicating copy to clipboard operation
wsdl-to-ts copied to clipboard

Support minOccurs=0

Open pauldraper opened this issue 7 years ago • 4 comments

Should be optional or undefined if minOccurs=0

pauldraper avatar Nov 10 '18 15:11 pauldraper

Unfortunately I don't believe this is something exposed by the soap library. If it were it could be added, otherwise this lib would need a complete rewrite with a custom XSD parser.

TimLuq avatar Nov 10 '18 16:11 TimLuq

I see that now :(

As is, the wsdl-to-ts cannot really be used with TS's strict nullable setting, as all elements become required.

pauldraper avatar Nov 10 '18 17:11 pauldraper

(Thanks for the quick response, BTW! Great project.)

pauldraper avatar Nov 10 '18 18:11 pauldraper

Yes, the way to handle the situation currently is to either generate the types once and then do manual corrections or, it pains me to say, have objects containing properties whose undefined or null values has been cast to any.

interface ISomeInterface {
  description: string; // : string | null - in reality supports xsi:nil="true"
  name: string;
  restricted: boolean; // ?: boolean - in reality minOccurs="0"
}
const o: ISomeInterface = {
  description: null as any,
  name: "example",
  restricted: undefined as any,
};

TimLuq avatar Nov 11 '18 11:11 TimLuq