Skip to content

Commit 7ac200e

Browse files
committed
Fixed issues related to merge conflicts
1 parent 7db6f8a commit 7ac200e

File tree

3 files changed

+20
-18
lines changed

3 files changed

+20
-18
lines changed

src/Microsoft.OpenApi.Hidi/OpenApiService.cs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ CancellationToken cancellationToken
7171
{
7272
// Default to yaml and OpenApiVersion 3 during csdl to OpenApi conversion
7373
openApiFormat = format ?? GetOpenApiFormat(csdl, logger);
74-
openApiVersion = version == null ? OpenApiSpecVersion.OpenApi3_0 : TryParseOpenApiSpecVersion(version);
75-
74+
openApiVersion = version != null ? TryParseOpenApiSpecVersion(version) : OpenApiSpecVersion.OpenApi3_0;
75+
7676
stream = await GetStream(csdl, logger, cancellationToken);
7777
document = await ConvertCsdlToOpenApi(stream);
7878
}
@@ -113,7 +113,7 @@ CancellationToken cancellationToken
113113
}
114114

115115
openApiFormat = format ?? GetOpenApiFormat(openapi, logger);
116-
openApiVersion = version == null ? TryParseOpenApiSpecVersion(version) : result.OpenApiDiagnostic.SpecificationVersion;
116+
openApiVersion = version != null ? TryParseOpenApiSpecVersion(version) : result.OpenApiDiagnostic.SpecificationVersion;
117117
}
118118

119119
Func<string, OperationType?, OpenApiOperation, bool> predicate;
@@ -181,9 +181,10 @@ CancellationToken cancellationToken
181181
catch (Exception ex)
182182
{
183183
#if DEBUG
184-
logger.LogCritical(ex, ex.Message);
184+
logger.LogCritical(ex, ex.Message);
185185
#else
186186
logger.LogCritical(ex.Message);
187+
187188
#endif
188189
return 1;
189190
}
@@ -335,12 +336,14 @@ internal static async Task<int> ValidateOpenApiDocument(string openapi, LogLevel
335336

336337
OpenApiDocument document;
337338
logger.LogTrace("Parsing the OpenApi file");
338-
document = new OpenApiStreamReader(new OpenApiReaderSettings
339+
var result = await new OpenApiStreamReader(new OpenApiReaderSettings
339340
{
340341
RuleSet = ValidationRuleSet.GetDefaultRuleSet()
341342
}
342-
).Read(stream, out var context);
343+
).ReadAsync(stream);
343344

345+
document = result.OpenApiDocument;
346+
var context = result.OpenApiDiagnostic;
344347
if (context.Errors.Count != 0)
345348
{
346349
foreach (var error in context.Errors)
@@ -355,7 +358,7 @@ internal static async Task<int> ValidateOpenApiDocument(string openapi, LogLevel
355358

356359
logger.LogTrace("Finished walking through the OpenApi document. Generating a statistics report..");
357360
logger.LogInformation(statsVisitor.GetStatisticsReport());
358-
361+
359362
return 0;
360363
}
361364
catch(Exception ex)
@@ -385,7 +388,9 @@ private static ILogger ConfigureLoggerInstance(LogLevel loglevel)
385388

386389
var logger = LoggerFactory.Create((builder) => {
387390
builder
388-
.AddConsole()
391+
.AddConsole(c => {
392+
c.LogToStandardErrorThreshold = LogLevel.Error;
393+
})
389394
#if DEBUG
390395
.AddDebug()
391396
#endif

src/Microsoft.OpenApi.Hidi/Program.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT license.
33

4+
using System;
45
using System.CommandLine;
56
using System.IO;
67
using System.Threading;
@@ -11,7 +12,7 @@ namespace Microsoft.OpenApi.Hidi
1112
{
1213
static class Program
1314
{
14-
static async Task<int> Main(string[] args)
15+
static async Task Main(string[] args)
1516
{
1617
var rootCommand = new RootCommand() {
1718
};
@@ -32,7 +33,7 @@ static async Task<int> Main(string[] args)
3233
var formatOption = new Option<OpenApiFormat?>("--format", "File format");
3334
formatOption.AddAlias("-f");
3435

35-
var logLevelOption = new Option<LogLevel>("--loglevel", () => LogLevel.Warning, "The log level to use when logging messages to the main output.");
36+
var logLevelOption = new Option<LogLevel>("--loglevel", () => LogLevel.Information, "The log level to use when logging messages to the main output.");
3637
logLevelOption.AddAlias("-ll");
3738

3839
var filterByOperationIdsOption = new Option<string>("--filter-by-operationids", "Filters OpenApiDocument by OperationId(s) provided");
@@ -80,7 +81,10 @@ static async Task<int> Main(string[] args)
8081
rootCommand.Add(validateCommand);
8182

8283
// Parse the incoming args and invoke the handler
83-
return await rootCommand.InvokeAsync(args);
84+
await rootCommand.InvokeAsync(args);
85+
86+
//// Wait for logger to write messages to the console before exiting
87+
await Task.Delay(10);
8488
}
8589
}
8690
}

src/Microsoft.OpenApi.Hidi/appsettings.json

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)