use of org.mule.runtime.extension.api.dsl.syntax.resources.spi.ExtensionSchemaGenerator in project mule by mulesoft.
the class ExtensionsTestInfrastructureDiscoverer method generateSchemaTestResource.
public void generateSchemaTestResource(ExtensionModel model, File generatedResourcesDirectory) {
String xsdFileName = model.getXmlDslModel().getXsdFileName();
try {
ExtensionSchemaGenerator schemaGenerator = getSchemaGenerator();
Set<ExtensionModel> models = new HashSet<>(extensionManager.getExtensions());
models.add(MuleExtensionModelProvider.getExtensionModel());
String schema = schemaGenerator.generate(model, DslResolvingContext.getDefault(models));
File xsd = FileUtils.newFile(generatedResourcesDirectory, xsdFileName);
FileUtils.copyStreamToFile(new ByteArrayInputStream(schema.getBytes()), xsd);
} catch (IOException e) {
throw new RuntimeException(format("Error generating test xsd resource [%s]: " + e.getMessage(), xsdFileName, e));
}
}
Aggregations