outofcoffee / imposter

Scriptable, multipurpose mock server. Run standalone mock servers, or embed mocks within your tests.
https://imposter.sh
Other
349 stars 58 forks source link

Load XSD files recursivelly #355

Open tiagojco opened 1 year ago

tiagojco commented 1 year ago

Hi,

When parsing a WSDL file, Imposter loads the content of all XSD files in the same directory as the WSDL file. This means that all XSD types defined in those files are used to support resolution of types referenced from the WSDL file.

https://docs.imposter.sh/soap_plugin/#xsd-file-locations

Could you make this process recursive ?

I'm not familiar with kotlin, otherwise i could make a PR, but here is change sugestion to the Wsdl parser https://github.com/outofcoffee/imposter/blob/cc11dbd3efe23ae5cd1762162a88ca92a762b290/mock/soap/src/main/java/io/gatehill/imposter/plugin/soap/parser/AbstractWsdlParser.kt#L79

val xsds = wsdlFile.parentFile.walk().filter { it.extension === "xsd" }?.toList() ?: emptyList()

Something like that.

I often deal with .wsdl that import .xsds that are organized in subfolders. Those WSDL i cant mock via imposter because of this restriction.

outofcoffee commented 1 year ago

Hi @tiagojco, thank you for opening this issue. One way we could look to achieve this would be to look for the XSD import element, e.g.

<xs:import namespace="http://example.com/a/namespace" schemaLocation="../parent.xsd"/>

Another alternative could be the include element.

Source: https://www.oreilly.com/library/view/xml-schema/0596002521/re27.html and https://www.oreilly.com/library/view/xml-schema/0596002521/re28.html

If the XSDs are related, do they have xs:import... or xs:include elements within them?