-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
34 lines (30 loc) · 1.09 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
using System;
using System.IO;
using System.Linq;
using CommandLine;
namespace SwaggerConverter
{
class Program
{
static void Main(string[] args)
{
Parser.Default.ParseArguments<Options>(args).WithParsed<Options>(o =>
{
var finalSwaggerPath = Path.IsPathFullyQualified(o.SwaggerFile) ? o.SwaggerFile : Path.GetRelativePath(Environment.CurrentDirectory, o.SwaggerFile);
var finalOutput = Path.IsPathFullyQualified(o.OutputPath) ? o.OutputPath : Path.GetRelativePath(Environment.CurrentDirectory, o.OutputPath);
if (File.Exists(finalSwaggerPath) == false)
{
Console.Error.WriteLine("File does not exist: " + o.SwaggerFile + ". Resolved to: " + finalSwaggerPath);
return;
}
var sf = SwaggerFile.LoadSwaggerFile(finalSwaggerPath);
var controllerRoutes = sf.Routes.GroupBy((x) => x.Controller);
foreach (var group in controllerRoutes)
{
var controllerName = group.Key;
ControllerWriter.WriteController(controllerName, group.ToList(), finalOutput);
}
});
}
}
}