I am trying to manipulate my swagger doc. I need to run redoc split
to separate the main swagger.
During start.cs I am getting the swagger doc and saving it to the file system. That works as expected. Then in my split method, I get the swagger doc and run it through redoc split
and nothing happens, no error and no messages. I put breakpoints on the first line, inside the Try block and when I step, it exits so I think an error is getting swallowed somewhere.
I can run this from a command window just fine.
public static void RunSplitCommand()
{
string output = string.Empty;
string error = string.Empty;
var args = "redocly split \"../bin/swagger/Swagger.json\" --outDir= \"../bin/swagger\"";
using (var process = new System.Diagnostics.Process())
{
process.StartInfo = new System.Diagnostics.ProcessStartInfo();
process.StartInfo.WorkingDirectory = Directory.GetCurrentDirectory();
process.StartInfo.FileName = "cmd.exe";
process.StartInfo.Arguments = args;
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardError = true;
try
{
process.Start();
process.WaitForExit();
if (process.StandardOutput.ReadToEnd() != string.Empty)
output = process.StandardOutput.ReadToEnd();
else if (process.StandardError.ReadToEnd() != string.Empty)
output = process.StandardError.ReadToEnd();
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
}
string.Concat(output, "\n");
}