wsdl-tsclient
wsdl-tsclient copied to clipboard
All properties in the generated interfaces are set to optional even if they are required
As the titel says, all properties are optional. It seems like the code is missing a check for the xml property minOccurs.
I have added this feature in my fork here https://github.com/stuikomma/wsdl-tsclient. It is quite a hacky implementation, but it works on our WSDL and on e.g. the marketo.wsdl example in this repo.
Note that this only handles whether a property is marked optional. Checking whether something should be nullable could be implemented similarly, but I didn't do it, because we don't need it for our use case.
@dderevjanik If you are interested in this functionality, I'd be willing to open a PR and clean up the implementation.
Hi, I will leave this here in case it helps someone else.
In your fork you have this line
const originalSchema = wsdl.definitions.schemas[inputMessage.element.targetNamespace].complexTypes[typeNameWithoutNamespace];
With the wsdl im using, originalSchema would always be undefined, because typeNameWithoutNamespace wouldn't match the case of the keys inside complexTypes.
I ended up doing this, it seems to work for my case, not sure if it's correct or not!
const originalSchema =
(wsdl.definitions.schemas[inputMessage.element.targetNamespace].complexTypes[
typeNameWithoutNamespace
]) || (wsdl.definitions.schemas[inputMessage.element.targetNamespace].complexTypes[
inputMessage.element.$name
]);