public string GenerateCode(IProgressReporter pGenerateProgress) { try { pGenerateProgress.Progress(10); var jarFile = options.SwaggerCodegenPath; if (!File.Exists(jarFile)) { Trace.WriteLine(jarFile + " does not exist"); jarFile = DependencyDownloader.InstallSwaggerCodegenCli(); } pGenerateProgress.Progress(30); var output = Path.Combine( Path.GetDirectoryName(swaggerFile) ?? throw new InvalidOperationException(), Guid.NewGuid().ToString("N"), "TempApiClient"); Directory.CreateDirectory(output); pGenerateProgress.Progress(40); var arguments = $"-jar \"{jarFile}\" generate " + "-l csharp " + $"--input-spec \"{swaggerFile}\" " + $"--output \"{output}\" " + "-DapiTests=false -DmodelTests=false " + $"-DpackageName={defaultNamespace} "; processLauncher.Start(javaPathProvider.GetJavaExePath(), arguments); pGenerateProgress.Progress(80); return(CSharpFileMerger.MergeFilesAndDeleteSource(output)); } finally { pGenerateProgress.Progress(90); } }
public void InstallSwaggerCodegenCli_Force_Returns_Path() => DependencyDownloader .InstallSwaggerCodegenCli(forceDownload: true) .Should() .NotBeNullOrWhiteSpace();
public void InstallSwaggerCodegenCli_With_Path_Returns_Path() => DependencyDownloader .InstallSwaggerCodegenCli(Path.GetTempPath()) .Should() .NotBeNullOrWhiteSpace();