-
Notifications
You must be signed in to change notification settings - Fork 67
Expand file tree
/
Copy pathProgram.cs
More file actions
69 lines (61 loc) · 2.89 KB
/
Program.cs
File metadata and controls
69 lines (61 loc) · 2.89 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
//---------------------------------------------------------------------
// <copyright file="Program.cs" company="Microsoft">
// Copyright (C) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
// </copyright>
//---------------------------------------------------------------------
using System;
using System.Reflection;
using Microsoft.OpenApi.OData;
namespace OoasUtil
{
class Program
{
static async System.Threading.Tasks.Task<int> Main(string[] args)
{
// args = new[] { "--json", "--input", @"E:\work\OneApiDesign\test\TripService.OData.xml", "-o", @"E:\work\OneApiDesign\test1\Trip.json" };
// args = new[] { "--yaml", "-i", @"E:\work\OneApiDesign\test\TripService.OData.xml", "-o", @"E:\work\OneApiDesign\test1\Trip.yaml" };
// args = new[] { "--yaml", "--input", @"http://services.odata.org/TrippinRESTierService", "-o", @"E:\work\OneApiDesign\test1\TripUrl.yaml" };
// args = new[] { "--json", "-i", @"http://services.odata.org/TrippinRESTierService", "-o", @"E:\work\OneApiDesign\test1\TripUrl.json" };
ComLineProcessor processor = new ComLineProcessor(args);
if (!processor.Process())
{
return 0;
}
if (!processor.CanContinue)
{
return 1;
}
OpenApiGenerator generator;
OpenApiConvertSettings settings = new OpenApiConvertSettings
{
EnableKeyAsSegment = processor.KeyAsSegment,
EnableDerivedTypesReferencesForResponses = processor.DerivedTypesReferencesForResponses.Value,
EnableDerivedTypesReferencesForRequestBody = processor.DerivedTypesReferencesForRequestBody.Value,
RequireDerivedTypesConstraintForBoundOperations = processor.RequireDerivedTypesConstraint.Value,
EnablePagination = processor.EnablePagination.Value,
EnableUnqualifiedCall = processor.EnableUnqualifiedCall.Value,
ShowSchemaExamples = !processor.DisableSchemaExamples.Value,
OpenApiSpecVersion = processor.Version.Value,
UseHttpPutForUpdate = processor.UseHttpPutForUpdate.Value,
};
if (processor.IsLocalFile)
{
generator = new FileOpenApiGenerator(processor.Input, processor.Output, processor.Format, settings);
}
else
{
generator = new UrlOpenApiGenerator(new Uri(processor.Input), processor.Output, processor.Format, settings);
}
if (await generator.GenerateAsync())
{
Console.WriteLine("Succeeded!");
return 1;
}
else
{
Console.WriteLine("Failed!");
return 0;
}
}
}
}