public string GenerateCode(IProgressReporter pGenerateProgress) { try { pGenerateProgress.Progress(10); var jarFile = options.OpenApiGeneratorPath; if (!File.Exists(jarFile)) { Trace.WriteLine(jarFile + " does not exist"); jarFile = DependencyDownloader.InstallOpenApiGenerator(); } 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 " + "--generator-name csharp-netcore " + $"--input-spec \"{Path.GetFileName(swaggerFile)}\" " + $"--output \"{output}\" " + $"--package-name \"{defaultNamespace}\" " + "--global-property apiTests=false,modelTests=false " + "--skip-overwrite "; processLauncher.Start(javaPathProvider.GetJavaExePath(), arguments, Path.GetDirectoryName(swaggerFile)); pGenerateProgress.Progress(80); return(CSharpFileMerger.MergeFilesAndDeleteSource(output)); } finally { pGenerateProgress.Progress(90); } }
public string GenerateCode(IVsGeneratorProgress pGenerateProgress) { try { pGenerateProgress.Progress(10); var jarFile = options.OpenApiGeneratorPath; if (!File.Exists(jarFile)) { Trace.WriteLine(jarFile + " does not exist"); jarFile = DependencyDownloader.InstallOpenApiGenerator(); } pGenerateProgress.Progress(30); var output = Path.Combine( Path.GetDirectoryName(swaggerFile) ?? throw new InvalidOperationException(), "TempApiClient"); Directory.CreateDirectory(output); pGenerateProgress.Progress(40); var arguments = $"-jar \"{jarFile}\" generate " + "-g csharp " + $"--input-spec \"{swaggerFile}\" " + $"--output \"{output}\" " + "-DapiTests=false -DmodelTests=false " + $"-DpackageName={defaultNamespace} " + "--skip-overwrite "; ProcessHelper.StartProcess(javaPathProvider.GetJavaExePath(), arguments); pGenerateProgress.Progress(80); return(CSharpFileMerger.MergeFilesAndDeleteSource(output)); } finally { pGenerateProgress.Progress(90); } }
public void InstallOpenApiGenerator_Force_Returns_Path() => DependencyDownloader .InstallOpenApiGenerator(forceDownload: true) .Should() .NotBeNullOrWhiteSpace();
public void InstallOpenApiGenerator_With_Path_Returns_Path() => DependencyDownloader .InstallOpenApiGenerator(Path.GetTempPath()) .Should() .NotBeNullOrWhiteSpace();